-
-
Notifications
You must be signed in to change notification settings - Fork 132
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Clear and concise description of the problem
Custom sequence of items within a category is necessary when editing a docs site, Could we add a mechanism sorting it?
Suggested solution
None.
My temporal solution:
export function usePageList() {
const routerStore = useRouterStore()
const router = routerStore.router
return computed<Post[]>(() => {
const excludePages = ['/:..all', '/:all(.*)*', '/', '/:path(.*)']
const routes = router.getRoutes()
.filter(i => i.name)
.filter(i => i.meta)
.filter(i => i.meta!.frontmatter)
.filter(i => i.path && !excludePages.includes(i.path))
.map((i) => {
return Object.assign({ path: i.path, excerpt: i.meta!.excerpt }, i.meta!.frontmatter || {}) as Post
})
+ // For pages, also sort it.
+ routes.sort((a, b) => {
+ // console.log(a.top, b.top, 'sort post list')
+ return (b.top || 0) - (a.top || 0)
+ })
+
return routes
})
}Alternative
No response
Additional context
No response
Validations
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request