chore: migrate to hexo-component-inferno 0.1.1

This commit is contained in:
ppoffice 2020-03-08 13:09:48 -04:00
parent 8d7624fc69
commit 43898dd3d4
13 changed files with 26 additions and 14 deletions

View File

@ -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));
}

View File

@ -28,6 +28,9 @@
{
"$ref": "/comment/livere.json"
},
{
"$ref": "/comment/utterances.json"
},
{
"$ref": "/comment/valine.json"
}

View File

@ -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"

View File

@ -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() {

View File

@ -5,6 +5,6 @@ module.exports = class extends Component {
render() {
const { site, page, helper } = this.props;
return <Categories site={site} page={page} helper={helper} />;
return <Categories.Cacheable site={site} page={page} helper={helper} />;
}
};

View File

@ -16,7 +16,8 @@ module.exports = class extends Component {
<h3 class="title is-5">{__('article.comments')}</h3>
{(() => {
try {
const Comment = view.require('comment/' + comment.type);
let Comment = view.require('comment/' + comment.type);
Comment = Comment.Cacheable ? Comment.Cacheable : Comment;
return <Comment config={config} page={page} helper={helper} comment={comment} />;
} catch (e) {
logger.w(`Icarus cannot load comment "${comment.type}"`);

View File

@ -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 <Donate helper={helper} donate={service} />;
} catch (e) {
logger.w(`Icarus cannot load donate button "${type}"`);

View File

@ -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 <Plugin site={site} config={config} page={page} helper={helper} plugin={plugins[name]} head={head} />;
} catch (e) {
logger.w(`Icarus cannot load plugin "${name}"`);

View File

@ -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 <Search config={config} helper={helper} search={search} />;
} catch (e) {
logger.w(`Icarus cannot load search "${search.type}"`);

View File

@ -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 <Share config={config} page={page} helper={helper} share={share} />;
} catch (e) {
logger.w(`Icarus cannot load share button "${share.type}"`);

View File

@ -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 <Widget site={site} helper={helper} config={config} page={page} widget={widget} />;
} catch (e) {
logger.w(`Icarus cannot load widget "${widget.type}"`);

View File

@ -5,6 +5,6 @@ module.exports = class extends Component {
render() {
const { site, helper } = this.props;
return <Tags site={site} helper={helper} />;
return <Tags.Cacheable site={site} helper={helper} />;
}
};

View File

@ -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",