hexo-theme-keep/layout/_partial/comment/valine.ejs

46 lines
1.8 KiB
Plaintext
Raw Normal View History

2020-04-14 21:18:37 +08:00
<% if(
2020-10-29 15:42:58 +08:00
theme.comment.valine.enable
&& theme.comment.valine.appid
&& theme.comment.valine.appkey
2020-04-14 21:18:37 +08:00
) { %>
2020-04-01 12:09:06 +08:00
<div class="valine-container">
<script src='//unpkg.com/valine/dist/Valine.min.js'></script>
<div id="vcomments"></div>
<script>
const temp_valine_input_meta = '<%= theme.comment.valine.meta %>';
2020-04-01 12:09:06 +08:00
new Valine({
el: '#vcomments',
2020-10-29 15:42:58 +08:00
appId: '<%= theme.comment.valine.appid %>',
appKey: '<%= theme.comment.valine.appkey %>',
meta: temp_valine_input_meta ? temp_valine_input_meta.split(',') : ['nick', 'mail', 'link'],
2020-04-01 12:09:06 +08:00
avatar: 'wavatar',
2020-04-24 22:02:10 +08:00
enableQQ: true,
2020-10-29 15:42:58 +08:00
placeholder: '<%= theme.comment.valine.placeholder %>',
2020-04-14 21:18:37 +08:00
lang: '<%= config.language %>'.toLowerCase()
});
// Add "Author" identify
const getValineDomTimer = setInterval(() => {
const vcards = document.querySelectorAll('#vcomments .vcards .vcard');
if (vcards.length > 0) {
2020-10-28 22:25:26 +08:00
let author = '<%= theme.base_info.author || config.author %>';
if (author) {
author = author.toLocaleLowerCase();
}
for (let vcard of vcards) {
const vnick = vcard.querySelector('.vhead .vnick');
2020-10-28 22:25:26 +08:00
if (vnick.innerHTML.toLocaleLowerCase() === author) {
vcard.classList.add('author');
}
}
clearInterval(getValineDomTimer);
} else {
clearInterval(getValineDomTimer);
}
}, 2000);
2020-04-01 12:09:06 +08:00
</script>
</div>
<% } %>