+18
-5
@@ -5,3 +5,2 @@ import fs from 'fs'; | ||
| import {compile} from 'yeahjs'; | ||
| import fm from 'front-matter'; | ||
| import marked from 'marked'; | ||
@@ -107,7 +106,4 @@ import yaml from 'js-yaml'; | ||
| log(`read ${shortPath}`); | ||
| const {attributes, body} = fm(fs.readFileSync(path, 'utf8')); | ||
| const {body, attributes} = parseFrontMatter(fs.readFileSync(path, 'utf8')); | ||
| if (attributes.body !== undefined) | ||
| throw new Error('Can\'t use reserved keyword "body" as a front matter property.'); | ||
| data[name] = createCtx(rootPath, {...attributes, body: marked(body, markedOptions)}); | ||
@@ -142,1 +138,18 @@ | ||
| } | ||
| const fmOpen = '---'; | ||
| const fmClose = '\n---'; | ||
| function parseFrontMatter(str) { | ||
| if (str.indexOf(fmOpen) !== 0 || str[fmOpen.length] === fmOpen[0]) return {body: str}; | ||
| let close = str.indexOf(fmClose, fmOpen.length); | ||
| if (close < 0) close = str.length; | ||
| const attributes = yaml.load(str.slice(0, close)); | ||
| if (attributes.body !== undefined) | ||
| throw new Error('Can\'t use reserved keyword "body" as a front matter property.'); | ||
| const body = str.slice(close + fmClose.length, str.length); | ||
| return {body, attributes}; | ||
| } |
+7
-8
@@ -10,17 +10,16 @@ { | ||
| }, | ||
| "version": "0.3.0", | ||
| "version": "0.4.0", | ||
| "author": "Vladimir Agafonkin", | ||
| "license": "ISC", | ||
| "dependencies": { | ||
| "front-matter": "^4.0.2", | ||
| "js-yaml": "^4.0.0", | ||
| "marked": "^1.2.7", | ||
| "yeahjs": "^0.2.0" | ||
| "js-yaml": "^4.1.0", | ||
| "marked": "^2.1.3", | ||
| "yeahjs": "^0.3.0" | ||
| }, | ||
| "devDependencies": { | ||
| "dir-compare": "^2.4.0", | ||
| "eslint": "^7.17.0", | ||
| "dir-compare": "^3.3.0", | ||
| "eslint": "^7.29.0", | ||
| "eslint-config-mourner": "^3.0.0", | ||
| "rimraf": "^3.0.2", | ||
| "tape": "^5.1.1" | ||
| "tape": "^5.2.2" | ||
| }, | ||
@@ -27,0 +26,0 @@ "scripts": { |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
15699
2.27%3
-25%141
6.82%+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated