Skip to content

Commit c92b0ff

Browse files
committed
site: add llms.txt index pointing at markdown blog siblings
1 parent 77850b9 commit c92b0ff

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

app/llms.txt/route.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { getAllPosts } from "@/lib/blog";
2+
import { absoluteUrl, siteConfig } from "@/lib/site";
3+
4+
export const dynamic = "force-static";
5+
6+
export async function GET() {
7+
const posts = await getAllPosts();
8+
9+
const lines = [
10+
`# ${siteConfig.name}`,
11+
"",
12+
`> ${siteConfig.description}`,
13+
"",
14+
"## Blog",
15+
"",
16+
...posts.map(
17+
(post) =>
18+
`- [${post.title}](${absoluteUrl(`/blog/${post.slug}/index.md`)}): ${post.description}`,
19+
),
20+
"",
21+
];
22+
23+
return new Response(lines.join("\n"), {
24+
headers: {
25+
"Content-Type": "text/plain; charset=utf-8",
26+
"Cache-Control": "public, s-maxage=3600, stale-while-revalidate=86400",
27+
},
28+
});
29+
}

0 commit comments

Comments
 (0)