import path from 'path'; import { readdirSync, readFileSync } from 'fs'; import '../utils/marked.min.js'; export default (fastify, options) => { fastify.get('/', async (request, reply) => { const files = readdirSync(options.docsDir); const readmePath = files.find((file) => /^readme\.md$/i.test(file)) ? path.join(options.docsDir, 'README.md') : null; if (!readmePath) { reply.code(404).send('

README.md not found

'); return; } const markdownContent = readFileSync(readmePath, 'utf-8'); const htmlContent = marked.parse(markdownContent); reply.type('text/html').send(` README ${htmlContent} `); }); };