Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/pages/[...entry]/index.html.md.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { APIRoute } from "astro";
import type { InferGetStaticPropsType, GetStaticPaths } from "astro";

import { getCollection } from "astro:content";

export const getStaticPaths = (async () => {
const entries = await getCollection("docs");

return entries.map((entry) => {
return {
params: {
// https://llmstxt.org/: (URLs without file names should append index.html.md instead.)
entry: entry.slug + "/index",
},
props: {
entry,
},
};
});
}) satisfies GetStaticPaths;

type Props = InferGetStaticPropsType<typeof getStaticPaths>;

export const GET: APIRoute<Props> = (context) => {
return new Response(context.props.entry.body, {
headers: {
"content-type": "text/markdown",
},
});
};
14 changes: 14 additions & 0 deletions src/pages/llms-full.txt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { APIRoute } from "astro";
import { getCollection } from "astro:content";

export const GET: APIRoute = async () => {
const markdown = await getCollection("docs")
.then((entries) => entries.map((entry) => entry.body))
.then((array) => array.join("\n\n"));

return new Response(markdown, {
headers: {
"content-type": "text/plain",
},
});
};
Loading