File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
app/[lang]/[[...mdxPath]] Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import { SuggestPattern } from '@/app/_components/suggest-pattern'
4
4
import { JsonLd , generateArticleSchema } from '@app/_components/json-ld'
5
+ import { generateBreadcrumbSchema } from '@app/_utils/generate-breadcrumb-schema'
5
6
import { Metadata } from 'next'
6
7
import { generateStaticParamsFor , importPage } from 'nextra/pages'
7
8
import { useMDXComponents } from '../../../mdx-components'
@@ -65,11 +66,29 @@ export default async function Page(props: PageProps) {
65
66
ogImageUrl
66
67
)
67
68
69
+ // Generate breadcrumb items
70
+ const breadcrumbs = [
71
+ { title : 'Home' , url : `/${ params . lang } ` }
72
+ ]
73
+
74
+ if ( params . mdxPath ) {
75
+ let currentPath = ''
76
+ for ( const segment of params . mdxPath ) {
77
+ currentPath += `/${ segment } `
78
+ breadcrumbs . push ( {
79
+ title : segment . charAt ( 0 ) . toUpperCase ( ) + segment . slice ( 1 ) . replace ( / - / g, ' ' ) ,
80
+ url : `/${ params . lang } ${ currentPath } `
81
+ } )
82
+ }
83
+ }
84
+
85
+ const breadcrumbSchema = generateBreadcrumbSchema ( breadcrumbs )
68
86
const pageKey = `${ params . lang } -${ params . mdxPath ?. join ( '-' ) || 'home' } `
69
87
70
88
return (
71
89
< div className = "nextra-content" >
72
90
< JsonLd data = { schemaData } />
91
+ < JsonLd data = { breadcrumbSchema } />
73
92
< Wrapper key = { pageKey } toc = { toc } metadata = { metadata } >
74
93
< MDXContent { ...props } params = { params } />
75
94
{ ! isHomepage && < SuggestPattern /> }
You can’t perform that action at this time.
0 commit comments