2021-02-21 13:44:11 +08:00
|
|
|
<%
|
|
|
|
if (page.utterances == undefined) {
|
|
|
|
page.utterances = theme.comments.utterances;
|
|
|
|
} else {
|
|
|
|
for (let key of Object.keys(theme.comments.utterances)) {
|
|
|
|
if (page.utterances[key] == undefined) {
|
|
|
|
page.utterances[key] = theme.comments.utterances[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%>
|
2021-02-19 23:33:19 +08:00
|
|
|
<script>
|
|
|
|
function pjax_utterances(){
|
|
|
|
if(!document.getElementById("utterances"))return;
|
|
|
|
setTimeout(function() {
|
|
|
|
var checkUtterances = setInterval(function () {
|
|
|
|
var HEAD = document.getElementById("utterances");
|
|
|
|
if (!HEAD) return
|
|
|
|
clearInterval(checkUtterances)
|
|
|
|
try {
|
|
|
|
HEAD.innerHTML="";
|
|
|
|
} catch (error) {}
|
|
|
|
var script = document.createElement('script');
|
|
|
|
script.setAttribute('src','https://utteranc.es/client.js');
|
2021-02-21 13:44:11 +08:00
|
|
|
script.setAttribute('repo','<%- page.utterances.repo %>');
|
|
|
|
let issuenumber = '<%- page.utterances['issue-number'] || page.comment_id %>';
|
2021-02-19 23:33:19 +08:00
|
|
|
if (issuenumber) {
|
|
|
|
script.setAttribute('issue-term', issuenumber);
|
|
|
|
} else {
|
2021-02-21 13:44:11 +08:00
|
|
|
script.setAttribute('issue-term', '<%- page.utterances['issue-term'] %>');
|
2021-02-19 23:33:19 +08:00
|
|
|
}
|
2021-02-21 13:44:11 +08:00
|
|
|
script.setAttribute('theme', '<%- page.dark ? page.utterances.theme.dark : page.utterances.theme.light %>' );
|
|
|
|
script.setAttribute('label','<%- page.utterances.label %>');
|
|
|
|
script.setAttribute('crossorigin','<%- page.utterances.crossorigin %>');
|
2021-02-19 23:33:19 +08:00
|
|
|
HEAD.appendChild(script);
|
|
|
|
}, 200)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
pjax_utterances();
|
|
|
|
</script>
|