@@ -9,7 +9,6 @@ function prefetchPath(path?: string) {
99 }
1010 nuxtApp = nuxtApp ?? useNuxtApp ( )
1111 prefetchedPaths . add ( path )
12- console . log ( 'prefetch' , path )
1312 nuxtApp . hooks . callHook ( 'link:prefetch' , path )
1413}
1514
@@ -57,33 +56,8 @@ function walk(items: NavigationItem[], path: string): boolean {
5756 return false
5857}
5958
60- /**
61- * First leaf page under the navigation node at `path`, if `path` is a section (directory) node.
62- * Returns `undefined` when the path isn't in the tree or already is a leaf — used to redirect
63- * directory URLs like `/getting-started` to their first page.
64- */
65- export function findFirstLeaf (
66- navigation : NavigationItem [ ] | undefined | null ,
67- path : string | undefined
68- ) : string | undefined {
69- if ( ! navigation ?. length || ! path ) return undefined
70- const visit = ( items : NavigationItem [ ] ) : string | undefined => {
71- for ( const item of items ) {
72- if ( item . path === path ) {
73- let current = item
74- while ( current . children ?. length ) current = current . children [ 0 ] !
75- // Guard: a directory `index.md` is emitted as its own first child — no redirect to self.
76- return current . path !== path ? current . path : undefined
77- }
78- if ( item . children ?. length ) {
79- const found = visit ( item . children )
80- if ( found ) return found
81- }
82- }
83- return undefined
84- }
85- return visit ( navigation )
86- }
59+ // Shared with the server-side `/raw/**` mirror (server/routes/raw/[...slug].md.get.ts).
60+ export { findFirstLeaf } from '../../utils/first-leaf'
8761
8862export interface BreadcrumbItem {
8963 title : string
0 commit comments