Skip to content

Commit a2a19ba

Browse files
authored
feat: Add Accept header content negotiation for markdown (#8272)
1 parent d340c41 commit a2a19ba

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

next.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ const nextConfig = {
2121
},
2222
async rewrites() {
2323
return [
24+
// Serve markdown when Accept header prefers text/markdown
25+
// Useful for LLM agents - https://www.skeptrune.com/posts/use-the-accept-header-to-serve-markdown-instead-of-html-to-llms/
26+
{
27+
source: '/:path*',
28+
has: [
29+
{
30+
type: 'header',
31+
key: 'accept',
32+
value: '(.*text/markdown.*)',
33+
},
34+
],
35+
destination: '/api/md/:path*',
36+
},
37+
// Explicit .md extension also serves markdown
2438
{
2539
source: '/:path*.md',
2640
destination: '/api/md/:path*',

0 commit comments

Comments
 (0)