Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update hexo-front-matter from 1.0.0 to 2.0.0 #4439

Merged
merged 1 commit into from Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 9 additions & 10 deletions lib/hexo/post.js
Expand Up @@ -8,8 +8,7 @@ const { magenta } = require('chalk');
const { load } = require('js-yaml');
const { slugize, escapeRegExp } = require('hexo-util');
const { copyDir, exists, listDir, mkdirs, readFile, rmdir, unlink, writeFile } = require('hexo-fs');
const yfm = require('hexo-front-matter');

const { parse: yfmParse, split: yfmSplit, stringify: yfmStringify } = require('hexo-front-matter');
const preservedKeys = ['title', 'slug', 'path', 'layout', 'date', 'content'];

const rPlaceholder = /(?:<|&lt;)!--\uFFFC(\d+)--(?:>|&gt;)/g;
Expand Down Expand Up @@ -128,15 +127,15 @@ class Post {

_renderScaffold(data) {
const { tag } = this.context.extend;
let yfmSplit;
let splited;

return this._getScaffold(data.layout).then(scaffold => {
const frontMatter = prepareFrontMatter({ ...data });
yfmSplit = yfm.split(scaffold);
splited = yfmSplit(scaffold);

return tag.render(yfmSplit.data, frontMatter);
return tag.render(splited.data, frontMatter);
}).then(frontMatter => {
const { separator } = yfmSplit;
const { separator } = splited;
const jsonMode = separator.startsWith(';');

// Parse front-matter
Expand All @@ -151,14 +150,14 @@ class Post {

let content = '';
// Prepend the separator
if (yfmSplit.prefixSeparator) content += `${separator}\n`;
if (splited.prefixSeparator) content += `${separator}\n`;

content += yfm.stringify(obj, {
content += yfmStringify(obj, {
mode: jsonMode ? 'json' : ''
});

// Concat content
content += yfmSplit.content;
content += splited.content;

if (data.content) {
content += `\n${data.content}`;
Expand Down Expand Up @@ -197,7 +196,7 @@ class Post {
return readFile(src);
}).then(content => {
// Create post
Object.assign(data, yfm(content));
Object.assign(data, yfmParse(content));
data.content = data._content;
delete data._content;

Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/processor/asset.js
Expand Up @@ -2,7 +2,7 @@

const { timezone, toDate, isExcludedFile, isMatch } = require('./common');
const Promise = require('bluebird');
const yfm = require('hexo-front-matter');
const { parse: yfm } = require('hexo-front-matter');
const { extname, relative } = require('path');
const { Pattern } = require('hexo-util');

Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/processor/post.js
Expand Up @@ -2,7 +2,7 @@

const { toDate, timezone, isExcludedFile, isTmpFile, isHiddenFile, isMatch } = require('./common');
const Promise = require('bluebird');
const yfm = require('hexo-front-matter');
const { parse: yfm } = require('hexo-front-matter');
const { extname, join } = require('path');
const { stat, listDir } = require('hexo-fs');
const { slugize, Pattern, Permalink } = require('hexo-util');
Expand Down
2 changes: 1 addition & 1 deletion lib/theme/view.js
@@ -1,7 +1,7 @@
'use strict';

const { dirname, extname, join } = require('path');
const yfm = require('hexo-front-matter');
const { parse: yfm } = require('hexo-front-matter');
const Promise = require('bluebird');

const assignIn = (target, ...sources) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -44,7 +44,7 @@
"bluebird": "^3.5.2",
"chalk": "^4.0.0",
"hexo-cli": "^3.0.0",
"hexo-front-matter": "^1.0.0",
"hexo-front-matter": "^2.0.0",
"hexo-fs": "^3.1.0",
"hexo-i18n": "^1.0.0",
"hexo-log": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions test/scripts/hexo/post.js
Expand Up @@ -6,7 +6,7 @@ const Promise = require('bluebird');
const { readFile, mkdirs, unlink, rmdir, writeFile, exists, stat, listDir } = require('hexo-fs');
const { highlight, escapeHTML } = require('hexo-util');
const { spy, useFakeTimers } = require('sinon');
const frontMatter = require('hexo-front-matter');
const { parse: yfm } = require('hexo-front-matter');
const fixture = require('../../fixtures/post_render');
const escapeSwigTag = str => str.replace(/{/g, '&#123;').replace(/}/g, '&#125;');

Expand Down Expand Up @@ -573,7 +573,7 @@ describe('Post', () => {
}).then(data => post.publish({
slug: 'foo'
})).then(data => {
const meta = frontMatter(data.content);
const meta = yfm(data.content);
meta.tags.should.eql(['tag', 'test']);
return unlink(data.path);
}));
Expand Down