mirror of
https://github.com/fosrl/docs-v2.git
synced 2026-09-30 17:59:10 +02:00
25 lines
699 B
TypeScript
25 lines
699 B
TypeScript
import { docsLlms, source } from '@/lib/source';
|
|
import { getPageMarkdownUrl } from '@/lib/shared';
|
|
import { notFound } from 'next/navigation';
|
|
|
|
export const revalidate = false;
|
|
|
|
export async function GET(_req: Request, { params }: RouteContext<'/llms.mdx/[[...slug]]'>) {
|
|
const { slug } = await params;
|
|
// last segment is always `content.md`
|
|
const page = source.getPage(slug?.slice(0, -1));
|
|
if (!page) notFound();
|
|
|
|
return new Response(await docsLlms.page(page), {
|
|
headers: {
|
|
'Content-Type': 'text/markdown; charset=utf-8',
|
|
},
|
|
});
|
|
}
|
|
|
|
export function generateStaticParams() {
|
|
return source.getPages().map((page) => ({
|
|
slug: getPageMarkdownUrl(page).segments,
|
|
}));
|
|
}
|