child tag

This commit is contained in:
xaoxuu 2021-07-14 00:03:28 +08:00
parent 8bb5c09d71
commit f37326822c
4 changed files with 15 additions and 14 deletions

View File

@ -2,7 +2,7 @@
* folding.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ * folding.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
* 格式与官方标签插件一致使用空格分隔中括号内的是可选参数中括号不需要写出来 * 格式与官方标签插件一致使用空格分隔中括号内的是可选参数中括号不需要写出来
* *
* {% folding [color:yellow] [codeblock:false] [open:false] title %} * {% folding [color:yellow] [child:codeblock] [open:false] title %}
* body * body
* {% endtable %} * {% endtable %}
*/ */
@ -10,11 +10,11 @@
'use strict'; 'use strict';
hexo.extend.tag.register('folding', function(args, content) { hexo.extend.tag.register('folding', function(args, content) {
args = hexo.args.map(args, ['color', 'codeblock', 'open'], ['title']); args = hexo.args.map(args, ['color', 'child', 'open'], ['title']);
var el = ''; var el = '';
// header // header
el += '<details class="tag-plugin folding"' el += '<details class="tag-plugin folding"';
el += ' ' + hexo.args.joinTags(args, ['color', 'codeblock']).join(' '); el += ' ' + hexo.args.joinTags(args, ['color', 'child']).join(' ');
if (args.open && args.open == 'true') { if (args.open && args.open == 'true') {
el += ' open'; el += ' open';
} }

View File

@ -6,7 +6,7 @@
* {% note [color:color] [title] content %} * {% note [color:color] [title] content %}
* *
* noteblock: * noteblock:
* {% noteblock [color:color] [codeblock:bool] title %} * {% noteblock [color:color] [child:codeblock/tabs] title %}
* markdown content * markdown content
* {% endnoteblock %} * {% endnoteblock %}
*/ */
@ -23,12 +23,7 @@ function outputNoteBlock(args, content) {
} }
// header // header
el += '<div class="tag-plugin note"'; el += '<div class="tag-plugin note"';
if (color && color.length > 0) { el += ' ' + hexo.args.joinTags(args, ['color', 'child']).join(' ');
el += ' color="' + color + '"';
}
if (args.codeblock !== undefined) {
el += ' codeblock="' + args.codeblock + '"';
}
el += '>'; el += '>';
// title // title
if (title && title.length > 0) { if (title && title.length > 0) {
@ -52,6 +47,6 @@ hexo.extend.tag.register('note', function(args) {
}); });
hexo.extend.tag.register('noteblock', function(args, content) { hexo.extend.tag.register('noteblock', function(args, content) {
args = hexo.args.map(args, ['color', 'codeblock'], ['title']); args = hexo.args.map(args, ['color', 'child'], ['title']);
return outputNoteBlock(args, content); return outputNoteBlock(args, content);
}, {ends: true}); }, {ends: true});

View File

@ -55,7 +55,7 @@ details[open]
>:last-child >:last-child
margin-bottom: 0 margin-bottom: 0
details[codeblock]>div.body details[child=codeblock]>div.body
padding: 0 padding: 0
background: transparent background: transparent
.highlight .highlight

View File

@ -25,7 +25,7 @@
.md .tag-plugin.note:not([color]) .md .tag-plugin.note:not([color])
.highlight .highlight
background: var(--block-hover) background: var(--block-hover)
.md .tag-plugin.note[codeblock=true] .md .tag-plugin.note[child=codeblock]
padding: 0 padding: 0
>.title, >.body:only-child >.title, >.body:only-child
margin-top: 0 margin-top: 0
@ -35,3 +35,9 @@
margin: 0 margin: 0
border: none border: none
background: none background: none
.md .tag-plugin.note[child=tabs]
>.body
margin: 0
>.tabs
margin-top: .5rem