Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
vue-md-loader
Advanced tools
Webpack loader for converting Markdown files to ALIVE Vue components.
This page vue-md-loader.wxsm.space is generated by a markdown file.
source: /example
NPM:
npm install vue-md-loader --save-dev
Yarn:
yarn add vue-md-loader --dev
Simply use vue-md-loader
to load .md
files and chain it with your vue-loader
.
module.exports = {
// ...
module: {
rules: [
// ...
{
test: /\.md$/,
loader: 'vue-loader!vue-md-loader'
}
]
}
}
Note that to get code highlighting to work, you need to:
highlight.js/styles/github-gist.css
.module.exports = {
// ...
module: {
rules: [
// ...
{
test: /\.md$/,
loaders: [
'vue-loader',
{
loader: 'vue-md-loader',
options: {
// your preferred options
}
}
]
}
]
}
}
A live demo is:
<template>
<div class="cls">{{msg}}</div>
</template>
<script>
export default {
data () {
return {
msg: 'Hello world!'
}
}
}
</script>
<style>
.cls {
color: red;
background: green;
}
</style>
<!-- some-live-demo.vue -->
becomes something like:
<some-live-demo/>
<pre><code>...</code></pre>
A Vue component with all it's <template>
, <script>
and <style>
settled will be inserted before it's source code block.
Multiple lives inside a single markdown file is supported by:
<script>
from different code blocks:
export default
will be extract into it's own Vue component with no conflicts.export default
will be extract into the same top-level component.<style>
from different code blocks will be extract into the same top-level component.Note:
<template>
found in live block.module.exports = {
// ...
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js' // 'vue/dist/vue.common.js' for webpack 1
}
}
}
String. Default: section
The wrapper of entire markdown content, can be HTML tag name or Vue component name.
Object.
Markdown-It options. Default:
{
html: true,
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value
} catch (__) {}
}
return ''
}
}
Array.
Markdown-It plugins list. For example:
// ...
plugins: [
// Without option
require('markdown-it-plugin-1'),
// With options
[
require('markdown-it-plugin-2'),
{
// ...
}
]
]
// ...
Object.
Markdown-It renderer rules. For example:
rules: {
'table_open': () => '<div class="table-responsive"><table class="table">',
'table_close': () => '</table></div>'
}
Function. For example:
preProcess: function(source) {
// do anything
return source
}
Function. For example
// This is useful when used with front-matter-loader to set the page title in nuxt projects
process: function(source){
let attrs = (source && source.attributes) || {}
attrs.title = attrs.title || ""
return {
template: source.body,
style: "",
script: `export default {
head(){
return {
title: '${attrs.title}'
}
}
}`
}
}
Function. For example:
afterProcess: function(result) {
// do anything
return result
}
Boolean. Default: true
Enable / Disable live detecting and assembling.
Regex. Default: /<!--[\s]*?([-\w]+?).vue[\s]*?-->/i
A code block with livePattern
inside itself becomes a live block. The matched body will become the live Vue component's name and reference (note that they must be unique to each other within the same page).
Function. Default: null
Use this if you wish to change the live template manually after process (e.g. add wrappers). For example:
afterProcessLiveTemplate: function(template) {
return `<div class="live-wrapper">${template}</div>`
}
# install dependencies
npm install
# serve example with hot reload at localhost:8888
npm run dev
# run all tests
npm test
MIT
FAQs
Webpack loader for converting Markdown files to ALIVE Vue components.
The npm package vue-md-loader receives a total of 444 weekly downloads. As such, vue-md-loader popularity was classified as not popular.
We found that vue-md-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.