We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7dd8ea5 commit ad6a5e6Copy full SHA for ad6a5e6
packages/web/src/pages/[...slug].md.ts
@@ -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