mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-24 00:40:34 +01:00
docs: add @nuxt/ui-pro source (#2775)
This commit is contained in:
@@ -2,25 +2,34 @@ import type { ContentNavigationItem } from '@nuxt/content'
|
||||
|
||||
function processNavigationItem(item: ContentNavigationItem, parent?: ContentNavigationItem): any {
|
||||
if (item.shadow) {
|
||||
return item.children?.map(child => processNavigationItem(child, item))
|
||||
return item.children?.flatMap(child => processNavigationItem(child, item))
|
||||
}
|
||||
|
||||
return {
|
||||
...item,
|
||||
title: parent?.title || item.title,
|
||||
class: item.framework ? `${item.framework}-only` : undefined,
|
||||
title: parent?.title && parent.title !== 'Pro' ? parent.title : item.title,
|
||||
badge: parent?.badge || item.badge,
|
||||
class: [item.framework && `${item.framework}-only`, item.module && `${item.module}-only`].filter(Boolean),
|
||||
children: item.children?.length ? item.children?.flatMap(child => processNavigationItem(child)) : undefined
|
||||
}
|
||||
}
|
||||
|
||||
export const useContentNavigation = (navigation: Ref<ContentNavigationItem[] | undefined>) => {
|
||||
const { framework } = useSharedData()
|
||||
const { framework, module } = useSharedData()
|
||||
|
||||
const mappedNavigation = computed(() => navigation.value?.map(item => processNavigationItem(item)))
|
||||
const filteredNavigation = computed(() => mappedNavigation.value?.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
children: item.children?.filter((child: any) => !child.framework || child.framework === framework.value)
|
||||
children: item.children?.filter((child: any) => {
|
||||
if (child.framework && child.framework !== framework.value) {
|
||||
return false
|
||||
}
|
||||
if (child.module && child.module !== module.value) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
}))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user