Skip to content

Commit

Permalink
Fix js-yaml tags for v4.0.0+
Browse files Browse the repository at this point in the history
Repair backwards compatibility https://github.com/nodeca/js-yaml/blob/master/migrate_v3_to_v4.md
with a bunch of plugins that use these yaml tags.

e.g.: https://github.com/lavas-project/hexo-pwa#options uses these yaml tags in the routes `!!js/regexp`
  • Loading branch information
marcofranssen committed Jan 14, 2022
1 parent 4c4bd22 commit 7808bec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/plugins/renderer/yaml.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict';
"use strict";

const yaml = require('js-yaml');
const { escape } = require('hexo-front-matter');
const yaml = require("js-yaml");
const { escape } = require("hexo-front-matter");
const schema = yaml.DEFAULT_SCHEMA.extend(require("js-yaml-js-types").all);

function yamlHelper(data) {
return yaml.load(escape(data.text));
return yaml.load(escape(data.text), { schema });
}

module.exports = yamlHelper;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"hexo-log": "^3.0.0",
"hexo-util": "^2.4.0",
"js-yaml": "^4.0.0",
"js-yaml-js-types": "^1.0.0",
"micromatch": "^4.0.2",
"moize": "^6.1.0",
"moment": "^2.22.2",
Expand Down

0 comments on commit 7808bec

Please sign in to comment.