feat(twikoo comment): custom seting twikoo version
This commit is contained in:
parent
a497c3abd5
commit
426df41623
|
@ -203,7 +203,8 @@ comment:
|
||||||
# See: https://github.com/imaegoo/twikoo
|
# See: https://github.com/imaegoo/twikoo
|
||||||
twikoo:
|
twikoo:
|
||||||
env_id: # Tencent Cloud environment id
|
env_id: # Tencent Cloud environment id
|
||||||
region: # environment region. If select Guangzhou, fill in "ap-guangzhou".
|
region: # Environment region. If select Guangzhou, fill in "ap-guangzhou".
|
||||||
|
version: 1.6.7 # Twikoo version, default use v1.6.7, you can custom fill
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
# RSS
|
# RSS
|
||||||
|
|
|
@ -1,19 +1,28 @@
|
||||||
<% if(theme.comment.use === 'twikoo' && theme.comment.twikoo.env_id) { %>
|
<%
|
||||||
|
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">
|
<div class="twikoo-container">
|
||||||
<script <%= theme.pjax.enable === true ? 'data-pjax' : '' %>
|
<script <%= pjax_enable === true ? 'data-pjax' : '' %>
|
||||||
src="//cdn.jsdelivr.net/npm/twikoo@1.4.1/dist/twikoo.all.min.js"
|
src="<%= twikoo_cdn_url %>"
|
||||||
></script>
|
></script>
|
||||||
<div id="twikoo-comment"></div>
|
<div id="twikoo-comment"></div>
|
||||||
<script <%= theme.pjax.enable === true ? 'data-pjax' : '' %>>
|
<script <%= pjax_enable === true ? 'data-pjax' : '' %>>
|
||||||
function loadTwikoo() {
|
function loadTwikoo() {
|
||||||
twikoo.init({
|
twikoo.init({
|
||||||
el: '#twikoo-comment',
|
el: '#twikoo-comment',
|
||||||
envId: '<%= theme.comment.twikoo.env_id %>',
|
envId: '<%= tk_env_id %>',
|
||||||
region: '<%= theme.comment.twikoo.region %>',
|
region: '<%= tk_region %>',
|
||||||
|
lang: '<%= config.language %>' || 'zh-CN'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('<%= theme.pjax.enable %>') {
|
if ('<%= pjax_enable === true %>') {
|
||||||
const loadTwikooTimeout = setTimeout(() => {
|
const loadTwikooTimeout = setTimeout(() => {
|
||||||
loadTwikoo();
|
loadTwikoo();
|
||||||
clearTimeout(loadTwikooTimeout);
|
clearTimeout(loadTwikooTimeout);
|
||||||
|
|
Loading…
Reference in New Issue