diff --git a/_config.yml b/_config.yml index 5280097..33e06bd 100755 --- a/_config.yml +++ b/_config.yml @@ -304,6 +304,9 @@ tag_plugins: aru: https://gcore.jsdelivr.net/gh/cdn-x/emoji/aru-l/${name}.gif tieba: https://gcore.jsdelivr.net/gh/cdn-x/emoji/tieba/${name}.png blobcat: https://gcore.jsdelivr.net/gh/norevi/waline-blobcatemojis@1.0/blobs/${name}.png + icon: + # 留空时,图标和文字颜色相同 + default_color: accent # theme, accent, red, orange, yellow, green, cyan, blue, purple # {% image %} image: fancybox: false # true, false diff --git a/scripts/tags/index.js b/scripts/tags/index.js index 658461a..07baf54 100644 --- a/scripts/tags/index.js +++ b/scripts/tags/index.js @@ -29,6 +29,7 @@ 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('icon', require('./lib/icon')(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)) diff --git a/scripts/tags/lib/icon.js b/scripts/tags/lib/icon.js new file mode 100644 index 0000000..a0a7d9e --- /dev/null +++ b/scripts/tags/lib/icon.js @@ -0,0 +1,27 @@ +/** + * icon.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% icon key [color:color] [style:css] %} + * + */ + +'use strict' + +module.exports = ctx => function(args) { + args = ctx.args.map(args, ['color', 'style'], ['key']) + if (args.color == null) { + args.color = ctx.theme.config.tag_plugins.icon.default_color + } + var el = '' + el += '