hexo-theme-stellar/layout/_partial/plugins/comments/utterances/script.ejs

26 lines
832 B
Plaintext

<script>
function utterances(){
if(!document.getElementById("utterances"))return;
setTimeout(function() {
var checkUtterances = setInterval(function () {
var el = document.getElementById("utterances");
if (!el) return
clearInterval(checkUtterances)
try {
el.innerHTML="";
} catch (error) {}
var script = document.createElement('script');
script.src = 'https://utteranc.es/client.js';
const keys = ['repo', 'issue-term', 'issue-number', 'theme', 'label', 'crossorigin'];
keys.forEach((key, i) => {
if (el.attributes[key] && el.attributes[key].value) {
script.setAttribute(key, el.attributes[key].value);
}
});
el.appendChild(script);
}, 200)
});
}
utterances();
</script>