Load Vue component runnable Markdown template

Update frontmatter-markdown-loader to v1.2.0

Kengo Hamasaki / hmsk
Hai-iro
1 min readAug 18, 2018

--

NPM module, “frontmatter-markdown-loader” was returning compiled render and staticRenderFns to run Markdown as Vue template manually. This feature was coming from a bit edge-y use-case of mine to run component dynamically.

In this update, added another attribute vue.component which returns compiled Vue component. (And added tests with jest for the entire features 😉)

This could be extended to give the child component’s implementation which is mentioned in markdown.

So we can run Vue component on Markdown smoothly.

import fm from "something.md"

export default {
extends: fm.vue.component,
components: {
OtherComponent // If markdown has `<other-component>` in body, will work :)
}
}

Sample project to see this feature:

The README.md is including <npm-or-yarn> element. When we load this with frontmatter-markdown-loader, then assign the same name component; eventually the page will be:

🎉

This update happened to build documentation with Markdown which includes multiple Vue components to show sample on Storybook, unlike storybook-readme. (Love this Storybook add-on though)

--

--