Skip to content

Commit 9d3a116

Browse files
committed
Render Markdown if we get an Accept text/markdown header
1 parent ad2d7ef commit 9d3a116

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/middleware/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const onRequest = defineMiddleware(async (context, next) => {
1414
"accept-encoding": "identity",
1515
},
1616
});
17-
} else if (pathname.endsWith("/index.md")) {
17+
} else if (pathname.endsWith("/index.md") || context.request.headers.get("accept")?.includes("text/markdown")) {
1818
const htmlUrl = new URL(pathname.replace("index.md", ""), context.url);
1919
const html = await (await fetch(htmlUrl)).text();
2020

worker/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default class extends WorkerEntrypoint<Env> {
3333
});
3434
}
3535

36-
if (request.url.endsWith("/index.md")) {
36+
if (request.url.endsWith("/index.md") || request.headers.get("accept")?.includes("text/markdown")) {
3737
const htmlUrl = request.url.replace("index.md", "");
3838
const res = await this.env.ASSETS.fetch(htmlUrl, request);
3939

0 commit comments

Comments
 (0)