vue-md-loader
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "vue-md-loader", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Webpack loader for converting Markdown files to ALIVE Vue components.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -219,2 +219,24 @@ # vue-md-loader | ||
### process | ||
Function. For example | ||
```javascript | ||
// 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}' | ||
} | ||
} | ||
}` | ||
} | ||
} | ||
``` | ||
### afterProcess | ||
@@ -221,0 +243,0 @@ |
@@ -47,2 +47,3 @@ const MarkdownIt = require('markdown-it') | ||
preProcess: null, | ||
process: null, | ||
afterProcess: null | ||
@@ -223,3 +224,10 @@ } | ||
} | ||
let result = this.options.live ? this.parseLives() : {template: source, script: '', style: ''} | ||
let result | ||
if (this.options.process && typeof this.options.process === 'function') { | ||
result = this.options.process(this.source) | ||
result.script = `<script>${result.script || ''}</script>` | ||
result.style = `<style>${result.style || ''}</style>` | ||
} else { | ||
result = this.options.live ? this.parseLives() : {template: this.source, script: '', style: ''} | ||
} | ||
let html = this.markdown.render(result.template) | ||
@@ -226,0 +234,0 @@ let vueFile = `<template><${this.options.wrapper}>${html}</${this.options.wrapper}></template>${result.style}${result.script}` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16435
231
292