Eleventy plugin to add a markdown shortcode
npm install eleventy-plugin-markdown-shortcodeAn Eleventy plugin to render markdown as a shortcode within other templating engines.
Thanks to Bryan Robinson for the Eleventy Plugin tutorial
Available on npm.
```
npm install eleventy-plugin-markdown-shortcode --save
Open up your Eleventy config file (probably .eleventy.js) and add the plugin:
``
const markdownShortcode = require("eleventy-plugin-markdown-shortcode");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(markdownShortcode);
};
This plugin is a universal shortcode, so it's available in the following templating engines:
* Liquid
* Nunjucks
* Handlebars
* JavaScript
In your templates, use the following syntax to grab the contents from any markdown file in your project path:
``
{% markdown '/path/to/markdown.md' %}
We handle (read: ignore) frontmatter with the markdown-it-front-matter plugin. You can include standard frontmatter like so:
`
---
title: Frontmatter test
---
It should not include anything that says title or the frontmatter dashes.`
And the plugin will skip the frontmatter, as long as it's valid
You can also pass in markdown-it configuration like so:
```
eleventyConfig.addPlugin(markdownShortcode, {
html: true,
linkify: true,
});
Read the live demo source code
Having problems? File an issue on GitHub