36 lines
1.2 KiB
Plaintext
36 lines
1.2 KiB
Plaintext
<%
|
|
const { enable: pjax_enable } = theme.pjax
|
|
let {
|
|
env_id: tk_env_id, region: tk_region, version: tk_version
|
|
} = theme.comment.twikoo
|
|
if (!tk_version) { tk_version = '1.6.7' }
|
|
const twikoo_cdn_url = `//cdn.jsdelivr.net/npm/twikoo@${tk_version}/dist/twikoo.all.min.js`
|
|
%>
|
|
<% if(theme.comment.use === 'twikoo' && tk_env_id) { %>
|
|
<div class="twikoo-container">
|
|
<script <%= pjax_enable === true ? 'data-pjax' : '' %>
|
|
src="<%= twikoo_cdn_url %>"
|
|
></script>
|
|
<div id="twikoo-comment"></div>
|
|
<script <%= pjax_enable === true ? 'data-pjax' : '' %>>
|
|
function loadTwikoo() {
|
|
twikoo.init({
|
|
el: '#twikoo-comment',
|
|
envId: '<%= tk_env_id %>',
|
|
region: '<%= tk_region %>',
|
|
lang: '<%= config.language %>' || 'zh-CN'
|
|
});
|
|
}
|
|
|
|
if ('<%= pjax_enable === true %>') {
|
|
const loadTwikooTimeout = setTimeout(() => {
|
|
loadTwikoo();
|
|
clearTimeout(loadTwikooTimeout);
|
|
}, 1000);
|
|
} else {
|
|
window.addEventListener('DOMContentLoaded', loadTwikoo);
|
|
}
|
|
</script>
|
|
</div>
|
|
<% } %>
|