diff --git a/scripts/tags/grid.js b/scripts/tags/grid.js new file mode 100644 index 0000000..ecd8b46 --- /dev/null +++ b/scripts/tags/grid.js @@ -0,0 +1,35 @@ +/** + * grid.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% grid [color:color] [child:codeblock/tabs] title %} + * body + * {% endgrid %} + */ + +'use strict'; + +hexo.extend.tag.register('grid', function(args, content) { + args = hexo.args.map(args, ['color', 'child'], ['title']); + const color = args.color; + const title = args.title; + var el = ''; + const defaultColor = hexo.theme.config.tag_plugins.note.default_color; + if (!color && defaultColor) { + color = defaultColor; + } + // 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/note.js b/scripts/tags/note.js index 9f924b2..a649801 100644 --- a/scripts/tags/note.js +++ b/scripts/tags/note.js @@ -2,18 +2,17 @@ * note.js v1.1 | https://github.com/xaoxuu/hexo-theme-stellar/ * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) * - * note: * {% note [color:color] [title] content %} - * - * noteblock: - * {% noteblock [color:color] [child:codeblock/tabs] title %} - * markdown content - * {% endnoteblock %} */ 'use strict'; -function outputNoteBlock(args, content) { +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 color = args.color; const title = args.title; var el = ''; @@ -31,22 +30,8 @@ function outputNoteBlock(args, content) { } // content el += '
'; - el += hexo.render.renderSync({text: content, engine: 'markdown'}).split('\n').join(''); + el += hexo.render.renderSync({text: args.content, engine: 'markdown'}).split('\n').join(''); el += '
'; return el; -} - -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 = ''; - } - return outputNoteBlock(args, args.content); }); - -hexo.extend.tag.register('noteblock', function(args, content) { - args = hexo.args.map(args, ['color', 'child'], ['title']); - return outputNoteBlock(args, content); -}, {ends: true}); diff --git a/scripts/tags/site.js b/scripts/tags/sites.js similarity index 96% rename from scripts/tags/site.js rename to scripts/tags/sites.js index 9fe4acd..edb6f8f 100644 --- a/scripts/tags/site.js +++ b/scripts/tags/sites.js @@ -62,6 +62,9 @@ hexo.extend.tag.register('sites', function(args) { } if (groupId in sites) { let group = sites[groupId]; + if ((typeof group == 'object') && group.constructor == Array) { + group = {items: group}; + } if (group.title || group.description) { el += groupHeader(group); } diff --git a/source/css/_layout/tag-plugins/inline-labels.styl b/source/css/_layout/tag-plugins/inline-labels.styl index 68d7baa..c630165 100644 --- a/source/css/_layout/tag-plugins/inline-labels.styl +++ b/source/css/_layout/tag-plugins/inline-labels.styl @@ -32,3 +32,6 @@ line-height: 1 font-weight: 700 font-family: $ff-code + h1,h2,h3,h4 + sup,sub + font-size: .85rem