mirror of
https://github.com/cloudflare/cloudflare-docs.git
synced 2026-01-11 20:06:58 +00:00
Render Markdown if we get an Accept text/markdown header (#25493)
This commit is contained in:
parent
b7b0a21aab
commit
fa1b1e26f6
2 changed files with 8 additions and 2 deletions
|
|
@ -14,7 +14,10 @@ export const onRequest = defineMiddleware(async (context, next) => {
|
|||
"accept-encoding": "identity",
|
||||
},
|
||||
});
|
||||
} else if (pathname.endsWith("/index.md")) {
|
||||
} else if (
|
||||
pathname.endsWith("/index.md") ||
|
||||
context.request.headers.get("accept")?.includes("text/markdown")
|
||||
) {
|
||||
const htmlUrl = new URL(pathname.replace("index.md", ""), context.url);
|
||||
const html = await (await fetch(htmlUrl)).text();
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,10 @@ export default class extends WorkerEntrypoint<Env> {
|
|||
});
|
||||
}
|
||||
|
||||
if (request.url.endsWith("/index.md")) {
|
||||
if (
|
||||
request.url.endsWith("/index.md") ||
|
||||
request.headers.get("accept")?.includes("text/markdown")
|
||||
) {
|
||||
const htmlUrl = request.url.replace("index.md", "");
|
||||
const res = await this.env.ASSETS.fetch(htmlUrl, request);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue