note
This commit is contained in:
parent
487216e888
commit
c753b3dfbc
|
@ -1,19 +1,21 @@
|
|||
/**
|
||||
* note.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
|
||||
* note.js v1.1 | https://github.com/xaoxuu/hexo-theme-stellar/
|
||||
* 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
|
||||
*
|
||||
* note:
|
||||
* {% note [color:color] [title] content %}
|
||||
*
|
||||
* noteblock:
|
||||
* {% noteblock [color:color] title %}
|
||||
* {% noteblock [color:color] [codeblock:bool] title %}
|
||||
* markdown content
|
||||
* {% endnoteblock %}
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
function outputNoteBlock(color, title, content) {
|
||||
function outputNoteBlock(args, content) {
|
||||
const color = args.color;
|
||||
const title = args.title;
|
||||
var el = '';
|
||||
const defaultColor = hexo.theme.config.tag_plugins.note.default_color;
|
||||
if (!color && defaultColor) {
|
||||
|
@ -24,6 +26,9 @@ function outputNoteBlock(color, title, content) {
|
|||
if (color && color.length > 0) {
|
||||
el += ' color="' + color + '"';
|
||||
}
|
||||
if (args.codeblock !== undefined) {
|
||||
el += ' codeblock="' + args.codeblock + '"';
|
||||
}
|
||||
el += '>';
|
||||
// title
|
||||
if (title && title.length > 0) {
|
||||
|
@ -39,14 +44,14 @@ function outputNoteBlock(color, title, content) {
|
|||
|
||||
hexo.extend.tag.register('note', function(args) {
|
||||
args = hexo.args.map(args, ['color'], ['title', 'content']);
|
||||
if (args.content) {
|
||||
return outputNoteBlock(args.color, args.title, args.content);
|
||||
} else {
|
||||
return outputNoteBlock(args.color, '', args.title);
|
||||
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'], ['title']);
|
||||
return outputNoteBlock(args.color, args.title, content);
|
||||
args = hexo.args.map(args, ['color', 'codeblock'], ['title']);
|
||||
return outputNoteBlock(args, content);
|
||||
}, {ends: true});
|
||||
|
|
|
@ -1,20 +1,37 @@
|
|||
.md div.note
|
||||
.md .tag-plugin.note
|
||||
$border-block = 4px
|
||||
position: relative
|
||||
margin-top: 1rem
|
||||
margin-bottom: 1rem
|
||||
padding: 1rem
|
||||
padding: 0 1rem
|
||||
border-radius: $border-block
|
||||
font-size: $fs-15
|
||||
background: var(--theme-bg)
|
||||
border: 1px solid var(--theme)
|
||||
color: var(--text-p1)
|
||||
div.title
|
||||
>.title
|
||||
inside-box: $fs-15
|
||||
margin-bottom: 0.5rem
|
||||
div.body
|
||||
line-height: 1.2
|
||||
margin-top: 1rem
|
||||
>.body
|
||||
inside-box: $fs-14
|
||||
line-height: 1.5
|
||||
margin-top: .5rem
|
||||
margin-bottom: 1rem
|
||||
>.body:only-child
|
||||
margin: 1rem 0
|
||||
|
||||
.md div.note:not([color])
|
||||
|
||||
.md .tag-plugin.note:not([color])
|
||||
.highlight
|
||||
background: var(--block-hover)
|
||||
.md .tag-plugin.note[codeblock=true]
|
||||
padding: 0
|
||||
>.title, >.body:only-child
|
||||
margin-top: 0
|
||||
>.body
|
||||
margin-bottom: 0
|
||||
.highlight
|
||||
margin: 0
|
||||
border: none
|
||||
background: none
|
||||
|
|
Loading…
Reference in New Issue