ff-stream-web

git clone git://archive.git.mtrnord.blog/MTRNord/ff-stream-web.git
Log | Files | Refs | README | LICENSE

markdown-loader.js (640B)


      1 /**
      2  * React Starter Kit (https://www.reactstarterkit.com/)
      3  *
      4  * Copyright © 2014-present Kriasoft, LLC. All rights reserved.
      5  *
      6  * This source code is licensed under the MIT license found in the
      7  * LICENSE.txt file in the root directory of this source tree.
      8  */
      9 
     10 const MarkdownIt = require('markdown-it');
     11 const fm = require('front-matter');
     12 
     13 module.exports = function markdownLoader(source) {
     14   const md = new MarkdownIt({
     15     html: true,
     16     linkify: true,
     17   });
     18 
     19   const frontmatter = fm(source);
     20   frontmatter.attributes.html = md.render(frontmatter.body);
     21 
     22   return `module.exports = ${JSON.stringify(frontmatter.attributes)};`;
     23 };