Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/_redirects
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/bug /bugs
/bug /bugs/ 301
12 changes: 10 additions & 2 deletions src/app/[[...mdxPath]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Metadata } from 'next';
import type { FC } from 'react';
import { generateStaticParamsFor, importPage } from 'nextra/pages';
import { removeLinks } from 'nextra/remove-links';
Expand All @@ -6,10 +7,17 @@ import { useMDXComponents as getMDXComponents } from '../../mdx-components';

export const generateStaticParams = generateStaticParamsFor('mdxPath');

export async function generateMetadata(props: PageProps) {
export async function generateMetadata(props: PageProps): Promise<Metadata> {
const params = await props.params;
const { metadata } = await importPage(params.mdxPath);
return metadata;
const path = (params.mdxPath ?? []).map(encodeURIComponent).join('/');
return {
...metadata,
alternates: {
...metadata.alternates,
canonical: path ? `/${path}/` : '/',
},
};
}

type PageProps = Readonly<{
Expand Down