From 43898dd3d439972c6772b8b8aaf9fa914482ca23 Mon Sep 17 00:00:00 2001 From: ppoffice Date: Sun, 8 Mar 2020 13:09:48 -0400 Subject: [PATCH] chore: migrate to hexo-component-inferno 0.1.1 --- include/config.js | 6 ++++-- include/schema/common/comment.json | 3 +++ include/schema/common/donates.json | 3 ++- layout/archive.jsx | 2 +- layout/categories.jsx | 2 +- layout/common/comment.jsx | 3 ++- layout/common/donates.jsx | 3 ++- layout/common/plugins.jsx | 3 ++- layout/common/search.jsx | 3 ++- layout/common/share.jsx | 3 ++- layout/common/widgets.jsx | 3 ++- layout/tags.jsx | 2 +- package.json | 4 ++-- 13 files changed, 26 insertions(+), 14 deletions(-) diff --git a/include/config.js b/include/config.js index f154fce..5ac6220 100644 --- a/include/config.js +++ b/include/config.js @@ -4,6 +4,7 @@ const path = require('path'); const util = require('util'); const crypto = require('crypto'); const logger = require('hexo-log')(); +const { Migrator } = require('hexo-component-inferno/lib/core/migrate'); module.exports = hexo => { if (!process.argv.includes('--icarus-dont-check-config')) { @@ -32,7 +33,8 @@ module.exports = hexo => { let cfg = yaml.parse(cfgStr); // Check config version if (!process.argv.includes('--icarus-dont-upgrade-config')) { - const migrator = new(require('hexo-component-inferno/lib/core/migrate'))(path.join(hexo.theme_dir, 'include/migration')); + const head = require(path.join(hexo.theme_dir, 'include/migration/head')); + const migrator = new Migrator(head); // Upgrade config if (migrator.isOudated(cfg.version)) { logger.info(`Your configuration file is outdated (${cfg.version} < ${migrator.getLatestVersion()}). ` @@ -57,7 +59,7 @@ module.exports = hexo => { const result = schema.validate(cfg); if (result !== true) { logger.warn('Configuration file failed one or more checks.'); - logger.warn('Icarus may still run, but you will encounter excepted results.'); + logger.warn('Icarus may still run, but you will encounter unexcepted results.'); logger.warn('Here is some information for you to correct the configuration file.'); logger.warn(util.inspect(result)); } diff --git a/include/schema/common/comment.json b/include/schema/common/comment.json index 5a68c06..a5e8cbd 100644 --- a/include/schema/common/comment.json +++ b/include/schema/common/comment.json @@ -28,6 +28,9 @@ { "$ref": "/comment/livere.json" }, + { + "$ref": "/comment/utterances.json" + }, { "$ref": "/comment/valine.json" } diff --git a/include/schema/common/donates.json b/include/schema/common/donates.json index 9ee9c2a..ff5ca05 100644 --- a/include/schema/common/donates.json +++ b/include/schema/common/donates.json @@ -1,9 +1,10 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "/common/donates.json", - "description": "Donate plugin configurations", + "description": "Donate plugin configurations\nhttps://blog.zhangruipeng.me/hexo-theme-icarus/categories/Plugins/Donation/", "type": "array", "items": { + "type": "object", "oneOf": [ { "$ref": "/donate/alipay.json" diff --git a/layout/archive.jsx b/layout/archive.jsx index 7516755..e03f463 100644 --- a/layout/archive.jsx +++ b/layout/archive.jsx @@ -1,7 +1,7 @@ const moment = require('moment'); const { Component, Fragment } = require('inferno'); const Paginator = require('hexo-component-inferno/lib/view/misc/paginator'); -const ArticleMedia = require('hexo-component-inferno/lib/view/common/article-media'); +const ArticleMedia = require('hexo-component-inferno/lib/view/common/article_media'); module.exports = class extends Component { render() { diff --git a/layout/categories.jsx b/layout/categories.jsx index 2efa9cb..7c1ceb1 100644 --- a/layout/categories.jsx +++ b/layout/categories.jsx @@ -5,6 +5,6 @@ module.exports = class extends Component { render() { const { site, page, helper } = this.props; - return ; + return ; } }; diff --git a/layout/common/comment.jsx b/layout/common/comment.jsx index 93e3938..cb9d6e0 100644 --- a/layout/common/comment.jsx +++ b/layout/common/comment.jsx @@ -16,7 +16,8 @@ module.exports = class extends Component {

{__('article.comments')}

{(() => { try { - const Comment = view.require('comment/' + comment.type); + let Comment = view.require('comment/' + comment.type); + Comment = Comment.Cacheable ? Comment.Cacheable : Comment; return ; } catch (e) { logger.w(`Icarus cannot load comment "${comment.type}"`); diff --git a/layout/common/donates.jsx b/layout/common/donates.jsx index abf98b6..bafe9d4 100644 --- a/layout/common/donates.jsx +++ b/layout/common/donates.jsx @@ -18,7 +18,8 @@ module.exports = class extends Component { const type = service.type; if (typeof type === 'string') { try { - const Donate = view.require('donate/' + type); + let Donate = view.require('donate/' + type); + Donate = Donate.Cacheable ? Donate.Cacheable : Donate; return ; } catch (e) { logger.w(`Icarus cannot load donate button "${type}"`); diff --git a/layout/common/plugins.jsx b/layout/common/plugins.jsx index a1a9920..35a2942 100644 --- a/layout/common/plugins.jsx +++ b/layout/common/plugins.jsx @@ -14,7 +14,8 @@ module.exports = class extends Component { return null; } try { - const Plugin = view.require('plugin/' + name); + let Plugin = view.require('plugin/' + name); + Plugin = Plugin.Cacheable ? Plugin.Cacheable : Plugin; return ; } catch (e) { logger.w(`Icarus cannot load plugin "${name}"`); diff --git a/layout/common/search.jsx b/layout/common/search.jsx index cb8134d..015a9bb 100644 --- a/layout/common/search.jsx +++ b/layout/common/search.jsx @@ -11,7 +11,8 @@ module.exports = class extends Component { } try { - const Search = view.require('search/' + search.type); + let Search = view.require('search/' + search.type); + Search = Search.Cacheable ? Search.Cacheable : Search; return ; } catch (e) { logger.w(`Icarus cannot load search "${search.type}"`); diff --git a/layout/common/share.jsx b/layout/common/share.jsx index 84efdf4..e2206bb 100644 --- a/layout/common/share.jsx +++ b/layout/common/share.jsx @@ -11,7 +11,8 @@ module.exports = class extends Component { } try { - const Share = view.require('share/' + share.type); + let Share = view.require('share/' + share.type); + Share = Share.Cacheable ? Share.Cacheable : Share; return ; } catch (e) { logger.w(`Icarus cannot load share button "${share.type}"`); diff --git a/layout/common/widgets.jsx b/layout/common/widgets.jsx index 2616f7f..0a69ca7 100644 --- a/layout/common/widgets.jsx +++ b/layout/common/widgets.jsx @@ -81,7 +81,8 @@ class Widgets extends Component { return null; } try { - const Widget = view.require('widget/' + widget.type); + let Widget = view.require('widget/' + widget.type); + Widget = Widget.Cacheable ? Widget.Cacheable : Widget; return ; } catch (e) { logger.w(`Icarus cannot load widget "${widget.type}"`); diff --git a/layout/tags.jsx b/layout/tags.jsx index 65cb070..e8c5a38 100644 --- a/layout/tags.jsx +++ b/layout/tags.jsx @@ -5,6 +5,6 @@ module.exports = class extends Component { render() { const { site, helper } = this.props; - return ; + return ; } }; diff --git a/package.json b/package.json index f7c6458..39e6451 100644 --- a/package.json +++ b/package.json @@ -23,10 +23,10 @@ "bulma-stylus": "0.8.0", "deepmerge": "^4.2.2", "hexo": "^4.2.0", - "hexo-component-inferno": "^0.0.2", + "hexo-component-inferno": "^0.1.1", "hexo-log": "^1.0.0", "hexo-pagination": "^1.0.0", - "hexo-renderer-inferno": "^0.1.1", + "hexo-renderer-inferno": "^0.1.3", "hexo-renderer-stylus": "^1.1.0", "hexo-util": "^1.8.0", "inferno": "^7.3.3",