@@ -5,8 +5,6 @@ import clsx from 'clsx';
55import { ChevronRightIcon } from '@heroicons/react/20/solid' ;
66import { useEffect , useState } from 'react' ;
77import { usePathname } from 'next/navigation' ;
8- import { navigation } from '@/data/navigation' ;
9- import { allPosts } from 'contentlayer/generated' ;
108
119export function Breadcrumbs ( { path} : { path : string [ ] } ) {
1210 let pathname = usePathname ( ) ;
@@ -25,36 +23,6 @@ export function Breadcrumbs({path}: {path: string[]}) {
2523 return version ? `/v/${ version } ${ path } ` : path ;
2624 } ;
2725
28- const getTitleForSlug = ( currentPath : string [ ] ) : string => {
29- const href = `/${ currentPath . join ( '/' ) } ` ;
30-
31- for ( const navItem of navigation ) {
32- for ( const topic of navItem . topics ) {
33- if ( topic . href === href ) return topic . title ;
34-
35- if ( topic . sections ) {
36- for ( const section of topic . sections ) {
37- if ( section . href === href ) return section . title ;
38-
39- if ( section . subsections ) {
40- for ( const subsection of section . subsections ) {
41- if ( subsection . href === href ) return subsection . title ;
42- }
43- }
44- }
45- }
46- }
47- }
48-
49- const pagePath = currentPath . join ( '/' ) ;
50- const post = allPosts . find ( post => post . _raw . flattenedPath === pagePath ) ;
51- if ( post && post . headings && post . headings . length > 0 ) {
52- return post . headings [ 0 ] . title ;
53- }
54-
55- throw new Error ( `No title found in navigation.ts or page headings for path: ${ href } ` ) ;
56- } ;
57-
5826 // Handle versions
5927 useEffect ( ( ) => {
6028 // Extract the version name from the URL path, if any
@@ -99,7 +67,7 @@ export function Breadcrumbs({path}: {path: string[]}) {
9967 : 'text-gray-500 hover:text-link-light dark:hover:text-link'
10068 ) }
10169 >
102- { getTitleForSlug ( path . slice ( 0 , index + 1 ) ) }
70+ { slug }
10371 </ Link >
10472 </ div >
10573 </ li >
0 commit comments