@tryghost/mg-jekyll-export 0.13.6 → 0.13.8-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/process-post.js +22 -2
- package/package.json +8 -8
package/lib/process-post.js
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
import MarkdownIt from 'markdown-it';
|
|
2
2
|
import string from '@tryghost/string';
|
|
3
3
|
import errors from '@tryghost/errors';
|
|
4
|
-
import
|
|
4
|
+
import {load, YAML11_SCHEMA} from 'js-yaml';
|
|
5
5
|
import processHtml from './process-html.js';
|
|
6
6
|
|
|
7
7
|
const md = new MarkdownIt({
|
|
8
8
|
html: true
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
+
const frontMatterPattern = /^\uFEFF?(---|= yaml =)\r?\n([\s\S]*?)\r?\n(?:\1|\.\.\.)[ \t]*(?:\r?\n|$)/;
|
|
12
|
+
|
|
13
|
+
function parseFrontMatter(contents) {
|
|
14
|
+
const match = contents.match(frontMatterPattern);
|
|
15
|
+
|
|
16
|
+
if (!match) {
|
|
17
|
+
return {
|
|
18
|
+
attributes: {},
|
|
19
|
+
body: contents
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const yaml = match[2].trim();
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
attributes: yaml ? load(yaml, {schema: YAML11_SCHEMA}) : {},
|
|
27
|
+
body: contents.slice(match[0].length)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
11
31
|
// The frontmatter date may be a Date object or a string
|
|
12
32
|
function _parseFrontMatterDate(fmDate) {
|
|
13
33
|
let postDate;
|
|
@@ -34,7 +54,7 @@ The body may be in Markdown or HTML.
|
|
|
34
54
|
const processMeta = (fileName, fileContents, options) => {
|
|
35
55
|
const inDraftsDir = fileName.startsWith('_drafts/');
|
|
36
56
|
|
|
37
|
-
let frontmatter =
|
|
57
|
+
let frontmatter = parseFrontMatter(fileContents);
|
|
38
58
|
let frontmatterAttributes = frontmatter.attributes;
|
|
39
59
|
|
|
40
60
|
let postDate = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-jekyll-export",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.8-0",
|
|
4
4
|
"description": "tbc",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@tryghost/errors": "3.
|
|
24
|
-
"@tryghost/
|
|
25
|
-
"@tryghost/
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
23
|
+
"@tryghost/errors": "3.4.2",
|
|
24
|
+
"@tryghost/mg-fs-utils": "0.26.8-0",
|
|
25
|
+
"@tryghost/mg-utils": "0.11.8-0",
|
|
26
|
+
"@tryghost/pretty-cli": "3.3.16",
|
|
27
|
+
"@tryghost/string": "0.3.7",
|
|
28
|
+
"js-yaml": "5.5.0",
|
|
29
|
+
"markdown-it": "15.0.3"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"dev": "echo \"Implement me!\"",
|