diff --git a/src/pages/[...entry]/index.html.md.ts b/src/pages/[...entry]/index.html.md.ts new file mode 100644 index 000000000000000..d3251d720d5c91a --- /dev/null +++ b/src/pages/[...entry]/index.html.md.ts @@ -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; + +export const GET: APIRoute = (context) => { + return new Response(context.props.entry.body, { + headers: { + "content-type": "text/markdown", + }, + }); +}; diff --git a/src/pages/llms-full.txt.ts b/src/pages/llms-full.txt.ts new file mode 100644 index 000000000000000..18dbe023a0e23b6 --- /dev/null +++ b/src/pages/llms-full.txt.ts @@ -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", + }, + }); +};