mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Use String.prototype.matchAll
This commit is contained in:
parent
17bd19d268
commit
eefc25de1a
@ -4,21 +4,21 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = ctx => function(args, content) {
|
||||
module.exports = ctx => function(args, content = '') {
|
||||
const tabBlock = /<!--\s*tab (.*?)\s*-->\n([\w\W\s\S]*?)<!--\s*endtab\s*-->/g;
|
||||
|
||||
args = args.join(' ').split(',');
|
||||
const tabName = args[0];
|
||||
const tabActive = Number(args[1]) || 0;
|
||||
|
||||
let match;
|
||||
let tabId = 0;
|
||||
let tabNav = '';
|
||||
let tabContent = '';
|
||||
|
||||
if (!tabName) ctx.log.warn('Tabs block must have unique name!');
|
||||
const matches = content.matchAll(tabBlock);
|
||||
|
||||
while ((match = tabBlock.exec(content)) !== null) {
|
||||
for (const match of matches) {
|
||||
let [caption = '', icon = ''] = match[1].split('@');
|
||||
let postContent = match[2];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user