Skip to content

Commit 81d0b24

Browse files
Fix js-yaml tags for v4.0.0+ (#4869) (#4876)
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` Co-authored-by: Marco Franssen <[email protected]>
1 parent b65a562 commit 81d0b24

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/plugins/renderer/yaml.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
const yaml = require('js-yaml');
44
const { escape } = require('hexo-front-matter');
5+
const schema = yaml.DEFAULT_SCHEMA.extend(require('js-yaml-js-types').all);
56

67
function yamlHelper(data) {
7-
return yaml.load(escape(data.text));
8+
return yaml.load(escape(data.text), { schema });
89
}
910

1011
module.exports = yamlHelper;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"hexo-log": "^2.0.0",
5151
"hexo-util": "^2.4.0",
5252
"js-yaml": "^4.0.0",
53+
"js-yaml-js-types": "^1.0.0",
5354
"micromatch": "^4.0.2",
5455
"moment": "^2.22.2",
5556
"moment-timezone": "^0.5.21",

0 commit comments

Comments
 (0)