Skip to content
Open
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
15 changes: 13 additions & 2 deletions src/app/api/md/[...slug]/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import {allPosts} from 'contentlayer/generated';
import {NextRequest, NextResponse} from 'next/server';
import {NextResponse} from 'next/server';

// Prerender every post's markdown at build time; unknown slugs 404 without
// invoking a function.
export const dynamicParams = false;

export function generateStaticParams() {
// The root index.mdx has an empty path; a catch-all needs at least one segment.
return allPosts
.filter(post => post._raw.flattenedPath !== '')
.map(post => ({slug: post._raw.flattenedPath.split('/')}));
}

export async function GET(
_: NextRequest,
_: Request,
{params}: {params: {slug: string[]}}
) {
const docPath = params.slug.join('/');
Expand Down
5 changes: 5 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"fluid": true,
"ignoreCommand": "git diff --quiet HEAD^ HEAD -- . ':(exclude).github' ':(exclude).agents' ':(exclude).amp' ':(exclude).vscode' ':(exclude)AGENTS.md' ':(exclude)README.md' ':(exclude).gitignore' ':(exclude)cspell*'"
}
Loading