emoji
This commit is contained in:
parent
23ece92e91
commit
8394f81510
|
@ -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 ########
|
||||
|
|
|
@ -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 += '<span class="tag-plugin emoji">';
|
||||
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 += '<img no-lazy="" class="inline"';
|
||||
el += ' src="' + url + '"';
|
||||
if (args.height) {
|
||||
el += ' style="height:' + args.height + '"';
|
||||
}
|
||||
el += '/>';
|
||||
}
|
||||
el += '</span>';
|
||||
return el;
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
.md .tag-plugin.emoji
|
||||
display: inline-block
|
||||
margin: -4px 2px 0
|
||||
vertical-align: middle
|
||||
img
|
||||
display: block
|
||||
object-fit: contain
|
||||
height: 1.75em
|
Loading…
Reference in New Issue