Destructuring assignment

This commit is contained in:
Mimi 2020-08-09 16:15:35 +08:00
parent a96d1126a9
commit 102160c25f
6 changed files with 10 additions and 13 deletions

View File

@ -3,7 +3,6 @@
<head>
{{ partial('_partials/head/head.njk', {}, {cache: theme.cache.enable}) }}
{% include '_partials/head/head-unique.njk' %}
{{- next_inject('head') }}
<title>{% block title %}{% endblock %}</title>
{{ partial('_third-party/analytics/index.njk', {}, {cache: theme.cache.enable}) }}
{{ partial('_scripts/noscript.njk', {}, {cache: theme.cache.enable}) }}

View File

@ -17,3 +17,5 @@
lang : '{{ page.lang }}'
};
</script>
{{- next_inject('head') }}

View File

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

View File

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

View File

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

View File

@ -8,10 +8,14 @@ describe('label', () => {
const postLabel = require('../../scripts/tags/label')(hexo);
it('only text', () => {
postLabel('@Hello world'.split(' ')).should.eql('<mark class="label default">Hello world</mark>');
postLabel('@Hello world'.split(' ')).should.eql('<mark class="label ">Hello world</mark>');
});
it('classes and text', () => {
postLabel('primary@Hello world'.split(' ')).should.eql('<mark class="label primary">Hello world</mark>');
});
it('classes and text with space', () => {
postLabel('primary @Hello world'.split(' ')).should.eql('<mark class="label primary">Hello world</mark>');
});
});