feat: Add accept/markdown to apps/landing

This commit is contained in:
Dries Augustyns
2026-04-20 17:09:56 +02:00
parent bd5a085802
commit df76be1b87
3 changed files with 401 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import { MARKDOWN_PAGES } from '../../content/pages';
export default function handler(req: NextApiRequest, res: NextApiResponse) {
const pathname = req.headers['x-md-path'];
if (typeof pathname !== 'string') {
res.status(406).end();
return;
}
const slug = pathname.replace(/^\/+|\/+$/g, '') || 'index';
res.setHeader('Vary', 'Accept');
const content = MARKDOWN_PAGES[slug];
if (!content) {
res.status(406).end();
return;
}
res.setHeader('Content-Type', 'text/markdown; charset=utf-8');
res.status(200).send(content);
}