Skip to content

Commit 89cd0bf

Browse files
HugoRCDbenjamincanac
authored andcommitted
docs(app): never display empty components category (#4792)
1 parent 76a2433 commit 89cd0bf

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

docs/app/layouts/docs.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ContentNavigationItem } from '@nuxt/content'
33
import { findPageChildren } from '@nuxt/content/utils'
44
55
const route = useRoute()
6+
const { framework } = useSharedData()
67
78
const navigation = inject<Ref<ContentNavigationItem[]>>('navigation')
89
@@ -50,8 +51,20 @@ const categories = {
5051
}]
5152
}
5253
54+
function filterChildrenByFramework(items: ContentNavigationItem[]): ContentNavigationItem[] {
55+
return items.filter((child) => {
56+
if (!child.framework) {
57+
return true
58+
}
59+
60+
return child.framework === framework.value
61+
})
62+
}
63+
5364
function groupChildrenByCategory(items: ContentNavigationItem[], slug: string): ContentNavigationItem[] {
54-
const childrenGroupedByCategory = items.reduce((acc, child) => {
65+
const filteredItems = filterChildrenByFramework(items)
66+
67+
const childrenGroupedByCategory = filteredItems.reduce((acc, child) => {
5568
if (child.category) {
5669
acc[child.category as string] = [...(acc[child.category as string] || []), child]
5770
} else {

0 commit comments

Comments
 (0)