useCategory

Provides the sidebar category definitions that decide how pages with a category are grouped and ordered within a section. Declare them in docs.categories in app.config; override the composable in your project only when categories must be computed at runtime.

useCategory() reads docs.categories from app.config and resolves category titles for the current locale. useNavigation uses it to group pages.

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

NameTypeDescription
categoriesComputedRef<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
Copyright © 2024 - 2026