Using markdownit-loader and markdown-it
- Add
@nuxtjs/markdownit
dependency using yarn or npm to your project - Add
@nuxtjs/markdownit
tomodules
section ofnuxt.config.js
{
modules: [
'@nuxtjs/markdownit'
],
// [optional] markdownit options
// See https://github.com/markdown-it/markdown-it
markdownit: {
preset: 'default',
linkify: true,
breaks: true,
use: [
'markdown-it-container',
'markdown-it-attrs'
]
}
}
TIP You can also write Vue logic inside <template lang="md">
!
hello.vue
:
<template lang="md">
# Hello World!
Current route is: {{ $route.path }}
</template>
hello.md
# Hello World!!
hello.vue
<template>
<div v-html="hello"></div>
</template>
<script>
import hello from '../hello.md'
export default {
computed: {
hello() {
return hello
}
}
}
</script>