From 40f6ee4fda2192f1473ce3ff32e15ad111b14e94 Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Sun, 11 Dec 2022 18:05:21 +0800 Subject: [PATCH] [opt] tag-plugins --- scripts/tags/ablock.js | 33 ------------- scripts/tags/about.js | 48 ------------------ scripts/tags/checkbox.js | 38 --------------- scripts/tags/emoji.js | 40 --------------- scripts/tags/folding.js | 30 ------------ scripts/tags/frame.js | 66 ------------------------- scripts/tags/friends.js | 53 -------------------- scripts/tags/index.js | 38 ++++++++++++--- scripts/tags/inline-labels.js | 54 ++++++++++----------- scripts/tags/lib/ablock.js | 33 +++++++++++++ scripts/tags/lib/about.js | 48 ++++++++++++++++++ scripts/tags/lib/checkbox.js | 30 ++++++++++++ scripts/tags/{ => lib}/copy.js | 46 +++++++++--------- scripts/tags/lib/emoji.js | 40 +++++++++++++++ scripts/tags/{ => lib}/folders.js | 44 ++++++++--------- scripts/tags/lib/folding.js | 30 ++++++++++++ scripts/tags/lib/frame.js | 66 +++++++++++++++++++++++++ scripts/tags/lib/friends.js | 53 ++++++++++++++++++++ scripts/tags/{ => lib}/ghcard.js | 36 +++++++------- scripts/tags/{ => lib}/grid.js | 40 +++++++-------- scripts/tags/{ => lib}/image.js | 76 ++++++++++++++--------------- scripts/tags/lib/link.js | 78 +++++++++++++++++++++++++++++ scripts/tags/lib/mark.js | 23 +++++++++ scripts/tags/lib/navbar.js | 57 ++++++++++++++++++++++ scripts/tags/lib/note.js | 35 +++++++++++++ scripts/tags/lib/poetry.js | 47 ++++++++++++++++++ scripts/tags/{ => lib}/quot.js | 48 +++++++++--------- scripts/tags/lib/sites.js | 57 ++++++++++++++++++++++ scripts/tags/lib/swiper.js | 38 +++++++++++++++ scripts/tags/lib/tabs.js | 2 +- scripts/tags/{ => lib}/tag.js | 26 +++++----- scripts/tags/lib/timeline.js | 78 +++++++++++++++++++++++++++++ scripts/tags/lib/toc.js | 72 +++++++++++++++++++++++++++ scripts/tags/lib/users.js | 22 --------- scripts/tags/link.js | 79 ------------------------------ scripts/tags/mark.js | 23 --------- scripts/tags/navbar.js | 57 ---------------------- scripts/tags/note.js | 35 ------------- scripts/tags/poetry.js | 47 ------------------ scripts/tags/sites.js | 57 ---------------------- scripts/tags/swiper.js | 38 --------------- scripts/tags/timeline.js | 81 ------------------------------- scripts/tags/toc.js | 72 --------------------------- 43 files changed, 1003 insertions(+), 1011 deletions(-) delete mode 100644 scripts/tags/ablock.js delete mode 100644 scripts/tags/about.js delete mode 100644 scripts/tags/checkbox.js delete mode 100644 scripts/tags/emoji.js delete mode 100644 scripts/tags/folding.js delete mode 100644 scripts/tags/frame.js delete mode 100644 scripts/tags/friends.js create mode 100644 scripts/tags/lib/ablock.js create mode 100644 scripts/tags/lib/about.js create mode 100644 scripts/tags/lib/checkbox.js rename scripts/tags/{ => lib}/copy.js (59%) create mode 100644 scripts/tags/lib/emoji.js rename scripts/tags/{ => lib}/folders.js (53%) create mode 100644 scripts/tags/lib/folding.js create mode 100644 scripts/tags/lib/frame.js create mode 100644 scripts/tags/lib/friends.js rename scripts/tags/{ => lib}/ghcard.js (62%) rename scripts/tags/{ => lib}/grid.js (52%) rename scripts/tags/{ => lib}/image.js (58%) create mode 100644 scripts/tags/lib/link.js create mode 100644 scripts/tags/lib/mark.js create mode 100644 scripts/tags/lib/navbar.js create mode 100644 scripts/tags/lib/note.js create mode 100644 scripts/tags/lib/poetry.js rename scripts/tags/{ => lib}/quot.js (60%) create mode 100644 scripts/tags/lib/sites.js create mode 100644 scripts/tags/lib/swiper.js rename scripts/tags/{ => lib}/tag.js (58%) create mode 100644 scripts/tags/lib/timeline.js create mode 100644 scripts/tags/lib/toc.js delete mode 100644 scripts/tags/lib/users.js delete mode 100644 scripts/tags/link.js delete mode 100644 scripts/tags/mark.js delete mode 100644 scripts/tags/navbar.js delete mode 100644 scripts/tags/note.js delete mode 100644 scripts/tags/poetry.js delete mode 100644 scripts/tags/sites.js delete mode 100644 scripts/tags/swiper.js delete mode 100644 scripts/tags/timeline.js delete mode 100644 scripts/tags/toc.js diff --git a/scripts/tags/ablock.js b/scripts/tags/ablock.js deleted file mode 100644 index ccf38da..0000000 --- a/scripts/tags/ablock.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * ablock.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/ - * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) - * - * {% ablock [color:color] [child:codeblock/tabs] title %} - * body - * {% endablock %} - */ - -'use strict'; - -hexo.extend.tag.register('ablock', function(args, content) { - args = hexo.args.map(args, ['color', 'child'], ['title']); - const { title } = args; - if (args.color == null) { - args.color = hexo.theme.config.tag_plugins.note.default_color - } - var el = ''; - // header - el += '
0) { - el += '
' + title + '
'; - } - // content - el += '
'; - el += hexo.render.renderSync({text: content, engine: 'markdown'}).split('\n').join(''); - el += '
'; - - return el; -}, {ends: true}); diff --git a/scripts/tags/about.js b/scripts/tags/about.js deleted file mode 100644 index c30fbdc..0000000 --- a/scripts/tags/about.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * about.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ - * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) - * - * {% about [avatar:xxx] [height:80px] %} - * title / body - * {% endabout %} - */ - -'use strict'; -const url_for = require('hexo-util').url_for.bind(hexo); - -hexo.extend.tag.register('about', function(args, content) { - args = hexo.args.map(args, ['avatar', 'height', 'border', 'back']); - var rows = hexo.render.renderSync({text: content, engine: 'markdown'}).split('\n'); - var el = ''; - // wrapper - el += '
'; - if (args.back) { - el += ''; - el += ''; - el += ''; - } - // avatar - var avatar_url = args.avatar; - if (avatar_url) { - el += '
'; - el += '
'; - el += ' 0) { - el += ' style="border-radius:' + args.border + '"'; - } - if (args.height && args.height.length > 0) { - el += ' height="' + args.height + '"'; - } - el += '/>'; - el += '
'; - el += '
'; - } - - // content - el += '
'; - el += rows.join(''); - el += '
'; - - el += '
'; - return el; -}, {ends: true}); diff --git a/scripts/tags/checkbox.js b/scripts/tags/checkbox.js deleted file mode 100644 index ba9bab5..0000000 --- a/scripts/tags/checkbox.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * checkbox.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ - * radio.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ - * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) - * - * {% checkbox [checked:false] [color:cyan] [symbol:plus/minus/times] text %} - * {% radio [checked:false] [color:cyan] text %} - */ - -'use strict'; - -function layoutDiv(args, type) { - args = hexo.args.map(args, ['color', 'checked', 'symbol'], ['text']); - var el = ''; - // div - el += '
'; - // div - el += '
'; - return el; -} - -hexo.extend.tag.register('checkbox', function(args) { - return layoutDiv(args, 'checkbox'); -}); - -hexo.extend.tag.register('radio', function(args) { - return layoutDiv(args, 'radio'); -}); diff --git a/scripts/tags/emoji.js b/scripts/tags/emoji.js deleted file mode 100644 index d98c183..0000000 --- a/scripts/tags/emoji.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * emoji.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ - * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) - * - * {% emoji [source] name [height:1.75em] %} - * - */ - -'use strict'; - -hexo.extend.tag.register('emoji', function(args) { - const config = hexo.theme.config.tag_plugins.emoji; - args = hexo.args.map(args, ['height'], ['source', 'name']); - var el = ''; - if (args.source == undefined) { - return el; - } - el += ''; - if (args.name == undefined) { - // 省略了 source - for (let id in config) { - if (config[id]) { - args.name = args.source; - args.source = id; - break; - } - } - } - if (config[args.source] && args.name) { - let url = config[args.source].replace('%s', args.name); - el += ''; - // content - el += '
'; - el += hexo.render.renderSync({text: content, engine: 'markdown'}).split('\n').join(''); - el += '
'; - - return el; -}, {ends: true}); diff --git a/scripts/tags/frame.js b/scripts/tags/frame.js deleted file mode 100644 index 827dc2b..0000000 --- a/scripts/tags/frame.js +++ /dev/null @@ -1,66 +0,0 @@ -/** - * frame.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ - * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) - * - * {% frame iphone11 [img:src] [video:url] [focus:top/bottom] [alt] %} - */ - -'use strict'; - -hexo.extend.tag.register('frame', function(args) { - args = hexo.args.map(args, ['focus', 'img', 'video'], ['device', 'alt']); - const img = args.img || ''; - const video = args.video || ''; - const device = args.device || ''; - const focus = args.focus || ''; - const alt = args.alt || ''; - if ((img.length == 0 && video.length == 0) || device.length == 0) { - return; - } - var el = ''; - function imgTag(url, alt) { - let i = ''; - i += ' 0) { - i += ' alt="' + alt + '"'; - } - i += '/>'; - return i; - } - if (video.length > 0) { - el += '
'; - el += '
0) { - el += 'focus="' + focus + '">'; - } else { - el += '>'; - } - el += ' 0) { - el += ' poster="' + img + '"'; - } - el += ' playsinline="" muted="" loop="" autoplay="" preload="metadata">'; - el += ''; - el += ''; - - el += '
'; - el += '
'; - el += '
'; - } else if (img.length > 0) { - el += '
'; - el += '
0) { - el += 'focus="' + focus + '">'; - } else { - el += '>'; - } - el += imgTag(img, alt); - el += '
'; - el += '
'; - if (alt.length > 0) { - el += '' + alt + ''; - } - el += '
'; - } - return el; -}); diff --git a/scripts/tags/friends.js b/scripts/tags/friends.js deleted file mode 100644 index 956e168..0000000 --- a/scripts/tags/friends.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * friends.js v2 | https://github.com/xaoxuu/hexo-theme-stellar/ - * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) - * - * {% friends [group] [repo:owner/repo] [api:http] %} - */ - -'use strict'; - -hexo.extend.tag.register('friends', function(args) { - args = hexo.args.map(args, ['repo', 'api'], ['group']); - var links = hexo.locals.get('data').links; - if (links == undefined) { - links = {}; - } - var api; - if (args.api) { - api = args.api; - } else if (args.repo) { - api = 'https://api.vlts.cc/output_data/v2/' + args.repo; - } - - var el = '
'; - if (api) { - el += '
'; - cell += ''; - cell += '
' + item.title + '
'; - cell += '
' - return cell; - } else { - return ''; - } - } - el += '
'; - const items = links[args.group] || []; - items.forEach((item, i) => { - el += cell(item); - }); - el += '
'; - } - - el += '
'; - return el; -}); diff --git a/scripts/tags/index.js b/scripts/tags/index.js index e9043f8..14242a0 100644 --- a/scripts/tags/index.js +++ b/scripts/tags/index.js @@ -2,10 +2,36 @@ 'use strict'; -const postTabs = require('./lib/tabs')(hexo); -hexo.extend.tag.register('tabs', postTabs, true); -hexo.extend.tag.register('subtabs', postTabs, true); -hexo.extend.tag.register('subsubtabs', postTabs, true); +// container +hexo.extend.tag.register('tabs', require('./lib/tabs')(hexo), true) +hexo.extend.tag.register('ablock', require('./lib/ablock')(hexo), true) +hexo.extend.tag.register('about', require('./lib/about')(hexo), true) +hexo.extend.tag.register('folding', require('./lib/folding')(hexo), true) +hexo.extend.tag.register('folders', require('./lib/folders')(hexo), true) +hexo.extend.tag.register('grid', require('./lib/grid')(hexo), true) +hexo.extend.tag.register('swiper', require('./lib/swiper')(hexo), true) -const users = require('./lib/users')(hexo); -hexo.extend.tag.register('users', users); \ No newline at end of file +// data +hexo.extend.tag.register('users', require('./lib/friends')(hexo)) +hexo.extend.tag.register('friends', require('./lib/friends')(hexo)) +hexo.extend.tag.register('sites', require('./lib/sites')(hexo)) +hexo.extend.tag.register('ghcard', require('./lib/ghcard')(hexo)) +hexo.extend.tag.register('toc', require('./lib/toc')(hexo)) +hexo.extend.tag.register('timeline', require('./lib/timeline')(hexo), {ends: true}) + +// express +hexo.extend.tag.register('checkbox', require('./lib/checkbox')(hexo, 'checkbox')) +hexo.extend.tag.register('radio', require('./lib/checkbox')(hexo, 'radio')) +hexo.extend.tag.register('copy', require('./lib/copy')(hexo)) +hexo.extend.tag.register('emoji', require('./lib/emoji')(hexo)) +hexo.extend.tag.register('frame', require('./lib/frame')(hexo)) +hexo.extend.tag.register('image', require('./lib/image')(hexo)) +hexo.extend.tag.register('link', require('./lib/link')(hexo)) +hexo.extend.tag.register('mark', require('./lib/mark')(hexo)) +hexo.extend.tag.register('navbar', require('./lib/navbar')(hexo)) +hexo.extend.tag.register('note', require('./lib/note')(hexo)) +hexo.extend.tag.register('poetry', require('./lib/poetry')(hexo), true) +hexo.extend.tag.register('quot', require('./lib/quot')(hexo)) +hexo.extend.tag.register('tag', require('./lib/tag')(hexo)) + +// others diff --git a/scripts/tags/inline-labels.js b/scripts/tags/inline-labels.js index 258e505..1f54e5d 100644 --- a/scripts/tags/inline-labels.js +++ b/scripts/tags/inline-labels.js @@ -5,40 +5,40 @@ * {% psw 这是密码 %} */ -'use strict'; +'use strict' hexo.extend.tag.register('u', function(args) { - return `${args.join(' ')}`; -}); + return `${args.join(' ')}` +}) hexo.extend.tag.register('emp', function(args) { - return `${args.join(' ')}`; -}); + return `${args.join(' ')}` +}) hexo.extend.tag.register('wavy', function(args) { - return `${args.join(' ')}`; -}); + return `${args.join(' ')}` +}) hexo.extend.tag.register('del', function(args) { - return `${args.join(' ')}`; -}); + return `${args.join(' ')}` +}) hexo.extend.tag.register('kbd', function(args) { - return `${args.join(' ')}`; -}); + return `${args.join(' ')}` +}) hexo.extend.tag.register('psw', function(args) { - return `${args.join(' ')}`; -}); + return `${args.join(' ')}` +}) hexo.extend.tag.register('sup', function(args) { - args = hexo.args.map(args, ['color'], ['text']); - var el = ''; - el += ''; - el += args.text; - el += ''; - return el; -}); + args = hexo.args.map(args, ['color'], ['text']) + var el = '' + el += '' + el += args.text + el += '' + return el +}) hexo.extend.tag.register('sub', function(args) { - args = hexo.args.map(args, ['color'], ['text']); - var el = ''; - el += ''; - el += args.text; - el += ''; - return el; -}); + args = hexo.args.map(args, ['color'], ['text']) + var el = '' + el += '' + el += args.text + el += '' + return el +}) diff --git a/scripts/tags/lib/ablock.js b/scripts/tags/lib/ablock.js new file mode 100644 index 0000000..0621c31 --- /dev/null +++ b/scripts/tags/lib/ablock.js @@ -0,0 +1,33 @@ +/** + * ablock.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% ablock [color:color] [child:codeblock/tabs] title %} + * body + * {% endablock %} + */ + +'use strict'; + +module.exports = ctx => function(args, content) { + args = ctx.args.map(args, ['color', 'child'], ['title']) + const { title } = args + if (args.color == null) { + args.color = ctx.theme.config.tag_plugins.note.default_color + } + var el = '' + // header + el += '
0) { + el += '
' + title + '
' + } + // content + el += '
' + el += ctx.render.renderSync({text: content, engine: 'markdown'}).split('\n').join('') + el += '
' + + return el +} diff --git a/scripts/tags/lib/about.js b/scripts/tags/lib/about.js new file mode 100644 index 0000000..df8190e --- /dev/null +++ b/scripts/tags/lib/about.js @@ -0,0 +1,48 @@ +/** + * about.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% about [avatar:xxx] [height:80px] %} + * title / body + * {% endabout %} + */ + +'use strict'; + +module.exports = ctx => function(args, content) { + const url_for = require('hexo-util').url_for.bind(ctx) + args = ctx.args.map(args, ['avatar', 'height', 'border', 'back']) + var rows = ctx.render.renderSync({text: content, engine: 'markdown'}).split('\n') + var el = '' + // wrapper + el += '
' + if (args.back) { + el += '' + el += '' + el += '' + } + // avatar + var avatar_url = args.avatar + if (avatar_url) { + el += '
' + el += '
' + el += ' 0) { + el += ' style="border-radius:' + args.border + '"' + } + if (args.height && args.height.length > 0) { + el += ' height="' + args.height + '"' + } + el += '/>' + el += '
' + el += '
' + } + + // content + el += '
' + el += rows.join('') + el += '
' + + el += '
' + return el +} \ No newline at end of file diff --git a/scripts/tags/lib/checkbox.js b/scripts/tags/lib/checkbox.js new file mode 100644 index 0000000..a582f03 --- /dev/null +++ b/scripts/tags/lib/checkbox.js @@ -0,0 +1,30 @@ +/** + * checkbox.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ + * radio.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% checkbox [checked:false] [color:cyan] [symbol:plus/minus/times] text %} + * {% radio [checked:false] [color:cyan] text %} + */ + +'use strict' + +module.exports = (ctx, type) => function(args) { + args = ctx.args.map(args, ['color', 'checked', 'symbol'], ['text']) + var el = '' + // div + el += '
' + // div + el += '
' + return el +} diff --git a/scripts/tags/copy.js b/scripts/tags/lib/copy.js similarity index 59% rename from scripts/tags/copy.js rename to scripts/tags/lib/copy.js index 6de1c20..a9ce52c 100644 --- a/scripts/tags/copy.js +++ b/scripts/tags/lib/copy.js @@ -7,43 +7,43 @@ * */ -'use strict'; +'use strict' -var copy_index = 0; +var copy_index = 0 -hexo.extend.tag.register('copy', function(args) { - args = hexo.args.map(args, ['width', 'git'], ['text']); +module.exports = ctx => function(args) { + args = ctx.args.map(args, ['width', 'git'], ['text']) if (args == undefined || args.text == undefined) { - return ''; + return '' } - var text = args.text; + var text = args.text if (args.git) { if (text.substr(0,1) == '/') { - text = text.substring(1); + text = text.substring(1) } if (args.git == 'ssh') { - text = 'git@github.com:' + text + '.git'; + text = 'git@github.com:' + text + '.git' } else if (args.git == 'gh') { - text = 'gh repo clone ' + text; + text = 'gh repo clone ' + text } else { - text = 'https://github.com/' + text + '.git'; + text = 'https://github.com/' + text + '.git' } } - const copy_id = 'copy_' + ++copy_index; + const copy_id = 'copy_' + ++copy_index - var el = ''; - el += '
'; - el += ''; + el += '>' + el += '' + el += '' - el += '
'; - return el; -}); + el += '' + return el +} diff --git a/scripts/tags/lib/emoji.js b/scripts/tags/lib/emoji.js new file mode 100644 index 0000000..c540729 --- /dev/null +++ b/scripts/tags/lib/emoji.js @@ -0,0 +1,40 @@ +/** + * emoji.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% emoji [source] name [height:1.75em] %} + * + */ + +'use strict' + +module.exports = ctx => function(args) { + const config = ctx.theme.config.tag_plugins.emoji + args = ctx.args.map(args, ['height'], ['source', 'name']) + var el = '' + if (args.source == undefined) { + return el + } + el += '' + if (args.name == undefined) { + // 省略了 source + for (let id in config) { + if (config[id]) { + args.name = args.source + args.source = id + break + } + } + } + if (config[args.source] && args.name) { + let url = config[args.source].replace('%s', args.name) + el += ' function(args, content) { + args = ctx.args.map(args, ['color']) + var el = '' + el += '
/g).filter(item => item.trim().length > 0) if (arr.length > 0) { - var nodes = []; + var nodes = [] arr.forEach((item, i) => { if (i % 2 == 0) { nodes.push({ header: item - }); + }) } else if (nodes.length > 0) { - var node = nodes[nodes.length-1]; + var node = nodes[nodes.length-1] if (node.body == undefined) { - node.body = item; + node.body = item } else { - node.body += '\n' + item; + node.body += '\n' + item } } - }); + }) nodes.forEach((node, i) => { - el += '
'; + el += '
' // summary - el += '' + (node.header || '') + ''; + el += '' + (node.header || '') + '' // content - el += '
'; - el += hexo.render.renderSync({text: (node.body || ''), engine: 'markdown'}).split('\n').join(''); - el += '
'; - }); + el += '
' + el += ctx.render.renderSync({text: (node.body || ''), engine: 'markdown'}).split('\n').join('') + el += '
' + }) } - el += '
'; + el += '' - return el; -}, {ends: true}); + return el +} diff --git a/scripts/tags/lib/folding.js b/scripts/tags/lib/folding.js new file mode 100644 index 0000000..4237434 --- /dev/null +++ b/scripts/tags/lib/folding.js @@ -0,0 +1,30 @@ +/** + * folding.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% folding [color:yellow] [child:codeblock] [open:false] title %} + * body + * {% endtable %} + */ + +'use strict' + +module.exports = ctx => function(args, content) { + args = ctx.args.map(args, ['color', 'child', 'open'], ['title']) + var el = '' + // header + el += '
' + // content + el += '
' + el += ctx.render.renderSync({text: content, engine: 'markdown'}).split('\n').join('') + el += '
' + + return el +} diff --git a/scripts/tags/lib/frame.js b/scripts/tags/lib/frame.js new file mode 100644 index 0000000..bfdd2f8 --- /dev/null +++ b/scripts/tags/lib/frame.js @@ -0,0 +1,66 @@ +/** + * frame.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% frame iphone11 [img:src] [video:url] [focus:top/bottom] [alt] %} + */ + +'use strict' + +module.exports = ctx => function(args) { + args = ctx.args.map(args, ['focus', 'img', 'video'], ['device', 'alt']) + const img = args.img || '' + const video = args.video || '' + const device = args.device || '' + const focus = args.focus || '' + const alt = args.alt || '' + if ((img.length == 0 && video.length == 0) || device.length == 0) { + return + } + var el = '' + function imgTag(url, alt) { + let i = '' + i += ' 0) { + i += ' alt="' + alt + '"' + } + i += '/>' + return i + } + if (video.length > 0) { + el += '
' + el += '
0) { + el += 'focus="' + focus + '">' + } else { + el += '>' + } + el += ' 0) { + el += ' poster="' + img + '"' + } + el += ' playsinline="" muted="" loop="" autoplay="" preload="metadata">' + el += '' + el += '' + + el += '
' + el += '
' + el += '
' + } else if (img.length > 0) { + el += '
' + el += '
0) { + el += 'focus="' + focus + '">' + } else { + el += '>' + } + el += imgTag(img, alt) + el += '
' + el += '
' + if (alt.length > 0) { + el += '' + alt + '' + } + el += '
' + } + return el +} diff --git a/scripts/tags/lib/friends.js b/scripts/tags/lib/friends.js new file mode 100644 index 0000000..636c54b --- /dev/null +++ b/scripts/tags/lib/friends.js @@ -0,0 +1,53 @@ +/** + * friends.js v2 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% friends [group] [repo:owner/repo] [api:http] %} + */ + +'use strict' + +module.exports = ctx => function(args) { + args = ctx.args.map(args, ['repo', 'api'], ['group']) + var links = ctx.locals.get('data').links + if (links == undefined) { + links = {} + } + var api + if (args.api) { + api = args.api + } else if (args.repo) { + api = 'https://api.vlts.cc/output_data/v2/' + args.repo + } + + var el = '
' + if (api) { + el += '
' + cell += '' + cell += '
' + item.title + '
' + cell += '
' + return cell + } else { + return '' + } + } + el += '
' + const items = links[args.group] || [] + items.forEach((item, i) => { + el += cell(item) + }) + el += '
' + } + + el += '
' + return el +} diff --git a/scripts/tags/ghcard.js b/scripts/tags/lib/ghcard.js similarity index 62% rename from scripts/tags/ghcard.js rename to scripts/tags/lib/ghcard.js index 2dfe410..4c9d7b5 100644 --- a/scripts/tags/ghcard.js +++ b/scripts/tags/lib/ghcard.js @@ -11,29 +11,29 @@ * API: https://github.com/anuraghazra/github-readme-stats */ -'use strict'; +'use strict' -hexo.extend.tag.register('ghcard', function(args) { - var params = ['show_owner', 'theme', 'title_color', 'text_color', 'icon_color', 'bg_color', 'hide_border', 'cache_seconds', 'locale']; - args = hexo.args.map(args, params, ['repo']); - const path = args.repo; - var el = ''; - el += '' + return el +} diff --git a/scripts/tags/grid.js b/scripts/tags/lib/grid.js similarity index 52% rename from scripts/tags/grid.js rename to scripts/tags/lib/grid.js index 868db0d..b8e06e2 100644 --- a/scripts/tags/grid.js +++ b/scripts/tags/lib/grid.js @@ -10,40 +10,40 @@ * {% endgrid %} */ -'use strict'; +'use strict' -hexo.extend.tag.register('grid', function(args, content) { - args = hexo.args.map(args, ['bg']); - var el = ''; - el += '
function(args, content) { + args = ctx.args.map(args, ['bg']) + var el = '' + el += '
/g).filter(item => item.trim().length > 0) if (arr.length > 0) { - var nodes = []; + var nodes = [] arr.forEach((item, i) => { if (i % 2 == 0) { nodes.push({ header: item - }); + }) } else if (nodes.length > 0) { - var node = nodes[nodes.length-1]; + var node = nodes[nodes.length-1] if (node.body == undefined) { - node.body = item; + node.body = item } else { - node.body += '\n' + item; + node.body += '\n' + item } } - }); + }) nodes.forEach((node, i) => { - el += '
'; - el += hexo.render.renderSync({text: (node.body || ''), engine: 'markdown'}).split('\n').join(''); - el += '
'; - }); + el += '
' + el += ctx.render.renderSync({text: (node.body || ''), engine: 'markdown'}).split('\n').join('') + el += '
' + }) } - el += '
'; + el += '
' - return el; -}, {ends: true}); + return el +} diff --git a/scripts/tags/image.js b/scripts/tags/lib/image.js similarity index 58% rename from scripts/tags/image.js rename to scripts/tags/lib/image.js index 1eea4ff..f253f94 100644 --- a/scripts/tags/image.js +++ b/scripts/tags/lib/image.js @@ -5,82 +5,82 @@ * {% image src [alt] [width:400px] [bg:#eee] [download:true/false/url] %} */ -'use strict'; +'use strict' -hexo.extend.tag.register('image', function(args) { - args = hexo.args.map(args, ['width', 'height', 'bg', 'download', 'padding', 'fancybox'], ['src', 'alt']); - var style = ''; +module.exports = ctx => function(args) { + args = ctx.args.map(args, ['width', 'height', 'bg', 'download', 'padding', 'fancybox'], ['src', 'alt']) + var style = '' if (args.width) { - style += 'width:' + args.width + ';'; + style += 'width:' + args.width + ';' } if (args.height) { - style += 'height:' + args.height + ';'; + style += 'height:' + args.height + ';' } // fancybox - var fancybox = false; - if (hexo.theme.config.plugins.fancybox && hexo.theme.config.plugins.fancybox.enable) { + var fancybox = false + if (ctx.theme.config.plugins.fancybox && ctx.theme.config.plugins.fancybox.enable) { // 主题配置 - if (hexo.theme.config.tag_plugins.image && hexo.theme.config.tag_plugins.image.fancybox) { - fancybox = hexo.theme.config.tag_plugins.image.fancybox; + if (ctx.theme.config.tag_plugins.image && ctx.theme.config.tag_plugins.image.fancybox) { + fancybox = ctx.theme.config.tag_plugins.image.fancybox } // 覆盖配置 if (args.fancybox && args.fancybox.length > 0) { if (args.fancybox == 'true') { - fancybox = true; + fancybox = true } else if (args.fancybox == 'false') { - fancybox = false; + fancybox = false } } } function img(src, alt, style) { - let img = ''; - img += ' 0) { - img += ' style="' + style + '"'; + img += ' style="' + style + '"' } - img += '/>'; - return img; + img += '/>' + return img } - var el = ''; + var el = '' // wrap - el += '
'; + el += '
' // bg - el += '
0) { - el += 'background:' + args.bg + ';'; + el += 'background:' + args.bg + ';' } if (args.padding) { - el += 'padding:' + args.padding + ';'; + el += 'padding:' + args.padding + ';' } - el += '"'; + el += '"' } - el += '>'; - el += img(args.src, args.alt, style); + el += '>' + el += img(args.src, args.alt, style) if (args.download && args.download.length > 0) { - let href = args.download; + let href = args.download if (args.download == 'true') { - href = args.src; + href = args.src } - el += ''; + el += '' } - el += '
'; + el += '
' if (args.alt && args.alt.length > 0) { - el += '
'; - el += '' + args.alt + ''; - el += '
'; + el += '
' + el += '' + args.alt + '' + el += '
' } - el += '
'; - return el; -}); + el += '' + return el +} \ No newline at end of file diff --git a/scripts/tags/lib/link.js b/scripts/tags/lib/link.js new file mode 100644 index 0000000..8ba6494 --- /dev/null +++ b/scripts/tags/lib/link.js @@ -0,0 +1,78 @@ +/** + * link.js v1.1 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% link url [title] [desc:true/false] [icon:src] %} + */ + +'use strict' + +module.exports = ctx => function(args) { + const full_url_for = require('hexo-util').full_url_for.bind(ctx) + args = ctx.args.map(args, ['icon', 'desc'], ['url', 'title']) + var autofill = [] + if (!args.title) { + autofill.push('title') + } + if (!args.icon) { + autofill.push('icon') + } + if (args.desc) { + autofill.push('desc') + } + var el = '' + el += '' + } else { + el += '
' + } + return el + } + function loadTitle() { + return '' + (args.title || args.url) + '' + } + function loadDesc() { + return '' + } + function loadLink() { + return '' + full_url_for(args.url) + '' + } + + if (args.desc) { + // top + el += '
' + el += loadIcon() + loadLink() + el += '
' + // bottom + el += '
' + el += loadTitle() + loadDesc() + el += '
' + } else { + // left + el += '
' + el += loadTitle() + loadLink() + el += '
' + // right + el += '
' + el += loadIcon() + el += '
' + } + + // end + el += '
' + + return el +} diff --git a/scripts/tags/lib/mark.js b/scripts/tags/lib/mark.js new file mode 100644 index 0000000..545926a --- /dev/null +++ b/scripts/tags/lib/mark.js @@ -0,0 +1,23 @@ +/** + * mark.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% mark text [color:color] %} + * + */ + +'use strict' + +module.exports = ctx => function(args) { + args = ctx.args.map(args, ['color'], ['text']) + if (args.color == null) { + args.color = ctx.theme.config.tag_plugins.mark.default_color + } + var el = '' + el += ' function(args) { + if (args.length == 0) { + return + } + args = ctx.args.map(args, ['active'], ['links']) + if (args.links) { + args.links = args.links.split(' ') + } + var el = '' + return el +} diff --git a/scripts/tags/lib/note.js b/scripts/tags/lib/note.js new file mode 100644 index 0000000..db9f729 --- /dev/null +++ b/scripts/tags/lib/note.js @@ -0,0 +1,35 @@ +/** + * note.js v1.1 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% note [color:color] [title] content %} + */ + +'use strict' + +module.exports = ctx => function(args) { + args = ctx.args.map(args, ['color'], ['title', 'content']) + if (args.content == undefined || args.content.length <= 0) { + args.content = args.title + args.title = '' + } + const { title } = args + if (args.color == null) { + args.color = ctx.theme.config.tag_plugins.note.default_color + } + var el = '' + // header + el += '
0) { + el += '
' + title + '
' + } + // content + el += '
' + el += ctx.render.renderSync({text: args.content, engine: 'markdown'}).split('\n').join('') + el += '
' + + return el +} diff --git a/scripts/tags/lib/poetry.js b/scripts/tags/lib/poetry.js new file mode 100644 index 0000000..3d5ab0c --- /dev/null +++ b/scripts/tags/lib/poetry.js @@ -0,0 +1,47 @@ +/** + * poetry.js v1.1 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * poetry: + * {% poetry [title] [author:作者] [date:日期] [footer:footer] %} + * body + * {% endpoetry %} + * + */ + +'use strict' + +module.exports = ctx => function(args, content) { + var el = '' + args = ctx.args.map(args, ['author', 'date', 'footer'], ['title']) + + el += '
' + } + if (args.date) { + el += '' + args.date + '' + } + el += '
' + } + el += '
' + el += ctx.render.renderSync({text: content, engine: 'markdown'}).split('\n').join('') + el += '
' + if (args.footer) { + el += '' + } + el += '' + el += '' + return el +} \ No newline at end of file diff --git a/scripts/tags/quot.js b/scripts/tags/lib/quot.js similarity index 60% rename from scripts/tags/quot.js rename to scripts/tags/lib/quot.js index 3eae282..ae2c327 100644 --- a/scripts/tags/quot.js +++ b/scripts/tags/lib/quot.js @@ -7,49 +7,49 @@ * */ -'use strict'; +'use strict' -hexo.extend.tag.register('quot', function(args) { - var el = ''; - args = hexo.args.map(args, ['el', 'icon'], ['text']); +module.exports = ctx => function(args) { + var el = '' + args = ctx.args.map(args, ['el', 'icon'], ['text']) if (!args.el) { - args.el = 'p'; + args.el = 'p' } - var type = ''; + var type = '' if (args.icon && args.icon != 'square' && args.icon != 'quotes') { - type = ' type="icon"'; + type = ' type="icon"' } else { - type = ' type="text"'; + type = ' type="text"' } function content() { if (!args.icon) { - return args.text; + return args.text } - var el = ''; - const cfg = hexo.theme.config.tag_plugins.quot[args.icon]; + var el = '' + const cfg = ctx.theme.config.tag_plugins.quot[args.icon] if (cfg && cfg.prefix) { - el += ''; + el += '' } - el += args.text; + el += args.text if (cfg && cfg.suffix) { - el += ''; + el += '' } - return el; + return el } if (args.el.includes('h')) { el += '' - el += '<' + args.el + ' class="content" id="' + args.text + '"' + type + '>'; - el += ''; - el += content(); - el += ''; + el += '<' + args.el + ' class="content" id="' + args.text + '"' + type + '>' + el += '' + el += content() + el += '' el += '' } else { el += '' - el += '<' + args.el + ' class="content"' + type + '>'; - el += content(); - el += ''; + el += '<' + args.el + ' class="content"' + type + '>' + el += content() + el += '' el += '' } - return el; -}); + return el +} diff --git a/scripts/tags/lib/sites.js b/scripts/tags/lib/sites.js new file mode 100644 index 0000000..2458570 --- /dev/null +++ b/scripts/tags/lib/sites.js @@ -0,0 +1,57 @@ +/** + * sites.js v2 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% sites [group] [repo:owner/repo] [api:http] %} + */ + +'use strict' + +module.exports = ctx => function(args) { + args = ctx.args.map(args, ['repo', 'api'], ['group']) + var links = ctx.locals.get('data').links + if (links == undefined) { + links = {} + } + var api + if (args.api) { + api = args.api + } else if (args.repo) { + api = 'https://api.vlts.cc/output_data/v2/' + args.repo + } + + var el = '
' + if (api) { + el += '
' + cell += '' + cell += '
' + cell += '' + cell += '' + item.title + '' + cell += '' + (item.description || item.url) + '' + cell += '
' + cell += '
' + return cell + } else { + return '' + } + } + el += '
' + const items = links[args.group] || [] + items.forEach((item, i) => { + el += cell(item) + }) + el += '
' + } + + el += '
' + return el +} diff --git a/scripts/tags/lib/swiper.js b/scripts/tags/lib/swiper.js new file mode 100644 index 0000000..e2ffd33 --- /dev/null +++ b/scripts/tags/lib/swiper.js @@ -0,0 +1,38 @@ +/** + * swiper.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% swiper %} + * ![img](src) + * {% endswiper %} + */ + +'use strict' + +module.exports = ctx => function(args, content) { + args = ctx.args.map(args, ['width']) + var el = '' + function slide() { + let imgs = ctx.render.renderSync({text: content, engine: 'markdown'}) + imgs = imgs.match(//gi) + if (imgs && imgs.length > 0) { + imgs.forEach((img, i) => { + img = img.replace('' + }) + } + } + el += '
0) { + el += ' ' + ctx.args.joinTags(args, 'width').join(' ') + } + el += '>' + el += '
' + slide() + el += '
' + el += '
' + el += '
' + el += '
' + el += '
' + return el +} \ No newline at end of file diff --git a/scripts/tags/lib/tabs.js b/scripts/tags/lib/tabs.js index e716ad3..9f4a03c 100644 --- a/scripts/tags/lib/tabs.js +++ b/scripts/tags/lib/tabs.js @@ -2,7 +2,7 @@ * tabs.js v2 | 基于NexT修改: https://theme-next.js.org/docs/tag-plugins/tabs */ -'use strict'; +'use strict' var tab_index = 0 diff --git a/scripts/tags/tag.js b/scripts/tags/lib/tag.js similarity index 58% rename from scripts/tags/tag.js rename to scripts/tags/lib/tag.js index f080178..b5ebc96 100644 --- a/scripts/tags/tag.js +++ b/scripts/tags/lib/tag.js @@ -6,15 +6,15 @@ * */ -'use strict'; +'use strict' const tag_colors = ['red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple'] -var tag_index = 0; +var tag_index = 0 -hexo.extend.tag.register('tag', function(args) { - args = hexo.args.map(args, ['color'], ['text', 'href']); +module.exports = ctx => function(args) { + args = ctx.args.map(args, ['color'], ['text', 'href']) if (args.color == null) { - const default_color = hexo.theme.config.tag_plugins.tag?.default_color + const default_color = ctx.theme.config.tag_plugins.tag?.default_color if (default_color) { args.color = default_color } else { @@ -25,11 +25,11 @@ hexo.extend.tag.register('tag', function(args) { } } } - var el = ''; - el += ' + * what happened 1 + * + * + * what happened 2 + * + * {% endtimeline %} + */ + +'use strict' + +function layoutNodeTitle(ctx, content) { + var el = '' + el += '
' + if (content && content.length > 0) { + el += ctx.render.renderSync({text: content, engine: 'markdown'}).split('\n').join('') + } + el += '
' + return el +} + +function layoutNodeContent(ctx, content) { + var el = '' + el += '
' + if (content && content.length > 0) { + el += ctx.render.renderSync({text: content, engine: 'markdown'}).split('\n').join('') + } + el += '
' + return el +} + +module.exports = ctx => function(args, content = '') { + args = ctx.args.map(args, ['api', 'user', 'type', 'limit', 'hide']) + var el = '' + if (!args.type) { + args.type = 'timeline' + } + if (args.api && args.api.length > 0) { + el += '
/g).filter(item => item.trim().length > 0) + if (arr.length > 0) { + var nodes = [] + arr.forEach((item, i) => { + if (i % 2 == 0) { + nodes.push({ + header: item + }) + } else if (nodes.length > 0) { + var node = nodes[nodes.length-1] + if (node.body == undefined) { + node.body = item + } else { + node.body += '\n' + item + } + } + }) + nodes.forEach((node, i) => { + el += '
' + el += layoutNodeTitle(ctx, node.header) + el += layoutNodeContent(ctx, node.body) + el += '
' + }) + } + + el += '
' + return el +} diff --git a/scripts/tags/lib/toc.js b/scripts/tags/lib/toc.js new file mode 100644 index 0000000..14dba2d --- /dev/null +++ b/scripts/tags/lib/toc.js @@ -0,0 +1,72 @@ +/** + * toc.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% toc wiki:xxx [title] [open:true] [display:mobile] %} + */ + +'use strict' + +function layoutDocTree(pages) { + var el = '' + el += '
' + return el +} + +module.exports = ctx => function(args) { + args = ctx.args.map(args, ['wiki', 'open', 'display'], ['title']) + + var el = '' + el += '
1) { + el += '
' + proj.sections.forEach((sec, i) => { + el += '
' + el += '
' + el += sec.title + el += '
' + el += layoutDocTree(sec.pages) + el += '
' + }) + el += '
' + } else { + el += '
' + el += '
' + el += layoutDocTree(proj.pages) + el += '
' + el += '
' + } + } + el += '' + // end + el += '
' + return el +} \ No newline at end of file diff --git a/scripts/tags/lib/users.js b/scripts/tags/lib/users.js deleted file mode 100644 index 1ebfe20..0000000 --- a/scripts/tags/lib/users.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * users.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ - * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) - * - * {% users api:https://api.github.com/repos/xaoxuu/hexo-theme-stellar/contributors %} - */ - -'use strict'; - -module.exports = ctx => function(args) { - args = ctx.args.map(args, ['api']); - var el = '
'; - - el += '
'; - } else { - el += '
'; - } - return el; - } - function loadTitle() { - return '' + (args.title || args.url) + ''; - } - function loadDesc() { - return ''; - } - function loadLink() { - return '' + full_url_for(args.url) + ''; - } - - if (args.desc) { - // top - el += '
'; - el += loadIcon() + loadLink(); - el += '
'; - // bottom - el += '
'; - el += loadTitle() + loadDesc(); - el += '
'; - } else { - // left - el += '
'; - el += loadTitle() + loadLink(); - el += '
'; - // right - el += '
'; - el += loadIcon(); - el += '
'; - } - - // end - el += '
'; - - return el; -}); diff --git a/scripts/tags/mark.js b/scripts/tags/mark.js deleted file mode 100644 index 7ecc3e2..0000000 --- a/scripts/tags/mark.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * mark.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/ - * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) - * - * {% mark text [color:color] %} - * - */ - -'use strict'; - -hexo.extend.tag.register('mark', function(args) { - args = hexo.args.map(args, ['color'], ['text']); - if (args.color == null) { - args.color = hexo.theme.config.tag_plugins.mark.default_color - } - var el = ''; - el += ' 1) { - text = tmp[0]; - if (text.length > 1) { - text = text.substring(1, text.length); - } - href = tmp[1]; - if (href.length > 1) { - href = href.substring(0, href.length-1); - } - el += ' href="' + href + '"'; - } - } else { - el += ' href="#' + a + '"'; - text = a; - } - el += '>'; - el += text; - el += ''; - return el; - } - (args.links || []).forEach((item, i) => { - el += layoutItem(item, i); - }); - el += ''; - return el; -}); diff --git a/scripts/tags/note.js b/scripts/tags/note.js deleted file mode 100644 index 4265ccc..0000000 --- a/scripts/tags/note.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * note.js v1.1 | https://github.com/xaoxuu/hexo-theme-stellar/ - * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) - * - * {% note [color:color] [title] content %} - */ - -'use strict'; - -hexo.extend.tag.register('note', function(args) { - args = hexo.args.map(args, ['color'], ['title', 'content']); - if (args.content == undefined || args.content.length <= 0) { - args.content = args.title; - args.title = ''; - } - const { title } = args; - if (args.color == null) { - args.color = hexo.theme.config.tag_plugins.note.default_color - } - var el = ''; - // header - el += '
0) { - el += '
' + title + '
'; - } - // content - el += '
'; - el += hexo.render.renderSync({text: args.content, engine: 'markdown'}).split('\n').join(''); - el += '
'; - - return el; -}); diff --git a/scripts/tags/poetry.js b/scripts/tags/poetry.js deleted file mode 100644 index 61979b9..0000000 --- a/scripts/tags/poetry.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * poetry.js v1.1 | https://github.com/xaoxuu/hexo-theme-stellar/ - * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) - * - * poetry: - * {% poetry [title] [author:作者] [date:日期] [footer:footer] %} - * body - * {% endpoetry %} - * - */ - -'use strict'; - -hexo.extend.tag.register('poetry', function(args, content) { - var el = ''; - args = hexo.args.map(args, ['author', 'date', 'footer'], ['title']); - - el += '
'; - } - if (args.date) { - el += '' + args.date + ''; - } - el += '
'; - } - el += '
'; - el += hexo.render.renderSync({text: content, engine: 'markdown'}).split('\n').join(''); - el += '
'; - if (args.footer) { - el += ''; - } - el += '' - el += ''; - return el; -}, {ends: true}); diff --git a/scripts/tags/sites.js b/scripts/tags/sites.js deleted file mode 100644 index 2bd483e..0000000 --- a/scripts/tags/sites.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * sites.js v2 | https://github.com/xaoxuu/hexo-theme-stellar/ - * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) - * - * {% sites [group] [repo:owner/repo] [api:http] %} - */ - -'use strict'; - -hexo.extend.tag.register('sites', function(args) { - args = hexo.args.map(args, ['repo', 'api'], ['group']); - var links = hexo.locals.get('data').links; - if (links == undefined) { - links = {}; - } - var api; - if (args.api) { - api = args.api; - } else if (args.repo) { - api = 'https://api.vlts.cc/output_data/v2/' + args.repo; - } - - var el = '
'; - if (api) { - el += '
'; - cell += ''; - cell += '
'; - cell += ''; - cell += '' + item.title + ''; - cell += '' + (item.description || item.url) + ''; - cell += '
'; - cell += '
' - return cell; - } else { - return ''; - } - } - el += '
'; - const items = links[args.group] || []; - items.forEach((item, i) => { - el += cell(item); - }); - el += '
'; - } - - el += '
'; - return el; -}); diff --git a/scripts/tags/swiper.js b/scripts/tags/swiper.js deleted file mode 100644 index cf547f6..0000000 --- a/scripts/tags/swiper.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * swiper.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ - * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) - * - * {% swiper %} - * ![img](src) - * {% endswiper %} - */ - -'use strict'; - -hexo.extend.tag.register('swiper', function(args, content) { - args = hexo.args.map(args, ['width']); - var el = ''; - function slide() { - let imgs = hexo.render.renderSync({text: content, engine: 'markdown'}); - imgs = imgs.match(//gi); - if (imgs && imgs.length > 0) { - imgs.forEach((img, i) => { - img = img.replace(''; - }); - } - } - el += '
0) { - el += ' ' + hexo.args.joinTags(args, 'width').join(' '); - } - el += '>'; - el += '
'; - slide(); - el += '
'; - el += '
'; - el += '
'; - el += '
'; - el += '
'; - return el; -}, {ends: true}); diff --git a/scripts/tags/timeline.js b/scripts/tags/timeline.js deleted file mode 100644 index 2c362bd..0000000 --- a/scripts/tags/timeline.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * timeline.js v2 | https://github.com/xaoxuu/hexo-theme-stellar/ - * - * {% timeline %} - * - * - * what happened 1 - * - * - * what happened 2 - * - * {% endtimeline %} - */ - -'use strict'; - -function layoutNodeTitle(content) { - var el = ''; - el += '
'; - if (content && content.length > 0) { - el += hexo.render.renderSync({text: content, engine: 'markdown'}).split('\n').join(''); - } - el += '
'; - return el; -} - -function layoutNodeContent(content) { - var el = ''; - el += '
'; - if (content && content.length > 0) { - el += hexo.render.renderSync({text: content, engine: 'markdown'}).split('\n').join(''); - } - el += '
'; - return el; -} - - -function postTimeline(args, content) { - args = hexo.args.map(args, ['api', 'user', 'type', 'limit', 'hide']); - var el = ''; - if (!args.type) { - args.type = 'timeline'; - } - if (args.api && args.api.length > 0) { - el += '
/g).filter(item => item.trim().length > 0) - if (arr.length > 0) { - var nodes = []; - arr.forEach((item, i) => { - if (i % 2 == 0) { - nodes.push({ - header: item - }); - } else if (nodes.length > 0) { - var node = nodes[nodes.length-1]; - if (node.body == undefined) { - node.body = item; - } else { - node.body += '\n' + item; - } - } - }); - nodes.forEach((node, i) => { - el += '
'; - el += layoutNodeTitle(node.header); - el += layoutNodeContent(node.body); - el += '
'; - }); - } - - el += '
'; - return el; -} - -hexo.extend.tag.register('timeline', postTimeline, {ends: true}); diff --git a/scripts/tags/toc.js b/scripts/tags/toc.js deleted file mode 100644 index 91a556f..0000000 --- a/scripts/tags/toc.js +++ /dev/null @@ -1,72 +0,0 @@ -/** - * toc.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ - * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) - * - * {% toc wiki:xxx [title] [open:true] [display:mobile] %} - */ - -'use strict'; - -function layoutDocTree(pages) { - var el = ''; - el += ''; - return el; -} - -hexo.extend.tag.register('toc', function(args) { - args = hexo.args.map(args, ['wiki', 'open', 'display'], ['title']); - - var el = ''; - el += '
1) { - el += '
'; - proj.sections.forEach((sec, i) => { - el += '
'; - el += '
'; - el += sec.title; - el += '
'; - el += layoutDocTree(sec.pages); - el += '
'; - }); - el += '
'; - } else { - el += '
'; - el += '
'; - el += layoutDocTree(proj.pages); - el += '
'; - el += '
'; - } - } - el += ''; - // end - el += '
'; - return el; -});