2020-04-14 21:18:37 +08:00
|
|
|
<% if(
|
2021-01-28 17:44:01 +08:00
|
|
|
theme.comment.use === 'valine'
|
2020-10-29 15:42:58 +08:00
|
|
|
&& 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">
|
2020-12-30 18:11:46 +08:00
|
|
|
<script <%= theme.pjax.enable === true ? 'data-pjax' : '' %>
|
|
|
|
src="//cdn.jsdelivr.net/npm/valine@latest/dist/Valine.min.js"></script>
|
2020-04-01 12:09:06 +08:00
|
|
|
<div id="vcomments"></div>
|
2020-12-30 18:11:46 +08:00
|
|
|
<script <%= theme.pjax.enable === true ? 'data-pjax' : '' %>>
|
|
|
|
function loadValine() {
|
|
|
|
new Valine({
|
|
|
|
el: '#vcomments',
|
|
|
|
appId: '<%= theme.comment.valine.appid %>',
|
|
|
|
appKey: '<%= theme.comment.valine.appkey %>',
|
2021-01-05 17:05:14 +08:00
|
|
|
meta: ['nick', 'mail', 'link'],
|
2020-12-30 18:11:46 +08:00
|
|
|
avatar: 'wavatar',
|
|
|
|
enableQQ: true,
|
|
|
|
placeholder: '<%= theme.comment.valine.placeholder %>',
|
|
|
|
lang: '<%= config.language %>'.toLowerCase()
|
|
|
|
});
|
2020-10-28 22:25:26 +08:00
|
|
|
|
2021-01-15 16:57:20 +08:00
|
|
|
function getAuthor(language) {
|
|
|
|
switch (language) {
|
|
|
|
case 'en':
|
|
|
|
return 'Author';
|
|
|
|
case 'zh-CN':
|
|
|
|
return '博主';
|
|
|
|
default:
|
|
|
|
return 'Master';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-30 18:11:46 +08:00
|
|
|
// Add "Author" identify
|
|
|
|
const getValineDomTimer = setInterval(() => {
|
|
|
|
const vcards = document.querySelectorAll('#vcomments .vcards .vcard');
|
|
|
|
if (vcards.length > 0) {
|
|
|
|
let author = '<%= theme.base_info.author || config.author %>';
|
2020-10-28 22:25:26 +08:00
|
|
|
|
2021-01-26 09:34:31 +08:00
|
|
|
if (author) {
|
|
|
|
for (let vcard of vcards) {
|
|
|
|
const vnick_dom = vcard.querySelector('.vhead .vnick');
|
|
|
|
const vnick = vnick_dom.innerHTML;
|
|
|
|
if (vnick === author) {
|
|
|
|
vnick_dom.innerHTML = `${vnick} <span class="author">${getAuthor(KEEP.hexo_config.language)}</span>`
|
|
|
|
}
|
2020-12-30 18:11:46 +08:00
|
|
|
}
|
2020-07-22 17:08:07 +08:00
|
|
|
}
|
2020-12-30 18:11:46 +08:00
|
|
|
clearInterval(getValineDomTimer);
|
|
|
|
} else {
|
|
|
|
clearInterval(getValineDomTimer);
|
2020-07-22 17:08:07 +08:00
|
|
|
}
|
2020-12-30 18:11:46 +08:00
|
|
|
}, 2000);
|
|
|
|
}
|
|
|
|
|
2022-10-13 22:51:32 +08:00
|
|
|
if ('<%= theme.pjax.enable %>' === 'true') {
|
2020-12-30 18:11:46 +08:00
|
|
|
const loadValineTimeout = setTimeout(() => {
|
|
|
|
loadValine();
|
|
|
|
clearTimeout(loadValineTimeout);
|
|
|
|
}, 1000);
|
|
|
|
} else {
|
|
|
|
window.addEventListener('DOMContentLoaded', loadValine);
|
|
|
|
}
|
2020-04-01 12:09:06 +08:00
|
|
|
</script>
|
|
|
|
</div>
|
|
|
|
<% } %>
|