Files
wedding/tools/lib/markdown-loader.js

17 lines
395 B
JavaScript

const MarkdownIt = require('markdown-it');
const fm = require('front-matter');
module.exports = function markdownLoader(source) {
this.cacheable();
const md = new MarkdownIt({
html: true,
linkify: true,
});
const frontmatter = fm(source);
frontmatter.attributes.html = md.render(frontmatter.body);
return `module.exports = ${JSON.stringify(frontmatter.attributes)};`;
};