From 8394f815100a882aa8bb156bfb8765f74d39ba0c Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Mon, 2 Aug 2021 16:25:27 +0800 Subject: [PATCH] emoji --- _config.yml | 6 ++++ scripts/tags/emoji.js | 40 +++++++++++++++++++++++ source/css/_layout/tag-plugins/emoji.styl | 8 +++++ 3 files changed, 54 insertions(+) create mode 100644 scripts/tags/emoji.js create mode 100644 source/css/_layout/tag-plugins/emoji.styl diff --git a/_config.yml b/_config.yml index 7d53ce1..a63887a 100755 --- a/_config.yml +++ b/_config.yml @@ -168,6 +168,12 @@ tag_plugins: # {% checkbox %} checkbox: interactive: false # enable interactive for user + emoji: + default: https://cdn.jsdelivr.net/gh/volantis-x/cdn-emoji/qq/%s.gif + twemoji: https://cdn.jsdelivr.net/gh/twitter/twemoji/assets/svg/%s.svg + qq: https://cdn.jsdelivr.net/gh/volantis-x/cdn-emoji/qq/%s.gif + aru: https://cdn.jsdelivr.net/gh/volantis-x/cdn-emoji/aru-l/%s.gif + tieba: https://cdn.jsdelivr.net/gh/volantis-x/cdn-emoji/tieba/%s.png ######## JS Plugins ######## diff --git a/scripts/tags/emoji.js b/scripts/tags/emoji.js new file mode 100644 index 0000000..d98c183 --- /dev/null +++ b/scripts/tags/emoji.js @@ -0,0 +1,40 @@ +/** + * emoji.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/ + * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来) + * + * {% emoji [source] name [height:1.75em] %} + * + */ + +'use strict'; + +hexo.extend.tag.register('emoji', function(args) { + const config = hexo.theme.config.tag_plugins.emoji; + args = hexo.args.map(args, ['height'], ['source', 'name']); + var el = ''; + if (args.source == undefined) { + return el; + } + el += ''; + if (args.name == undefined) { + // 省略了 source + for (let id in config) { + if (config[id]) { + args.name = args.source; + args.source = id; + break; + } + } + } + if (config[args.source] && args.name) { + let url = config[args.source].replace('%s', args.name); + el += '