From f046c8cd19efab5bc140628639b6ee8a65f2aad1 Mon Sep 17 00:00:00 2001
From: ppoffice
Date: Fri, 14 Aug 2020 12:14:46 -0400
Subject: [PATCH] feat(*): support for Hexo 5.0
---
include/register.js | 14 ------------
layout/common/head.jsx | 4 +---
layout/layout.jsx | 4 ++--
package.json | 12 +++++-----
source/js/main.js | 51 ------------------------------------------
5 files changed, 9 insertions(+), 76 deletions(-)
diff --git a/include/register.js b/include/register.js
index 8847e81..1ea452f 100644
--- a/include/register.js
+++ b/include/register.js
@@ -12,18 +12,4 @@ module.exports = hexo => {
require('hexo-component-inferno/lib/hexo/helper/page')(hexo);
require('hexo-component-inferno/lib/hexo/helper/thumbnail')(hexo);
require('hexo-component-inferno/lib/core/view').init(hexo);
-
- const hooks = [
- 'after_render:html',
- 'after_post_render'
- ];
- const filters = [
- 'hexoMetaGeneratorInject',
- 'externalLinkFilter'
- ];
- hooks.forEach(hook => {
- hexo.extend.filter.list()[hook]
- .filter(filter => filters.includes(filter.name))
- .forEach(filter => hexo.extend.filter.unregister(hook, filter));
- });
};
diff --git a/layout/common/head.jsx b/layout/common/head.jsx
index 0b950c9..d099b1e 100644
--- a/layout/common/head.jsx
+++ b/layout/common/head.jsx
@@ -29,11 +29,10 @@ function getPageTitle(page, siteTitle, helper) {
module.exports = class extends Component {
render() {
- const { env, site, config, helper, page } = this.props;
+ const { site, config, helper, page } = this.props;
const { url_for, cdn, fontcdn, iconcdn, is_post } = helper;
const {
url,
- meta_generator = true,
head = {},
article,
highlight,
@@ -106,7 +105,6 @@ module.exports = class extends Component {
return
- {meta_generator ? : null}
{meta && meta.length ? : null}
diff --git a/layout/layout.jsx b/layout/layout.jsx
index 4337007..8607b5d 100644
--- a/layout/layout.jsx
+++ b/layout/layout.jsx
@@ -9,13 +9,13 @@ const Search = require('./common/search');
module.exports = class extends Component {
render() {
- const { env, site, config, page, helper, body } = this.props;
+ const { site, config, page, helper, body } = this.props;
const language = page.lang || page.language || config.language;
const columnCount = Widgets.getColumnCount(config.widgets);
return
-
+
diff --git a/package.json b/package.json
index 56d1156..1312c3a 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,7 @@
"lint": "eslint --ext .js --ext .jsx --ext .json ."
},
"devDependencies": {
- "eslint": "^6.8.0",
+ "eslint": "^7.6.0",
"eslint-config-hexo": "^4.1.0",
"eslint-plugin-json": "^2.0.1",
"eslint-plugin-react": "^7.17.0"
@@ -21,16 +21,16 @@
"peerDependencies": {
"bulma-stylus": "0.8.0",
"deepmerge": "^4.2.2",
- "hexo": "^4.2.0",
- "hexo-component-inferno": "^0.4.0",
- "hexo-log": "^1.0.0",
+ "hexo": "^5.0.2",
+ "hexo-component-inferno": "^0.5.0",
+ "hexo-log": "^2.0.0",
"hexo-pagination": "^1.0.0",
"hexo-renderer-inferno": "^0.1.3",
"hexo-renderer-stylus": "^1.1.0",
- "hexo-util": "^1.8.0",
+ "hexo-util": "^2.3.0",
"inferno": "^7.3.3",
"inferno-create-element": "^7.3.3",
"moment": "^2.22.2",
"semver": ">=5.0.0"
}
-}
\ No newline at end of file
+}
diff --git a/source/js/main.js b/source/js/main.js
index 4f5a9ae..3efa91f 100644
--- a/source/js/main.js
+++ b/source/js/main.js
@@ -138,55 +138,4 @@
$mask.on('click', toggleToc);
$('.navbar-main .catalogue').on('click', toggleToc);
}
-
- // hexo-util/lib/is_external_link.js
- function isExternalLink(input, sitehost, exclude) {
- try {
- sitehost = new URL(sitehost).hostname;
- } catch (e) { }
-
- if (!sitehost) return false;
-
- // handle relative url
- let data;
- try {
- data = new URL(input, 'http://' + sitehost);
- } catch (e) { return false; }
-
- // handle mailto: javascript: vbscript: and so on
- if (data.origin === 'null') return false;
-
- const host = data.hostname;
-
- if (exclude) {
- exclude = Array.isArray(exclude) ? exclude : [exclude];
-
- if (exclude && exclude.length) {
- for (const i of exclude) {
- if (host === i) return false;
- }
- }
- }
-
- if (host !== sitehost) return true;
-
- return false;
- }
-
- if (typeof config !== 'undefined'
- && typeof config.site.url !== 'undefined'
- && typeof config.site.external_link !== 'undefined'
- && config.site.external_link.enable) {
- $('.article .content a').filter((i, link) => {
- return link.href
- && !$(link).attr('href').startsWith('#')
- && link.classList.length === 0
- && isExternalLink(link.href,
- config.site.url,
- config.site.external_link.exclude);
- }).each((i, link) => {
- link.relList.add('noopener');
- link.target = '_blank';
- });
- }
}(jQuery, window.moment, window.ClipboardJS, window.IcarusThemeSettings));