diff --git a/docs/zh-CN/advanced/assist.md b/docs/zh-CN/advanced/assist.md index 563d2b7f6d7bf9c5e2ddddff4f9f8ed42f380fa5..47096dfa81749d7e7053f004dd3db18e1141b360 100644 --- a/docs/zh-CN/advanced/assist.md +++ b/docs/zh-CN/advanced/assist.md @@ -86,3 +86,37 @@ Hexo 主题一般都会扩展一些自己特有的标签插件,在这方面做 3. 重启 Hexo 服务器,效果如下。 ![](https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190802171506.png) + +### Bootstrap 标注 + +语法如下: + +``` +{% note [type] [no-icon] %} +**header text** + +any text +{% endnote %} +``` + +> 标签内可以是任意文字,支持 markdown 和 HTML 语法。 + +参数: + +`[type]`:标注类型 + +`[no-icon]`:是否显示 ICON + +举例: + +``` +{% note success %} +**Success** + +This is success note. +{% endnote %} +``` + +全部效果如下: + +![](https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190802221712.png) diff --git a/scripts/tags/note.js b/scripts/tags/note.js new file mode 100644 index 0000000000000000000000000000000000000000..99d917b1e3209eedae12e564a02aec34804c9ff9 --- /dev/null +++ b/scripts/tags/note.js @@ -0,0 +1,14 @@ +/* global hexo */ + +'use strict'; + +function note(args, content) { + return `
+ ${hexo.render + .renderSync({ text: content, engine: 'markdown' }) + .split('\n') + .join('')} +
`; +} + +hexo.extend.tag.register('note', note, { ends: true }); diff --git a/source/css/_components/index.styl b/source/css/_components/index.styl index d208f23b8fe2e67b2342a090b4b2e04d21776185..14e792cdb83080bf6edf7634e2715a13a8905cfb 100644 --- a/source/css/_components/index.styl +++ b/source/css/_components/index.styl @@ -11,3 +11,4 @@ @import './copy.styl' @import './analytics/index.styl' @import './search/index.styl' +@import './tag-plugin/index.styl' diff --git a/source/css/_components/tag-plugin/index.styl b/source/css/_components/tag-plugin/index.styl new file mode 100644 index 0000000000000000000000000000000000000000..3cce3fd95b4ad326b44ac27b13c437aca1e2e511 --- /dev/null +++ b/source/css/_components/tag-plugin/index.styl @@ -0,0 +1 @@ +@import './note.styl' diff --git a/source/css/_components/tag-plugin/note.styl b/source/css/_components/tag-plugin/note.styl new file mode 100644 index 0000000000000000000000000000000000000000..8b2412102fbc3e1fba41d9f1d9b6cb91764ab059 --- /dev/null +++ b/source/css/_components/tag-plugin/note.styl @@ -0,0 +1,63 @@ +.note-plugin + position: relative + margin: 1rem 0 + border: 1px solid #eee + border-left-width: .35rem + padding: 0 1rem + line-height: 1.7em + + &:not(.no-icon) + padding-left: 2rem + + &::before + position: absolute + top: .8em + left: .6rem + font-family: 'FontAwesome' + font-size: $font-size-base + 6px + + &.default::before + content: '\f0a9' + color: #777 + + &.success::before + content: '\f058' + color: #5cb85c + + &.warning::before + content: '\f06a' + color: #f0ad4e + + &.danger::before + content: '\f056' + color: #d9534f + + &.default + border-left-color: #777 + + strong + color: #777 + + &.success + border-left-color: #5cb85c + + strong + color: #5cb85c + + &.warning + border-left-color: #f0ad4e + + strong + color: #f0ad4e + + &.danger + border-left-color: #d9534f + + strong + color: #d9534f + + h1, h2, h3, h4, h5, h6 + margin: 0 + + strong + font-size: $font-size-base + 6px