Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion layer/modules/markdown-rewrite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,22 @@ export default defineNuxtModule({
return
}

// Always redirect / to /llms.txt
// Always redirect / to /llms.txt and ensure plain text content type
const markdownHeaders = {
'content-type': 'text/markdown; charset=utf-8',
}

const routes = [
{
src: '^/$',
dest: '/llms.txt',
headers: markdownHeaders,
has: [{ type: 'header', key: 'accept', value: '(.*)text/markdown(.*)' }],
},
{
src: '^/$',
dest: '/llms.txt',
headers: markdownHeaders,
has: [{ type: 'header', key: 'user-agent', value: 'curl/.*' }],
},
]
Expand All @@ -66,11 +72,13 @@ export default defineNuxtModule({
{
src: `^/(${localePattern})$`,
dest: '/llms.txt',
headers: markdownHeaders,
has: [{ type: 'header', key: 'accept', value: '(.*)text/markdown(.*)' }],
},
{
src: `^/(${localePattern})$`,
dest: '/llms.txt',
headers: markdownHeaders,
has: [{ type: 'header', key: 'user-agent', value: 'curl/.*' }],
},
)
Expand Down Expand Up @@ -109,11 +117,13 @@ export default defineNuxtModule({
{
src: `^${pagePath}$`,
dest: rawPath,
headers: markdownHeaders,
has: [{ type: 'header', key: 'accept', value: '(.*)text/markdown(.*)' }],
},
{
src: `^${pagePath}$`,
dest: rawPath,
headers: markdownHeaders,
has: [{ type: 'header', key: 'user-agent', value: 'curl/.*' }],
},
]
Expand Down
Loading