Skip to content

Conversation

@WalshyDev
Copy link
Member

@WalshyDev WalshyDev commented Sep 29, 2025

Summary

If an incoming request says they accept Markdown, render that instead of the usual HTML page. This can help reduce token usage for LLMs.

Test with:

$ curl https://walshy-accept-markdown.preview.developers.cloudflare.com/workers/static-assets/binding/ -H 'Accept: text/markdown' -v

Documentation checklist

  • Is there a changelog entry (guidelines)? If you don't add one for something awesome and new (however small) — how will our customers find out? Changelogs are automatically posted to RSS feeds, the Discord, and X.
  • The documentation style guide has been adhered to.
  • If a larger change - such as adding a new page- an issue has been opened in relation to any incorrect or out of date information that this PR fixes.
  • Files which have changed name or location have been allocated redirects.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 29, 2025

@github-actions
Copy link
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
*.ts @cloudflare/developer-advocacy, @kristianfreeman, @kodster28, @pedrosousa, @haleycode, @GregBrimble, @KianNH, @WalshyDev

@WalshyDev WalshyDev force-pushed the walshy/accept-markdown branch from 9d3a116 to 024d58b Compare September 29, 2025 12:20
@kodster28 kodster28 merged commit fa1b1e2 into production Sep 29, 2025
8 checks passed
@kodster28 kodster28 deleted the walshy/accept-markdown branch September 29, 2025 13:11
@erify-world
Copy link

This pull request updates both the middleware and worker logic to better handle requests for Markdown content. Now, requests with an Accept header indicating a preference for Markdown (text/markdown) will be treated the same as requests directly for /index.md files. This ensures that clients explicitly requesting Markdown receive the appropriate content, improving content negotiation and client compatibility.

Content negotiation improvements:

  • Updated the condition in src/middleware/index.ts to serve Markdown content not only for paths ending with /index.md, but also when the Accept header includes text/markdown.
  • Made a corresponding update in worker/index.ts to apply the same logic, ensuring consistent behavior between the middleware and worker entrypoint.

@erify-world
Copy link

💎🔥 Nice improvement!

This PR enhances the markdown routing logic so requests with an Accept: text/markdown header are now correctly served with the markdown content, not only /index.md paths.

Key points checked:
• ✅ Middleware (src/middleware/index.ts) updated to handle text/markdown.
• ✅ Worker entrypoint (worker/index.ts) aligned with the same logic for consistency.
• ✅ Ensures better support for clients that explicitly request markdown.

Looks solid — this should improve developer experience and interoperability when consuming docs via APIs. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants