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

thinking-toggle-wip
Ryan Vogel 2025-12-20 13:05:06 -05:00 committed by Aiden Cline
parent 25e25a2110
commit af66701f44
1 changed files with 18 additions and 0 deletions

View File

@ -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",
},
})
}