feat(docs): adding .md to docs pages shows raw markdown (#5823)
This commit is contained in:
parent
7dd8ea58c2
commit
ad6a5e6157
1 changed files with 18 additions and 0 deletions
18
packages/web/src/pages/[...slug].md.ts
Normal file
18
packages/web/src/pages/[...slug].md.ts
Normal 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",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue