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