Make your markdown code examples come alive using vue-live
yarn add -D vuepress-plugin-live
# or with npm: npm install -D vuepress-plugin-live
//.vuepress/config.js
module.exports = {
//...
plugins: [["live"]],
};
In your markdown file just add a live
flag to your fenced code blocks.
```vue live
<button>example</button>
```
Path to a custom layout for the vue-live instances
vuepress-plugin-live/layout.vue
//.vuepress/config.js
module.exports = {
//...
plugins: [
["live", { layout: path.resolve(__dirname, "../VueLiveLayout.vue") }],
],
};
Avoid server side rendering the components in components if they are not ssr ready. Remember that vuepress build pre-compiles the html pages you need.
false
//.vuepress/config.js
module.exports = {
//...
plugins: [["live", { noSsr: true }]],
};
Allows users of theis plugin to say what fenced blocks will be rendered with vue-live.
(lang) => / live$/.test(lang) && / live /.test(lang);
//.vuepress/config.js
module.exports = {
//...
plugins: [
[
"live",
{
liveFilter(lang) {
return ["vue", "js", "jsx"].includes(lang);
},
},
],
],
};