Skip to content
Open
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
13 changes: 9 additions & 4 deletions src/app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ import {getMDXComponent} from 'next-contentlayer/hooks';
import {notFound} from 'next/navigation';
import {Suspense} from 'react';

export const maxDuration = 300;
// Every page is enumerated by generateStaticParams. Reject unknown slugs at the
// router so the site returns a real HTTP 404. Without this, notFound() runs
// inside the root layout's <Suspense> after the response has started streaming,
// and the not-found page is served with status 200.
export const dynamicParams = false;

export const generateStaticParams = async () => {
return allPosts.map(post => ({
params: {slug: post._raw.flattenedPath.split('/')}
}));
return allPosts
// The root document is served by app/page.tsx, not this catch-all route.
.filter(post => post._raw.flattenedPath !== '')
.map(post => ({slug: post._raw.flattenedPath.split('/')}));
};

export const generateMetadata = ({params}: Props) => {
Expand Down