hugo-theme-zzo/layouts/partials/comments/utterances.html

30 lines
1.2 KiB
HTML

<div id="utterances"></div>
<noscript>Please enable JavaScript to view the <a href="https://github.com/utterance">comments powered by utterances.</a></noscript>
<script>
document.addEventListener('DOMContentLoaded', function () {
try {
{{ $owner:= .Site.Params.utterances.owner }}
var owner = JSON.parse({{ $owner | jsonify }});
{{ $repo:= .Site.Params.utterances.repo }}
var repo = JSON.parse({{ $repo | jsonify }});
var localTheme = localStorage.getItem('theme');
var utterTheme = localTheme === "dark" || localTheme === "hacker" ? 'photon-dark' : localTheme === 'kimbie' ? 'github-dark-orange' : 'github-light'
var myScript = document.createElement('script');
myScript.setAttribute('src', 'https://utteranc.es/client.js');
myScript.setAttribute('repo', `${owner}/${repo}`);
myScript.setAttribute('issue-term', 'pathname');
myScript.setAttribute('theme', utterTheme);
myScript.setAttribute('crossorigin', 'anonymous');
myScript.setAttribute('async', '');
myScript.onload = function() {
}
document.getElementById('utterances').appendChild(myScript);
} catch (err) {
console.log(err);
}
});
</script>