@jackfranklin/rollup-plugin-markdown

Parse markdown files and import them with Rollup

Usage no npm install needed!

<script type="module">
  import jackfranklinRollupPluginMarkdown from 'https://cdn.skypack.dev/@jackfranklin/rollup-plugin-markdown';
</script>

README

rollup-plugin-markdown

CircleCI

A Rollup plugin to parse Markdown files.

  • Showdown is used to parse the Markdown
  • Gray Matter is used to parse front-matter from the markdown file.

Install

npm install --save-dev @jackfranklin/rollup-plugin-markdown

yarn add --dev @jackfranklin/rollup-plugin-markdown

Example module output

import blogPost from './blog-post.md'

// from this import you get:
blogPost.html // the parsed HTML
blogPost.metadata // a JS object of the front-matter
blogPost.filename // blog-post.md - the filename that was imported

Rollup configuration

import markdown from '@jackfranklin/rollup-plugin-markdown'

export default {
  input: 'your-app.js',
  plugins: [markdown()],
}

You can pass in four options:

  • include and exclude, which are globs to limit which file(s) the plugin is applied to.
  • showdownOptions, which are options to pass to the Showdown converter.
  • showdownExtensions, which is an array of Showdown extensions.

The plugin will only parse .md files.

Changelog

0.3.0 [13th Jan 2021]

  • Allow Showdown options and extensions to be registered. Thanks to @mattfran and @arnorhs for their contributions.

0.2.0

  • expose full path to Markdown file as .path from the import.

0.1.0

  • Initial release