返回 CodeWhale
route.ts
根目录 / web / app / docs-markdown / [topic] / route.ts
1 import { RELEASE_DOCS, buildTopicMarkdown } from "@/lib/release-docs";
2
3 export const dynamic = "force-static";
4 export const dynamicParams = false;
5
6 export function generateStaticParams() {
7 return RELEASE_DOCS.topics.map((document) => ({ topic: `${document.slug}.md` }));
8 }
9
10 export async function GET(_request: Request, { params }: { params: Promise<{ topic: string }> }) {
11 const { topic } = await params;
12 const body = topic.endsWith(".md") ? buildTopicMarkdown(topic.slice(0, -3)) : null;
13 if (body === null) return new Response("Not found", { status: 404 });
14 return new Response(body, { headers: { "content-type": "text/markdown; charset=utf-8", "cache-control": "public, max-age=3600" } });
15 }
16
16 lines TYPESCRIPT