From 3bc0a942813934d84fe9597ebf65428b20ba67b0 Mon Sep 17 00:00:00 2001 From: ppoffice <ppoffice@users.noreply.github.com> Date: Sat, 20 Aug 2022 16:12:59 -0400 Subject: [PATCH] chore: update hexo-component-inferno and migration script --- include/migration/head.js | 2 +- include/migration/v5_v5.1.js | 29 +++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 include/migration/v5_v5.1.js diff --git a/include/migration/head.js b/include/migration/head.js index db0c11f..7aeb7b1 100644 --- a/include/migration/head.js +++ b/include/migration/head.js @@ -1 +1 @@ -module.exports = require('./v4_v5'); +module.exports = require('./v5_v5.1'); diff --git a/include/migration/v5_v5.1.js b/include/migration/v5_v5.1.js new file mode 100644 index 0000000..ca0f667 --- /dev/null +++ b/include/migration/v5_v5.1.js @@ -0,0 +1,29 @@ +const Migration = require('hexo-component-inferno/lib/core/migrate').Migration; + +module.exports = class extends Migration { + constructor() { + super('5.1.0', null); + } + + upgrade(config) { + // Upgrade Waline configurations from v1 to v2. + const comment = config.comment || {}; + const renamedOptions = { + 'visitor': 'pageview', + 'uploadImage': 'image_uploader', + 'highlight': 'highlighter', + 'math': 'tex_renderer' + }; + if (comment.type === 'waline') { + for (const option in renamedOptions) { + if (typeof comment[option] !== 'undefined') { + if (typeof comment[renamedOptions[option]] === 'undefined') { + comment[renamedOptions[option]] = comment[option]; + } + delete comment[option]; + } + } + } + return config; + } +}; diff --git a/package.json b/package.json index 2905905..6a81785 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "bulma-stylus": "0.8.0", "deepmerge": "^4.2.2", "hexo": "^6.0.0", - "hexo-component-inferno": "^1.2.0", + "hexo-component-inferno": "^2.0.0", "hexo-log": "^3.0.0", "hexo-pagination": "^2.0.0", "hexo-renderer-inferno": "^0.1.3",