useCategory
Read the category definitions that group and order pages in the sidebar.
useCategory() reads docs.categories from app.config and resolves category titles for the current locale. useNavigation uses it to group pages.
Recommended: Declare in app.config
Keys are the slugs of top-level section directories (without the numeric prefix); values are category lists, and list order is sidebar order:
app/app.config.ts
export default defineAppConfig({
docs: {
categories: {
guide: [
{ id: 'basics', title: { 'zh-CN': '基础', 'en': 'Basics' }, icon: 'i-lucide-settings' },
{ id: 'shipping', title: { 'zh-CN': '发布', 'en': 'Shipping' }, icon: 'i-lucide-rocket' }
]
}
}
})
Pages join a category through the category frontmatter field:
content/docs/2.guide/9.deployment.md
---
title: Deployment
category: shipping
---
See Navigation and Categories for details.
Signature
function useCategory(): {
categories: ComputedRef<Record<string, Category[]>>
}
interface Category {
id: string
title: string
icon: string
}
Return Value
| Name | Type | Description |
|---|---|---|
categories | ComputedRef<Record<string, Category[]>> | Keys are section slugs, values are that section's categories with title resolved for the current locale |
Overriding
Create a same-named file in your project. The return shape must stay { categories }:
app/composables/useCategory.ts
export function useCategory() {
const { t } = useMovkI18n()
const categories = computed(() => ({
guide: [
{ id: 'basics', title: t('docs.overview'), icon: 'i-lucide-settings' }
]
}))
return {
categories
}
}
Once overridden, docs.categories no longer applies.
Changelog
No recent changes