From 49d96ee195e94d03aee48848f9436ec9e1c5cb74 Mon Sep 17 00:00:00 2001 From: Elmore Cheng <9206414+ikeq@users.noreply.github.com> Date: Thu, 3 Oct 2019 17:32:37 +0800 Subject: [PATCH] detail improvements (#148) --- layout/index.ejs | 2 +- lib/config.js | 19 ++++++++++++++----- lib/configSchema.json | 2 +- lib/filter/post.js | 4 ++++ lib/utils.js | 18 +++++++++++------- package.json | 6 +++--- source/_resources.json | 2 +- source/main.1efb2acb62d508679d87.zh-Hans.js | 1 - source/main.5509fae49a8263eb6b15.zh-Hant.js | 1 - source/main.5ac6b548dbff945e028b.zh-Hant.js | 1 + source/main.77374c447781af9644db.ja.js | 1 - source/main.7773219322474154c9eb.zh-Hans.js | 1 + source/main.a6ef31dc523c76e5118c.js | 1 + source/main.c145738ea9113b8ce68e.ja.js | 1 + source/main.e456207a2fb3a1560aeb.js | 1 - ...00.css => styles.d1f4718a192abf1f2afd.css} | 6 +++--- 16 files changed, 42 insertions(+), 25 deletions(-) delete mode 100644 source/main.1efb2acb62d508679d87.zh-Hans.js delete mode 100644 source/main.5509fae49a8263eb6b15.zh-Hant.js create mode 100644 source/main.5ac6b548dbff945e028b.zh-Hant.js delete mode 100644 source/main.77374c447781af9644db.ja.js create mode 100644 source/main.7773219322474154c9eb.zh-Hans.js create mode 100644 source/main.a6ef31dc523c76e5118c.js create mode 100644 source/main.c145738ea9113b8ce68e.ja.js delete mode 100644 source/main.e456207a2fb3a1560aeb.js rename source/{styles.e987407a0a9d77c7ba00.css => styles.d1f4718a192abf1f2afd.css} (91%) diff --git a/layout/index.ejs b/layout/index.ejs index ae96093..b397771 100644 --- a/layout/index.ejs +++ b/layout/index.ejs @@ -24,7 +24,7 @@ <% if (theme.ga) { %><%- ga(theme.ga) %><% } -%> -<%- `<${theme.runtime.rootSelector}>` %> +<%- `<${theme.runtime.selector}>` %> <%- theme.scripts %> diff --git a/lib/config.js b/lib/config.js index 3a92d88..03b6fb6 100644 --- a/lib/config.js +++ b/lib/config.js @@ -7,7 +7,6 @@ const utils = require('./utils'); const pkg = require('../package.json'); const configSchema = require('./configSchema.json'); const resources = require('../source/_resources.json'); -const external_regex = /^(\w+:)?\/\/\w+\.\w+/; module.exports = function (hexo) { hexo.on('generateBefore', function () { @@ -24,7 +23,7 @@ module.exports = function (hexo) { $description: site.description }); const urlFn = result.static_prefix ? - a => external_regex.test(a) ? a : `${result.static_prefix}/${a}` : + a => utils.isExternal(a) ? a : `${result.static_prefix}/${a}` : urlFor.bind(this); // override default language @@ -41,6 +40,16 @@ module.exports = function (hexo) { delete disqus.shortname; } + // convert menu to array + if (result.menu) { + result.menu = Object.keys(result.menu).map(k => { + const item = [k, result.menu[k]]; + if (utils.isExternal(item[1])) item.push(1); + return item; + }) + } + + // sns if (result.sns) { const sns = []; if (result.sns.email !== undefined) result.sns.email = 'mailto:' + (result.sns.email || email); @@ -115,12 +124,12 @@ module.exports = function (hexo) { } // override boolean value to html string - if (result.footer.powered) result.footer.powered = __('footer.powered', 'Hexo') - if (result.footer.theme) result.footer.theme = __('footer.theme') + ' - Inside' + if (result.footer.powered) result.footer.powered = __('footer.powered', 'Hexo') + if (result.footer.theme) result.footer.theme = __('footer.theme') + ' - Inside' result.runtime = { // root selector - rootSelector: resources.root, + selector: resources.root, hash: utils.md5([ ...hexo.locals.getters.pages().sort('-date').toArray(), ...hexo.locals.getters.posts().sort('-date').toArray() diff --git a/lib/configSchema.json b/lib/configSchema.json index 3a42b16..247bca6 100644 --- a/lib/configSchema.json +++ b/lib/configSchema.json @@ -151,7 +151,7 @@ "license": { "type": "string", "contentMediaType": "text/html" , - "default": "Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)" + "default": "Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)" }, "published": { "type": "boolean" }, "updated": { "type": "boolean" }, diff --git a/lib/filter/post.js b/lib/filter/post.js index 3b7e607..067d28f 100644 --- a/lib/filter/post.js +++ b/lib/filter/post.js @@ -136,6 +136,10 @@ module.exports = function (data) { // optimize code block $('.highlight') + // remove unused language class + .each(function () { + $(this).attr('class', 'highlight') + }) .children('table').wrap('
'); // wrap