mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-18 18:33:42 +00:00
Destructuring assignment
This commit is contained in:
parent
a96d1126a9
commit
102160c25f
@ -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}) }}
|
||||
|
||||
@ -17,3 +17,5 @@
|
||||
lang : '{{ page.lang }}'
|
||||
};
|
||||
</script>
|
||||
|
||||
{{- next_inject('head') }}
|
||||
|
||||
@ -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.');
|
||||
|
||||
@ -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!');
|
||||
|
||||
|
||||
@ -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 '';
|
||||
|
||||
@ -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>');
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user