Skip to content

The open source coding agent.

TypeScript

feat(docs): adding .md to docs pages shows raw markdown (#5823)

Ryan Vogelad6a5e6157ea
diff --git a/packages/web/src/pages/[...slug].md.ts b/packages/web/src/pages/[...slug].md.ts
new file mode 100644
index 00000000000..51c63b5a69d
--- /dev/null
+++ b/packages/web/src/pages/[...slug].md.ts
@@ -0,0 +1,18 @@
+import type { APIRoute } from "astro"
+import { getCollection } from "astro:content"
+
+export const GET: APIRoute = async ({ params }) => {
+ const slug = params.slug || "index"
+ const docs = await getCollection("docs")
+ const doc = docs.find((d) => d.id === slug)
+
+ if (!doc) {
+ return new Response("Not found", { status: 404 })
+ }
+
+ return new Response(doc.body, {
+ headers: {
+ "Content-Type": "text/plain; charset=utf-8",
+ },
+ })
+}