feat: enable Markdown for Agents#121
Draft
ntatoud wants to merge 1 commit into
Draft
Conversation
Add build-time markdown generation and Vercel routing so requests with Accept: text/markdown receive markdown responses with Content-Type: text/markdown. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Member
|
For this one, we need to check if we can do some Astro integration with this code. We had the "same" integration in Fork-It-Community/forkit.community#762 I'll take some time to review yours because I find the code in Fork it! Community's source code a bit "hacky". |
Member
Author
|
@yoannfleurydev yeah, I just quickly drafted this and wanted to refine, but I was not sure that was something we wanted. I simply would rather have it live on the remote than just on my machine. I also have a working "hacky way" of doing this on my blog, so I wanted to find a better way to do that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/integrations/markdown-for-agents.ts— an Astro build integration that converts every pre-rendered HTML page to a.mdfile indist/at build time (239 pages generated)vercel.tsto rewrite requests withAccept: text/markdownto the corresponding.mdfile and serve it withContent-Type: text/markdown; charset=utf-8How it works
At build time, the integration walks
dist/and for eachindex.htmlfile runs it through aunifiedpipeline (rehype-parse → rehype-remark → remark-gfm → remark-stringify) to produce a sibling.mdfile (e.g.dist/fr/blog/index.html → dist/fr/blog.md).On Vercel, a rewrite rule matches any request whose
Acceptheader containstext/markdownand transparently serves the.mdfile with the correctContent-Typeheader.Test plan
curl -H "Accept: text/markdown" https://bearstudio.fr/frreturns markdown withContent-Type: text/markdowncurl https://bearstudio.fr/frreturns HTML as beforePOST https://isitagentready.com/api/scan—checks.contentAccessibility.markdownNegotiation.statusshould be"pass"🤖 Generated with Claude Code