diff --git a/layout/_layout.njk b/layout/_layout.njk index 87649d0..56dcde1 100644 --- a/layout/_layout.njk +++ b/layout/_layout.njk @@ -3,7 +3,6 @@ {{ partial('_partials/head/head.njk', {}, {cache: theme.cache.enable}) }} {% include '_partials/head/head-unique.njk' %} - {{- next_inject('head') }} {% block title %}{% endblock %} {{ partial('_third-party/analytics/index.njk', {}, {cache: theme.cache.enable}) }} {{ partial('_scripts/noscript.njk', {}, {cache: theme.cache.enable}) }} diff --git a/layout/_partials/head/head-unique.njk b/layout/_partials/head/head-unique.njk index 5424909..f9bcfe2 100644 --- a/layout/_partials/head/head-unique.njk +++ b/layout/_partials/head/head-unique.njk @@ -17,3 +17,5 @@ lang : '{{ page.lang }}' }; + +{{- next_inject('head') }} diff --git a/scripts/tags/caniuse.js b/scripts/tags/caniuse.js index ec0e549..a6b0454 100644 --- a/scripts/tags/caniuse.js +++ b/scripts/tags/caniuse.js @@ -5,9 +5,7 @@ 'use strict'; module.exports = ctx => function(args) { - args = args.join('').split('@'); - const feature = args[0]; - const periods = args[1] || 'current'; + const [feature, periods = 'current'] = args.join('').split('@'); if (!feature) { ctx.log.warn('Caniuse feature can NOT be empty.'); diff --git a/scripts/tags/label.js b/scripts/tags/label.js index 80f3c27..1ebfca5 100644 --- a/scripts/tags/label.js +++ b/scripts/tags/label.js @@ -5,9 +5,7 @@ 'use strict'; module.exports = ctx => function(args) { - args = args.join(' ').split('@'); - const classes = args[0] || 'default'; - const text = args[1] || ''; + const [classes = 'default', text = ''] = args.join(' ').split('@'); if (!text) ctx.log.warn('Label text must be defined!'); diff --git a/scripts/tags/link-grid.js b/scripts/tags/link-grid.js index c95421e..b0398c9 100644 --- a/scripts/tags/link-grid.js +++ b/scripts/tags/link-grid.js @@ -4,11 +4,7 @@ 'use strict'; -module.exports = function(args, content) { - const image = args[0] || '/images/avatar.gif'; - const delimiter = args[1] || '|'; - const comment = args[2] || '%'; - +module.exports = function([image = '/images/avatar.gif', delimiter = '|', comment = '%'], content) { const links = content.split('\n').filter(line => line.trim() !== '').map(line => { const item = line.split(delimiter).map(arg => arg.trim()); if (item[0][0] === comment) return ''; diff --git a/test/tags/label.js b/test/tags/label.js index bf3c011..bf27108 100644 --- a/test/tags/label.js +++ b/test/tags/label.js @@ -8,10 +8,14 @@ describe('label', () => { const postLabel = require('../../scripts/tags/label')(hexo); it('only text', () => { - postLabel('@Hello world'.split(' ')).should.eql('Hello world'); + postLabel('@Hello world'.split(' ')).should.eql('Hello world'); }); it('classes and text', () => { postLabel('primary@Hello world'.split(' ')).should.eql('Hello world'); }); + + it('classes and text with space', () => { + postLabel('primary @Hello world'.split(' ')).should.eql('Hello world'); + }); });