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

51 lines
1.9 KiB
Plaintext
Raw Normal View History

2020-04-14 21:18:37 +08:00
<% if(
theme.comments.valine.enable
&& theme.comments.valine.appid
&& theme.comments.valine.appkey
) { %>
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>
new Valine({
el: '#vcomments',
appId: '<%= theme.comments.valine.appid %>',
appKey: '<%= theme.comments.valine.appkey %>',
2020-04-28 23:20:17 +08:00
meta: '<%= theme.comments.valine.meta %>'.split(','),
2020-04-01 12:09:06 +08:00
avatar: 'wavatar',
2020-04-24 22:02:10 +08:00
enableQQ: true,
placeholder: '<%= theme.comments.valine.placeholder %>',
2020-04-14 21:18:37 +08:00
lang: '<%= config.language %>'.toLowerCase()
});
2020-10-28 22:25:26 +08:00
// Valine 评论列表增加"博主"标识
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();
}
let email = '<%= theme.base_info.email %>';
if (email) {
email = email.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>
<% } %>