Skip to content

Commit 0c7c44c

Browse files
committed
fix: handle root docs route metadata during export
1 parent 1f63d11 commit 0c7c44c

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

app/docs/[[...mdxPath]]/page.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import { Metadata } from 'next'
55
export const generateStaticParams = generateStaticParamsFor('mdxPath')
66

77
export async function generateMetadata(props: {
8-
params: Promise<{ mdxPath: string[] }>
8+
params: Promise<{ mdxPath?: string[] }>
99
}): Promise<Metadata> {
1010
const params = await props.params
11-
const { metadata } = await importPage(params.mdxPath)
12-
const canonicalPath = params.mdxPath.length > 0
13-
? `/docs/${params.mdxPath.join('/')}/`
11+
const mdxPath = params.mdxPath ?? []
12+
const { metadata } = await importPage(mdxPath)
13+
const canonicalPath = mdxPath.length > 0
14+
? `/docs/${mdxPath.join('/')}/`
1415
: '/docs/'
1516

1617
return {
@@ -29,10 +30,11 @@ export async function generateMetadata(props: {
2930
const Wrapper = getMDXComponents().wrapper
3031

3132
export default async function Page(props: {
32-
params: Promise<{ mdxPath: string[] }>
33+
params: Promise<{ mdxPath?: string[] }>
3334
}) {
3435
const params = await props.params
35-
const result = await importPage(params.mdxPath)
36+
const mdxPath = params.mdxPath ?? []
37+
const result = await importPage(mdxPath)
3638
const { default: MDXContent, toc, metadata } = result
3739
return (
3840
<Wrapper toc={toc} metadata={metadata}>

0 commit comments

Comments
 (0)