diff --git a/lib/homepage.js b/lib/homepage.js new file mode 100644 index 0000000..e648493 --- /dev/null +++ b/lib/homepage.js @@ -0,0 +1,19 @@ +import { unified } from 'unified' +import remarkParse from 'remark-parse' +import remarkRehype from 'remark-rehype' +import rehypeStringify from 'rehype-stringify' +import fs from 'fs' +import path from 'path' + +const __dirname = path.dirname(new URL(import.meta.url).pathname) +const homepagePath = path.join(__dirname, '..', 'HOMEPAGE.md') + +const processor = unified() + .use(remarkParse) + .use(remarkRehype) + .use(rehypeStringify) + +const homepageMD = fs.readFileSync(homepagePath, 'utf8') +const homepageHTML = processor.processSync(homepageMD) + +export default homepageHTML diff --git a/lib/index.js b/lib/index.js index f62f617..b83a6b4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,10 +1,6 @@ import { createRequire } from 'module' -import { unified } from 'unified' -import remarkParse from 'remark-parse' -import remarkRehype from 'remark-rehype' -import rehypeStringify from 'rehype-stringify' -import fs from 'fs' import path from 'path' +import homepageHTML from './homepage.js' const require = createRequire(import.meta.url) const __dirname = path.dirname(new URL(import.meta.url).pathname) @@ -16,15 +12,6 @@ const ejs = require('ejs') const staticsPath = path.join(__dirname, 'public') const viewsPath = path.join(__dirname, 'views') -const homepagePath = path.join(__dirname, '..', 'HOMEPAGE.md') - -const processor = unified() - .use(remarkParse) - .use(remarkRehype) - .use(rehypeStringify) - -const homepageMD = fs.readFileSync(homepagePath, 'utf8') -const homepageHTML = processor.processSync(homepageMD) const app = fastify({ logger: true })