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