File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
src/components/breadcrumbs Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -9,22 +9,26 @@ type BreadcrumbsProps = {
99} ;
1010
1111export function Breadcrumbs ( { leafNode} : BreadcrumbsProps ) {
12- const nodes : DocNode [ ] = [ ] ;
12+ const breadcrumbs : { title : string ; to : string } [ ] = [ ] ;
13+
1314 for ( let node : DocNode | undefined = leafNode ; node ; node = node . parent ) {
1415 if ( node && ! node . missing ) {
15- nodes . unshift ( node ) ;
16+ const to = node . path === '/' ? node . path : `/${ node . path } /` ;
17+ const title = node . frontmatter . platformTitle ?? node . frontmatter . title ;
18+
19+ breadcrumbs . unshift ( {
20+ to,
21+ title,
22+ } ) ;
1623 }
1724 }
1825
1926 return (
2027 < ul className = "list-none flex p-0 flex-wrap" style = { { margin : 0 } } >
21- { nodes . map ( n => {
22- const to = n . path === '/' ? n . path : `/${ n . path } /` ;
28+ { breadcrumbs . map ( b => {
2329 return (
24- < li className = { styles [ 'breadcrumb-item' ] } key = { n . path } >
25- < SmartLink to = { to } >
26- { n . frontmatter . platformTitle ?? n . frontmatter . title }
27- </ SmartLink >
30+ < li className = { styles [ 'breadcrumb-item' ] } key = { b . to } >
31+ < SmartLink to = { b . to } > { b . title } </ SmartLink >
2832 </ li >
2933 ) ;
3034 } ) }
You can’t perform that action at this time.
0 commit comments