mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-21 19:31:57 +00:00
feat: Add Accept header content negotiation for markdown (#8272)
This commit is contained in:
@@ -21,6 +21,20 @@ const nextConfig = {
|
||||
},
|
||||
async rewrites() {
|
||||
return [
|
||||
// Serve markdown when Accept header prefers text/markdown
|
||||
// Useful for LLM agents - https://www.skeptrune.com/posts/use-the-accept-header-to-serve-markdown-instead-of-html-to-llms/
|
||||
{
|
||||
source: '/:path*',
|
||||
has: [
|
||||
{
|
||||
type: 'header',
|
||||
key: 'accept',
|
||||
value: '(.*text/markdown.*)',
|
||||
},
|
||||
],
|
||||
destination: '/api/md/:path*',
|
||||
},
|
||||
// Explicit .md extension also serves markdown
|
||||
{
|
||||
source: '/:path*.md',
|
||||
destination: '/api/md/:path*',
|
||||
|
||||
Reference in New Issue
Block a user