mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-20 19:02:33 +00:00
Destructuring assignment
This commit is contained in:
parent
a96d1126a9
commit
102160c25f
@ -3,7 +3,6 @@
|
|||||||
<head>
|
<head>
|
||||||
{{ partial('_partials/head/head.njk', {}, {cache: theme.cache.enable}) }}
|
{{ partial('_partials/head/head.njk', {}, {cache: theme.cache.enable}) }}
|
||||||
{% include '_partials/head/head-unique.njk' %}
|
{% include '_partials/head/head-unique.njk' %}
|
||||||
{{- next_inject('head') }}
|
|
||||||
<title>{% block title %}{% endblock %}</title>
|
<title>{% block title %}{% endblock %}</title>
|
||||||
{{ partial('_third-party/analytics/index.njk', {}, {cache: theme.cache.enable}) }}
|
{{ partial('_third-party/analytics/index.njk', {}, {cache: theme.cache.enable}) }}
|
||||||
{{ partial('_scripts/noscript.njk', {}, {cache: theme.cache.enable}) }}
|
{{ partial('_scripts/noscript.njk', {}, {cache: theme.cache.enable}) }}
|
||||||
|
|||||||
@ -17,3 +17,5 @@
|
|||||||
lang : '{{ page.lang }}'
|
lang : '{{ page.lang }}'
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{{- next_inject('head') }}
|
||||||
|
|||||||
@ -5,9 +5,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = ctx => function(args) {
|
module.exports = ctx => function(args) {
|
||||||
args = args.join('').split('@');
|
const [feature, periods = 'current'] = args.join('').split('@');
|
||||||
const feature = args[0];
|
|
||||||
const periods = args[1] || 'current';
|
|
||||||
|
|
||||||
if (!feature) {
|
if (!feature) {
|
||||||
ctx.log.warn('Caniuse feature can NOT be empty.');
|
ctx.log.warn('Caniuse feature can NOT be empty.');
|
||||||
|
|||||||
@ -5,9 +5,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = ctx => function(args) {
|
module.exports = ctx => function(args) {
|
||||||
args = args.join(' ').split('@');
|
const [classes = 'default', text = ''] = args.join(' ').split('@');
|
||||||
const classes = args[0] || 'default';
|
|
||||||
const text = args[1] || '';
|
|
||||||
|
|
||||||
if (!text) ctx.log.warn('Label text must be defined!');
|
if (!text) ctx.log.warn('Label text must be defined!');
|
||||||
|
|
||||||
|
|||||||
@ -4,11 +4,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = function(args, content) {
|
module.exports = function([image = '/images/avatar.gif', delimiter = '|', comment = '%'], content) {
|
||||||
const image = args[0] || '/images/avatar.gif';
|
|
||||||
const delimiter = args[1] || '|';
|
|
||||||
const comment = args[2] || '%';
|
|
||||||
|
|
||||||
const links = content.split('\n').filter(line => line.trim() !== '').map(line => {
|
const links = content.split('\n').filter(line => line.trim() !== '').map(line => {
|
||||||
const item = line.split(delimiter).map(arg => arg.trim());
|
const item = line.split(delimiter).map(arg => arg.trim());
|
||||||
if (item[0][0] === comment) return '';
|
if (item[0][0] === comment) return '';
|
||||||
|
|||||||
@ -8,10 +8,14 @@ describe('label', () => {
|
|||||||
const postLabel = require('../../scripts/tags/label')(hexo);
|
const postLabel = require('../../scripts/tags/label')(hexo);
|
||||||
|
|
||||||
it('only text', () => {
|
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', () => {
|
it('classes and text', () => {
|
||||||
postLabel('primary@Hello world'.split(' ')).should.eql('<mark class="label primary">Hello world</mark>');
|
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