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

This commit is contained in:
Ryan Vogel 2025-12-20 13:05:06 -05:00 committed by GitHub
parent 7dd8ea58c2
commit ad6a5e6157
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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