vue-markdoc
Vue renderer for Markdoc
2,292
| Install | |
|---|---|
npm install vue-markdoc |
|
| Latest Version: | 0.3.0 |
| Vue: | 3 |
| License: | MIT |
| Last Updated: | Jun 6, 2023 |
| Links: | npm |
Maintainer: wobsoriano
vue-markdoc
Transform Markdoc renderable trees to Vue components.
Installation
pnpm add @markdoc/markdoc vue-markdoc
Usage
<script setup>
import Markdoc from '@markdoc/markdoc'
import render from 'vue-markdoc'
const doc = `
# Getting started
Run this command to install the Markdoc library:
`
const ast = Markdoc.parse(doc)
const content = Markdoc.transform(ast)
const ContentComponent = render(content)
</script>
<template>
<ContentComponent />
</template>
Rendering Vue components
To render a Vue component, provide the components object as an argument along with the content. The components object specifies a mapping from your tags and nodes to the corresponding Vue component.
<script setup>
import Markdoc from '@markdoc/markdoc'
import render from 'vue-markdoc'
import Callout from './Callout.vue'
const tags = {
callout: {
render: Callout,
attributes: {}
}
};
const doc = `
{% callout %}
Attention, over here!
{% /callout %}
`;
const ast = Markdoc.parse(doc)
const content = Markdoc.transform(ast, { tags })
const ContentComponent = render(content)
</script>
<template>
<ContentComponent />
</template>
<template>
<div class="callout">
<slot />
</div>
</template>
<style>
.callout {...}
</style>
Related
- unplugin-markdoc - Markdoc plugin for Vite/Webpack.
License
MIT
Related Packages
frontmatter-markdown-loader
Webpack loader for Front Matter Markdown file to get front matter attributes, co...
510,179
250
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 0.3.0 | ^3.2.0 | MIT | |
| 0.2.1 | ^3.2.0 | MIT | |
| 0.2.0 | ^3.2.0 | MIT | |
| 0.1.3 | >=3.2.0 | MIT | |
| 0.1.2 | >=3.2.0 | MIT | |
| 0.1.1 | >=3.2.0 | MIT |