Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nuxt-community/markdownit-module

Markdownit for Nuxt 2
https://github.com/nuxt-community/markdownit-module

Last synced: about 2 months ago
JSON representation

Markdownit for Nuxt 2

Awesome Lists containing this project

README

        

# Markdownit for Nuxt 2
[![npm](https://img.shields.io/npm/dt/@nuxtjs/markdownit.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/markdownit)
[![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/markdownit/latest.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/markdownit)

Using [markdownit-loader](https://github.com/nuxt-community/markdownit-loader) and [markdown-it](https://github.com/markdown-it/markdown-it)

## Setup
- Add `@nuxtjs/markdownit` dependency using yarn or npm to your project
- Add `@nuxtjs/markdownit` to `modules` section of `nuxt.config.js`
```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-div',
'markdown-it-attrs'
]
}
}
```

## Usage

### Using `.vue` files
**TIP** You can also write Vue logic inside ``!

`hello.vue`:
```html

# Hello World!

Current route is: {{ $route.path }}

```

### Using `.md` files

`hello.md`
```md
# Hello World!!
```

`hello.vue`
```html

import hello from '../hello.md'

export default {
computed: {
hello() {
return hello
}
}
}

```

### Using `$md` to render markdown

`nuxt.config.js`:
```js
{
modules: [
'@nuxtjs/markdownit'
],
markdownit: {
runtime: true // Support `$md()`
}
}
```

`hello.vue`:
```html

export default {
data() {
return {
model: '# Hello World!'
}
}
}

```