Skip to content

Commit ad6a5e6

Browse files
authored
feat(docs): adding .md to docs pages shows raw markdown (#5823)
1 parent 7dd8ea5 commit ad6a5e6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { APIRoute } from "astro"
2+
import { getCollection } from "astro:content"
3+
4+
export const GET: APIRoute = async ({ params }) => {
5+
const slug = params.slug || "index"
6+
const docs = await getCollection("docs")
7+
const doc = docs.find((d) => d.id === slug)
8+
9+
if (!doc) {
10+
return new Response("Not found", { status: 404 })
11+
}
12+
13+
return new Response(doc.body, {
14+
headers: {
15+
"Content-Type": "text/plain; charset=utf-8",
16+
},
17+
})
18+
}

0 commit comments

Comments
 (0)