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.
npm install --save-dev @jackfranklin/rollup-plugin-markdown
yarn add --dev @jackfranklin/rollup-plugin-markdown
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
import markdown from '@jackfranklin/rollup-plugin-markdown'
export default {
input: 'your-app.js',
plugins: [markdown()],
}
You can pass in four options:
include
andexclude
, 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.
- Allow Showdown options and extensions to be registered. Thanks to @mattfran and @arnorhs for their contributions.
- expose full path to Markdown file as
.path
from the import.
- Initial release