-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathroute.ts
More file actions
28 lines (23 loc) · 724 Bytes
/
route.ts
File metadata and controls
28 lines (23 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import type { NextRequest } from "next/server";
import { getDocument } from "@/utils/docs";
import { NextResponse } from "next/server";
interface ApiDocsPageProps {
params: Promise<{ folder: string; slug: string[] }>;
}
export async function GET(request: NextRequest, { params }: ApiDocsPageProps) {
const { folder, slug } = await params;
const document = slug.join("/");
const data = getDocument({
folder,
document,
});
if (!data) {
return new NextResponse("Document not found", { status: 404 });
}
return new NextResponse(data.content, {
headers: {
"Content-Type": "text/markdown; charset=utf-8",
"Cache-Control": "public, max-age=3600", // Cache for 1 hour
},
});
}