File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import type { ContentNavigationItem } from ' @nuxt/content'
3+ import { flattenNavigation } from ' ../utils/navigation'
34
45const route = useRoute ()
56const docsNavigation = inject <Ref <ContentNavigationItem []>>(' navigation' )
6- const docsLink = computed (() => docsNavigation ?.value . flatMap ( item => item . children || [ item ]) || [] )
7+ const docsLink = computed (() => flattenNavigation ( docsNavigation ?.value ) )
78const isDocs = computed (() => docsLink .value .findIndex (item => item .path === route .path ) !== - 1 )
89 </script >
910
Original file line number Diff line number Diff line change 1+ import type { ContentNavigationItem } from '@nuxt/content'
2+
3+ export const flattenNavigation = ( items ?: ContentNavigationItem [ ] ) : ContentNavigationItem [ ] => items ?. flatMap (
4+ item => item . children
5+ ? flattenNavigation ( item . children )
6+ : [ item ] ,
7+ ) || [ ]
You can’t perform that action at this time.
0 commit comments