• Stars
    star
    702
  • Rank 64,499 (Top 2 %)
  • Language
    JavaScript
  • Created over 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📇 Convert Markdown file to Vue2.0 component.

You have other better choices


vue-markdown-loader

npm vue

Convert Markdown file to Vue Component using markdown-it.

Example

Live demo

https://glitch.com/edit/#!/vue-markdown

Installation

# For Vue1
npm i vue-markdown-loader@0 -D

# For Vue2
npm i vue-markdown-loader -D
npm i  vue-loader vue-template-compiler -D

Feature

  • Hot reload
  • Write vue script
  • Code highlight

Usage

Documentation: Using loaders

webpack.config.js file:

module.exports = {
  module: {
    rules: [
      {
        test: /\.md$/,
        loader: 'vue-markdown-loader'
      }
    ]
  }
};

With vue-loader 15

const VueLoaderPlugin = require('vue-loader/lib/plugin');

module.exports = {
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      },
      {
        test: /\.md$/,
        use: [
          {
            loader: 'vue-loader'
          },
          {
            loader: 'vue-markdown-loader/lib/markdown-compiler',
            options: {
              raw: true
            }
          }
        ]
      }
    ]
  },
  plugins: [new VueLoaderPlugin()]
};

With Vue CLI 3

In your vue.config.js file:

module.exports = {
  chainWebpack: config => {
    config.module.rule('md')
      .test(/\.md/)
      .use('vue-loader')
      .loader('vue-loader')
      .end()
      .use('vue-markdown-loader')
      .loader('vue-markdown-loader/lib/markdown-compiler')
      .options({
        raw: true
      })
  }
}

Options

preventExtract

Since v2.0.0, this loader will automatically extract script and style tags from html token content (#26). If you do not need, you can set this option

{
  test: /\.md$/,
  loader: 'vue-markdown-loader',
  options: {
    preventExtract: true
  }
}

wrapper

You can customize wrapper tag no matter html element tag or vue component tag. Default is 'section'

{
  test: /\.md$/,
  loader: 'vue-markdown-loader',
  options: {
    wrapper: 'article',
  }
}

markdownIt

reference markdown-it

{
  module: {
    rules: [
      {
        test: /\.md$/,
        loader: 'vue-markdown-loader',
        options: {
          // markdown-it config
          preset: 'default',
          breaks: true,
          preprocess: function(markdownIt, source) {
            // do any thing
            return source;
          },
          use: [
            /* markdown-it plugin */
            require('markdown-it-xxx'),
            /* or */
            [require('markdown-it-xxx'), 'this is options']
          ]
        }
      }
    ];
  }
}

Or you can customize markdown-it

var markdown = require('markdown-it')({
  html: true,
  breaks: true
})

markdown
  .use(plugin1)
  .use(plugin2, opts, ...)
  .use(plugin3);

module.exports = {
  module: {
    rules: [
      {
        test: /\.md$/,
        loader: 'vue-markdown-loader',
        options: markdown
      }
    ]
  }
};

Add Vue configuration

var webpack = require('webpack');

module.exports = {
  module: {
    rules: [
      {
        test: /\.md$/,
        loader: 'vue-markdown-loader'
      }
    ]
  },

  plugins: [
    new webpack.LoaderOptionsPlugin({
      vue: {}
    })
  ]
};

License

WTFPL

More Repositories

1

vue-trend

🌈 Simple, elegant spark lines for Vue.js
JavaScript
1,191
star
2

vuep

🎡 A component for rendering Vue components with live editor and preview.
JavaScript
886
star
3

laue

🖖📈 Modern charts for Vue 2.0
JavaScript
263
star
4

vuerify

🚩Validation plugin for Vue.js
JavaScript
191
star
5

vue-region-picker

[DEPRECATED]
JavaScript
158
star
6

vuep.run

🏃 An online playground for Vue2.0
Vue
140
star
7

npmarket

🛒 More efficient search for node packages.
Vue
93
star
8

jsdoc-vue

[➡️ https://github.com/Kocal/jsdoc-vuejs] A jsdoc plugin that parses *.vue files.
Vue
69
star
9

vue-tricks

Vue
47
star
10

donate

❤️ Donate to @QingWei-Li
24
star
11

pue-loader

🐍 A more pythonic javascript for Vue component file. (Pug + CoffeeScript + Stylus)
JavaScript
20
star
12

vue-delay

🐌 Delay rendering component for Vue.js
JavaScript
17
star
13

typer

✍️ A simplified publishing tool
TypeScript
12
star
14

vueo

🍟 Easy to get value from vue instance via object paths.
JavaScript
10
star
15

hostext

🔡 Text hosting service
JavaScript
9
star
16

vuetch

👻 [WIP]A Vue 2.0 component that fetches data from a http request.
JavaScript
8
star
17

theme-color

Material theme color generator.
JavaScript
7
star
18

2webpack2

🕳️ Turn configuration of webpack 1 to 2
JavaScript
5
star
19

buble-jest

Jest plugin to use buble and babel(handle ES Modules) for transformation
JavaScript
5
star
20

highlightext

💡 Highlight text service
JavaScript
4
star
21

noop-webpack-plugin

🤷‍♀️ Webpack plugin that does nothing.
JavaScript
4
star
22

nft-swag

TypeScript
3
star
23

pue-syntax-highlight

Sublime Text syntax highlighting for single-file Vue components
3
star
24

htpl

A JavaScript templating engine uses Vue syntax.
TypeScript
3
star
25

vuea

🍔 Easy to drop or replace specified key in an array.
JavaScript
2
star
26

AutoBackupFolder

定时打包备份指定文件夹的程序
C#
2
star
27

MagicCubeReduction-CFOP

用cfop还原魔方, 第一个c#开发的程序,留个念想
C#
2
star
28

Aha

[DEPRECATED] 魔兽世界拍卖行辅助工具(客户端)
JavaScript
2
star
29

ablog

A homework orz
TypeScript
2
star
30

qingwei-li.github.io

HTML
1
star
31

sort

一些sort算法练习
JavaScript
1
star
32

parsedate

Converts a value to a Date
JavaScript
1
star
33

Polish

[DEPRECATED]
JavaScript
1
star
34

global-bin-path

DEPRECATED
JavaScript
1
star
35

site

1
star