2022-09-25 13:36:55 +08:00
|
|
|
<%
|
2022-10-13 22:51:32 +08:00
|
|
|
const {enable: pjax_enable} = theme.pjax
|
2022-09-25 13:36:55 +08:00
|
|
|
let {
|
2022-10-13 22:51:32 +08:00
|
|
|
env_id: tk_env_id, region: tk_region, version: tk_version
|
2022-09-25 13:36:55 +08:00
|
|
|
} = theme.comment.twikoo
|
2022-10-13 22:51:32 +08:00
|
|
|
if (!tk_version) {
|
|
|
|
tk_version = '1.6.7'
|
|
|
|
}
|
2022-09-25 13:36:55 +08:00
|
|
|
const twikoo_cdn_url = `//cdn.jsdelivr.net/npm/twikoo@${tk_version}/dist/twikoo.all.min.js`
|
|
|
|
%>
|
|
|
|
<% if(theme.comment.use === 'twikoo' && tk_env_id) { %>
|
2021-01-15 16:18:02 +08:00
|
|
|
<div class="twikoo-container">
|
2022-09-25 13:36:55 +08:00
|
|
|
<script <%= pjax_enable === true ? 'data-pjax' : '' %>
|
|
|
|
src="<%= twikoo_cdn_url %>"
|
2021-01-15 16:18:02 +08:00
|
|
|
></script>
|
|
|
|
<div id="twikoo-comment"></div>
|
2022-09-25 13:36:55 +08:00
|
|
|
<script <%= pjax_enable === true ? 'data-pjax' : '' %>>
|
2022-10-13 22:51:32 +08:00
|
|
|
function loadTwikoo() {
|
|
|
|
twikoo.init({
|
|
|
|
el: '#twikoo-comment',
|
|
|
|
envId: '<%= tk_env_id %>',
|
|
|
|
region: '<%= tk_region %>',
|
|
|
|
lang: '<%= config.language %>' || 'zh-CN'
|
|
|
|
});
|
|
|
|
}
|
2021-01-15 16:18:02 +08:00
|
|
|
|
2022-10-13 22:51:32 +08:00
|
|
|
if ('<%= pjax_enable %>' === 'true') {
|
|
|
|
const loadTwikooTimeout = setTimeout(() => {
|
|
|
|
loadTwikoo();
|
|
|
|
clearTimeout(loadTwikooTimeout);
|
|
|
|
}, 1000);
|
|
|
|
} else {
|
|
|
|
window.addEventListener('DOMContentLoaded', loadTwikoo);
|
|
|
|
}
|
2021-01-15 16:18:02 +08:00
|
|
|
</script>
|
|
|
|
</div>
|
|
|
|
<% } %>
|