[fix] syntax errors

This commit is contained in:
xaoxuu 2022-12-11 16:38:36 +08:00
parent 851c23cedc
commit 7963ea7289
2 changed files with 33 additions and 33 deletions

View File

@ -1,5 +1,5 @@
<script type="text/javascript">
stellar = {
const stellar = {
// 懒加载 css https://github.com/filamentgroup/loadCSS
loadCSS: (href, before, media, attributes) => {
var doc = window.document;

View File

@ -4,56 +4,56 @@
'use strict';
var tab_index = 0;
var tab_index = 0
module.exports = ctx => function(args, content = '') {
var el = '';
var arr = content.split(/<!--\s*tab (.*?)\s*-->/g).filter(item => item.trim().length > 0)
if (arr.length < 1) {
return el;
return ''
}
var tabs = [];
var tabs = []
arr.forEach((item, i) => {
if (i % 2 == 0) {
tabs.push({
header: item
});
})
} else if (tabs.length > 0) {
var tab = tabs[tabs.length-1];
var tab = tabs[tabs.length-1]
if (tab.body == undefined) {
tab.body = item;
tab.body = item
} else {
tab.body += '\n' + item;
tab.body += '\n' + item
}
}
});
})
args = ctx.args.map(args, ['active', 'align']);
const tabName = 'tab_' + ++tab_index;
const tabActive = Number(args.active) || 0;
args = ctx.args.map(args, ['active', 'align'])
const tabName = 'tab_' + ++tab_index
const tabActive = Number(args.active) || 0
let tabId = 0;
let tabNav = '';
let tabContent = '';
let tabId = 0
let tabNav = ''
let tabContent = ''
tabs.forEach((tab, i) => {
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 += `<li class="tab${isActive}"><a href="#${href}">${tab.header || abbr}</a></li>`;
tabContent += `<div class="tab-pane${isActive}" id="${href}">${content}</div>`;
});
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 += `<li class="tab${isActive}"><a href="#${href}">${tab.header || abbr}</a></li>`
tabContent += `<div class="tab-pane${isActive}" id="${href}">${content}</div>`
})
tabNav = `<ul class="nav-tabs">${tabNav}</ul>`;
tabContent = `<div class="tab-content">${tabContent}</div>`;
tabNav = `<ul class="nav-tabs">${tabNav}</ul>`
tabContent = `<div class="tab-content">${tabContent}</div>`
el += '<div class="tag-plugin tabs"';
var el = ''
el += '<div class="tag-plugin tabs"'
if (args.align != undefined) {
el += ' align="' + args.align + '"';
el += ' align="' + args.align + '"'
}
el += 'id="' + tabName.toLowerCase().split(' ').join('-') + '"'
el += '>'
el += tabNav + tabContent
el += '</div>'
return el
}
el += 'id="' + tabName.toLowerCase().split(' ').join('-') + '"';
el += '">';
el += tabNav + tabContent;
el += '</div>';
return el;
};