snowpack-markdown-it-plugin

A Snowpack plugin for converting .md files to HTML with your own custom render function. Great for building a DIY static site generator.

Usage no npm install needed!

<script type="module">
  import snowpackMarkdownItPlugin from 'https://cdn.skypack.dev/snowpack-markdown-it-plugin';
</script>

README

@vcarrier/snowpack-plugin-markdown-it

A Snowpack plugin for converting .md files to HTML with your own custom render function. Great for building a DIY static site generator.

Getting started

Installation:

npm i -D @vcarrier/snowpack-plugin-markdown-it

Example usage:

// snowpack.config.js
module.exports = {
  mount: {
    // Make sure your .md files are in a mounted directory
  },
  plugins: [
    [
      '@vcarrier/snowpack-plugin-markdown-it',
      {
        // markdown-it config
        md: {
          html: true,
          typographer: true,
        },

        // `content` is the HTML generated from your .md file
        // `metadata` is your frontmatter object
        // The return value should be an HTML string
        render(content, metadata) {
          return renderPost({ content, ...metadata })
        },
      },
    ],
  ],
  /* ... */
}