diff --git a/scripts/tags/folders.js b/scripts/tags/folders.js
index f45a7be..989bcc0 100644
--- a/scripts/tags/folders.js
+++ b/scripts/tags/folders.js
@@ -19,13 +19,13 @@ hexo.extend.tag.register('folders', function(args, content) {
el += ' ' + hexo.args.joinTags(args, ['color']).join(' ');
el += '>';
- var arr = content.split(//g).filter(item => item.trim().length > 0)
+ var arr = content.split(//g).filter(item => item.trim().length > 0)
if (arr.length > 0) {
var nodes = [];
arr.forEach((item, i) => {
- if (item.startsWith('folder ')) {
+ if (i % 2 == 0) {
nodes.push({
- header: item.substring(7)
+ header: item
});
} else if (nodes.length > 0) {
var node = nodes[nodes.length-1];
@@ -42,7 +42,7 @@ hexo.extend.tag.register('folders', function(args, content) {
el += '' + (node.header || '') + '';
// content
el += '
';
- el += hexo.render.renderSync({text: node.body, engine: 'markdown'}).split('\n').join('');
+ el += hexo.render.renderSync({text: (node.body || ''), engine: 'markdown'}).split('\n').join('');
el += '
';
});
}
diff --git a/scripts/tags/lib/tabs.js b/scripts/tags/lib/tabs.js
index 2ea4a36..a9acbe6 100644
--- a/scripts/tags/lib/tabs.js
+++ b/scripts/tags/lib/tabs.js
@@ -6,15 +6,15 @@
var tab_index = 0;
-module.exports = ctx => function(args, content) {
+module.exports = ctx => function(args, content = '') {
var el = '';
- var arr = content.split(//g).filter(item => item.trim().length > 0)
+ var arr = content.split(//g).filter(item => item.trim().length > 0)
if (arr.length < 1) {
return el;
}
var tabs = [];
arr.forEach((item, i) => {
- if (item.startsWith('tab ')) {
+ if (i % 2 == 0) {
tabs.push({
header: item
});
@@ -35,14 +35,12 @@ module.exports = ctx => function(args, content) {
let tabId = 0;
let tabNav = '';
let tabContent = '';
-
tabs.forEach((tab, i) => {
- let caption = tab.header.substring(4);
- let content = ctx.render.renderSync({ text: tab.body, engine: 'markdown' }).trim();
+ let content = ctx.render.renderSync({ text: (tab.body || ''), engine: 'markdown' }).trim();
const abbr = tabName + ' ' + ++tabId;
const href = abbr.toLowerCase().split(' ').join('-');
const isActive = (tabActive > 0 && tabActive === tabId) || (tabActive === 0 && tabId === 1) ? ' active' : '';
- tabNav += `${caption || abbr}`;
+ tabNav += `${tab.header || abbr}`;
tabContent += `${content}
`;
});
diff --git a/scripts/tags/split.js b/scripts/tags/split.js
index 87ce5d6..748db8d 100644
--- a/scripts/tags/split.js
+++ b/scripts/tags/split.js
@@ -3,9 +3,9 @@
* 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
*
* {% split [style:block/card] %}
- *
+ *
* left body
- *
+ *
* right body
* {% endsplit %}
*/
@@ -19,13 +19,13 @@ hexo.extend.tag.register('split', function(args, content) {
el += ' ' + hexo.args.joinTags(args, ['bg']).join(' ');
el += '>';
- var arr = content.split(//g).filter(item => item.trim().length > 0)
+ var arr = content.split(//g).filter(item => item.trim().length > 0)
if (arr.length > 0) {
var nodes = [];
arr.forEach((item, i) => {
- if (item == 'cell') {
+ if (i % 2 == 0) {
nodes.push({
- header: ''
+ header: item
});
} else if (nodes.length > 0) {
var node = nodes[nodes.length-1];
@@ -38,7 +38,7 @@ hexo.extend.tag.register('split', function(args, content) {
});
nodes.forEach((node, i) => {
el += '';
- el += hexo.render.renderSync({text: node.body, engine: 'markdown'}).split('\n').join('');
+ el += hexo.render.renderSync({text: (node.body || ''), engine: 'markdown'}).split('\n').join('');
el += '
';
});
}
diff --git a/scripts/tags/timeline.js b/scripts/tags/timeline.js
index 1f64082..2c362bd 100644
--- a/scripts/tags/timeline.js
+++ b/scripts/tags/timeline.js
@@ -49,11 +49,11 @@ function postTimeline(args, content) {
el += '';
}
- var arr = content.split(//g).filter(item => item.trim().length > 0)
+ var arr = content.split(//g).filter(item => item.trim().length > 0)
if (arr.length > 0) {
var nodes = [];
arr.forEach((item, i) => {
- if (item.startsWith('node ')) {
+ if (i % 2 == 0) {
nodes.push({
header: item
});
@@ -68,7 +68,7 @@ function postTimeline(args, content) {
});
nodes.forEach((node, i) => {
el += '
';
- el += layoutNodeTitle(node.header.substring(5));
+ el += layoutNodeTitle(node.header);
el += layoutNodeContent(node.body);
el += '
';
});