-
Notifications
You must be signed in to change notification settings - Fork 237
Expand file tree
/
Copy pathroute.ts
More file actions
42 lines (34 loc) · 1 KB
/
route.ts
File metadata and controls
42 lines (34 loc) · 1 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { notFound } from 'next/navigation';
import { rewriteCookbookUrlsInText } from '@/lib/geistdocs/cookbook-source';
import { getLLMText, source } from '@/lib/geistdocs/source';
import { i18n } from '@/lib/geistdocs/i18n';
export const revalidate = false;
export async function GET(
_req: Request,
{ params }: RouteContext<'/[lang]/llms.mdx/[[...slug]]'>
) {
const { slug, lang } = await params;
const page = source.getPage(slug, lang);
if (!page) {
notFound();
}
const sitemapPath =
lang === i18n.defaultLanguage ? '/sitemap.md' : `/${lang}/sitemap.md`;
const text = await getLLMText(page);
return new Response(
rewriteCookbookUrlsInText(text) +
`\n\n## Sitemap
[Overview of all docs pages](${sitemapPath})\n`,
{
headers: {
'Content-Type': 'text/markdown',
},
}
);
}
export const generateStaticParams = async ({
params,
}: RouteContext<'/[lang]/llms.mdx/[[...slug]]'>) => {
const { lang } = await params;
return source.generateParams(lang);
};