hexo-theme-stellar/layout/_partial/plugins/comments/valine/script.ejs

42 lines
1.3 KiB
Plaintext
Raw Normal View History

2021-03-13 22:30:07 +08:00
<%- js(theme.comments.valine.js) %>
<script>
function emoji(path, idx, ext) {
return path + "/" + path + "-" + idx + "." + ext;
}
var emojiMaps = {};
for (var i = 1; i <= 54; i++) {
emojiMaps['tieba-' + i] = emoji('tieba', i, 'png');
}
for (var i = 1; i <= 101; i++) {
emojiMaps['qq-' + i] = emoji('qq', i, 'gif');
}
for (var i = 1; i <= 116; i++) {
emojiMaps['aru-' + i] = emoji('aru', i, 'gif');
}
for (var i = 1; i <= 125; i++) {
emojiMaps['twemoji-' + i] = emoji('twemoji', i, 'png');
}
for (var i = 1; i <= 4; i++) {
emojiMaps['weibo-' + i] = emoji('weibo', i, 'png');
}
function load_comment(){
if(!document.getElementById("valine_container"))return;
const el = document.getElementById("valine_container");
var path = el.getAttribute('comment_id');
const placeholder = "<%= theme.comments.valine.placeholder %>";
if (!path) {
path = decodeURI(window.location.pathname);
}
var valine = new Valine();
valine.init(Object.assign(<%- JSON.stringify(theme.comments.valine) %>, {
el: '#valine_container',
path: path,
placeholder: placeholder,
emojiCDN: 'https://cdn.jsdelivr.net/gh/volantis-x/cdn-emoji/valine/',
emojiMaps: emojiMaps,
}));
}
load_comment();
</script>