feat(site): add markdown content negotiation via Netlify edge function#573
Merged
feat(site): add markdown content negotiation via Netlify edge function#573
Conversation
Serve pre-built markdown files when clients send Accept: text/markdown. Includes token count manifest for x-markdown-tokens response header.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
📦 Bundle Size Report
Total: 36.60 kB · 0 B · 0% Entry BreakdownSubpath sizes are the additional bytes on top of the root entry point, measured by bundling root + subpath together and subtracting the root-only size.
|
| Entry | Base | PR | Diff | % | |
|---|---|---|---|---|---|
. |
3.09 kB | 3.09 kB | 0 B | 0% | ✅ |
./dom |
2.58 kB | 2.58 kB | 0 B | 0% | ✅ |
| total | 5.67 kB | 5.67 kB | 0 B | 0% |
@videojs/element
| Entry | Base | PR | Diff | % | |
|---|---|---|---|---|---|
. |
817 B | 817 B | 0 B | 0% | ✅ |
./context |
823 B | 823 B | 0 B | 0% | ✅ |
| total | 1.60 kB | 1.60 kB | 0 B | 0% |
@videojs/icons
| Entry | Base | PR | Diff | % | |
|---|---|---|---|---|---|
./react |
2.10 kB | 2.10 kB | 0 B | 0% | ✅ |
./html |
1.37 kB | 1.37 kB | 0 B | 0% | ✅ |
| total | 3.46 kB | 3.46 kB | 0 B | 0% |
@videojs/react
| Entry | Base | PR | Diff | % | |
|---|---|---|---|---|---|
. |
7.69 kB | 7.69 kB | 0 B | 0% | ✅ |
./audio |
266 B | 266 B | 0 B | 0% | ✅ |
./background |
35 B | 35 B | 0 B | 0% | ✅ |
./video |
4.84 kB | 4.84 kB | 0 B | 0% | ✅ |
| total | 12.82 kB | 12.82 kB | 0 B | 0% |
@videojs/store
| Entry | Base | PR | Diff | % | |
|---|---|---|---|---|---|
. |
1.29 kB | 1.29 kB | 0 B | 0% | ✅ |
./html |
468 B | 468 B | 0 B | 0% | ✅ |
./react |
199 B | 199 B | 0 B | 0% | ✅ |
| total | 1.94 kB | 1.94 kB | 0 B | 0% |
@videojs/utils
| Entry | Base | PR | Diff | % | |
|---|---|---|---|---|---|
./array |
104 B | 104 B | 0 B | 0% | ✅ |
./dom |
684 B | 684 B | 0 B | 0% | ✅ |
./events |
227 B | 227 B | 0 B | 0% | ✅ |
./function |
197 B | 197 B | 0 B | 0% | ✅ |
./object |
119 B | 119 B | 0 B | 0% | ✅ |
./predicate |
265 B | 265 B | 0 B | 0% | ✅ |
./string |
110 B | 110 B | 0 B | 0% | ✅ |
./style |
185 B | 185 B | 0 B | 0% | ✅ |
./time |
478 B | 478 B | 0 B | 0% | ✅ |
./number |
158 B | 158 B | 0 B | 0% | ✅ |
| total | 2.47 kB | 2.47 kB | 0 B | 0% |
ℹ️ How to interpret
Sizes are minified + brotli, measured with esbuild.
Package totals are computed as root size + marginal subpath costs.
Subpath marginal cost = (root + subpath bundled together) − root alone.
| Icon | Meaning |
|---|---|
| ✅ | No change |
| 🔺 | Increased ≤ 10% |
| 🔴 | Increased > 10% |
| 🔽 | Decreased |
| 🆕 | New (no baseline) |
Run pnpm size locally to check current sizes.
The pre-built token manifest added a fetch round-trip in the edge function, negating the latency benefit. Since we already have the markdown body in memory, compute tokens inline with chars/4. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add CDN caching for edge function responses. Netlify atomic deploys automatically invalidate the cache, so s-maxage can be set to 1 year. Cached responses don't count toward edge function invocations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1a3a8fd to
092770c
Compare
sampotts
reviewed
Feb 19, 2026
|
|
||
| const headers = new Headers(); | ||
| headers.set('content-type', 'text/markdown; charset=utf-8'); | ||
| headers.set('cache-control', 'public, s-maxage=31536000'); |
Collaborator
There was a problem hiding this comment.
Will the content not change?
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
Serve pre-built markdown to AI agents via HTTP content negotiation. When a request includes
Accept: text/markdown, a Netlify Edge Function rewrites to the.mdfile generated by thellms-markdownintegration and returns it with the correctContent-Typeand anx-markdown-tokensheader.Inspiration
vercel.jsonrewrites withAcceptheader matchingOur implementation uses Netlify Edge Functions with declarative header matching to achieve the same effect with pre-built
.mdfiles.Changes
site/netlify/edge-functions/markdown-negotiation.ts): triggers only for/blog/*and/docs/*requests withAccept: text/markdown. Rewrites to the.mdsibling, setsContent-Type: text/markdown,Vary: Accept,Cache-Control, andx-markdown-tokens.cache: "manual"withs-maxage=31536000. Netlify atomic deploys automatically invalidate, so cached responses are always fresh per deploy.@netlify/edge-functionsadded as a dev dependency for type safety.Test plan
Markdown response — returns markdown with correct headers:
Normal HTML response — unaffected by edge function:
Fallback for pages without
.md— edge function passes through:🤖 Generated with Claude Code