feat(*): support for Hexo 5.0

This commit is contained in:
ppoffice 2020-08-14 12:14:46 -04:00
parent 1db27e6a33
commit f046c8cd19
No known key found for this signature in database
GPG Key ID: 465EB43C9286CCB4
5 changed files with 9 additions and 76 deletions

View File

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

View File

@ -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 <head>
<meta charset="utf-8" />
{meta_generator ? <meta name="generator" content={`Hexo ${env.version}`} /> : null}
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
{meta && meta.length ? <MetaTags meta={meta} /> : null}

View File

@ -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 <html lang={language ? language.substr(0, 2) : ''}>
<Head env={env} site={site} config={config} helper={helper} page={page} />
<Head site={site} config={config} helper={helper} page={page} />
<body class={`is-${columnCount}-column`}>
<Navbar config={config} helper={helper} page={page} />
<section class="section">

View File

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

View File

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