demo-md-loader
Advanced tools
Comparing version 1.0.2 to 1.0.3
38
index.js
'use strict'; | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const frontMatter = require('front-matter'); | ||
const camelize = require('camelize'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var frontMatter = require('front-matter'); | ||
var camelize = require('camelize'); | ||
function build(markdown) { | ||
return new Promise((resolve, reject) => { | ||
let doImports = ''; | ||
const codeFiles = markdown.codeFiles; | ||
const mods = []; | ||
const linkPromise = []; | ||
var doImports = ''; | ||
var codeFiles = markdown.codeFiles; | ||
var mods = []; | ||
var linkPromise = []; | ||
if (codeFiles.length === 0) { | ||
@@ -18,3 +18,3 @@ resolve(`export default ${raw(markdown.body)}`); | ||
codeFiles.forEach((c, i) => { | ||
const codeFilePath = path.resolve(this.context, c); | ||
var codeFilePath = path.resolve(this.context, c); | ||
doImports += `import mod_${i} from '${codeFilePath}';\n`; | ||
@@ -39,9 +39,9 @@ mods.push(`mod_${i}`); | ||
export const attributes = ${JSON.stringify(camelize(markdown.attributes))}; | ||
export const modules = [${mods}]; | ||
export const codes = [${[...arg]}]; | ||
export var attributes = ${JSON.stringify(camelize(markdown.attributes))}; | ||
export var modules = [${mods}]; | ||
export var codes = [${[...arg]}]; | ||
export default { | ||
attributes, | ||
modules, | ||
codes, | ||
attributes: attributes, | ||
modules: modules, | ||
codes: codes, | ||
}; | ||
@@ -59,5 +59,5 @@ ` | ||
function parseCode(markdown) { | ||
const body = markdown.body; | ||
const codes = body.match(/```jsx(\r|\n)+\s*import\s+((\'.+\')|(\".+\"));?\s*(\r|\n)+```(\r|\n)*/g) || []; | ||
const codeFiles = codes.map(c => | ||
var body = markdown.body; | ||
var codes = body.match(/```jsx(\r|\n)+\s*import\s+((\'.+\')|(\".+\"));?\s*(\r|\n)+```(\r|\n)*/g) || []; | ||
var codeFiles = codes.map(c => | ||
c.replace(/(```jsx(\r|\n)+\s*import\s+(\'|\"))|((\'|\");?\s*(\r|\n)+)|(```(\r|\n)*)/g, '') | ||
@@ -83,3 +83,3 @@ ); | ||
module.exports = function (source) { | ||
const callback = this.async(); | ||
var callback = this.async(); | ||
@@ -86,0 +86,0 @@ parse.call(this, source).then(m => { |
{ | ||
"name": "demo-md-loader", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Webpack loader that parses markdown files and converts them to a useful javascript object.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,6 @@ | ||
# demo-markdown-loader | ||
# demo-md-loader | ||
Webpack loader that parses markdown files and converts them to a useful javascript object. | ||
``` | ||
$ yarn add demo-md-loader | ||
``` |
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
4018
6