parent
59c481b068
commit
6ae0e3a583
|
@ -2,14 +2,27 @@
|
||||||
<noscript>Please enable JavaScript to view the <a href="https://github.com/utterance">comments powered by utterances.</a></noscript>
|
<noscript>Please enable JavaScript to view the <a href="https://github.com/utterance">comments powered by utterances.</a></noscript>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
function checkTheme(local, base) {
|
||||||
|
if (local === "dark" || base === "dark") {
|
||||||
|
return "photon-dark";
|
||||||
|
} else if (local === "hacker" || base === "hacker") {
|
||||||
|
return "photon-dark";
|
||||||
|
} else if (local === "kimbie" || base === "kimbie") {
|
||||||
|
return "github-dark-orange";
|
||||||
|
} else {
|
||||||
|
return "github-light";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
{{ $owner:= .Site.Params.utterances.owner }}
|
{{ $owner:= .Site.Params.utterances.owner }}
|
||||||
var owner = JSON.parse({{ $owner | jsonify }});
|
var owner = JSON.parse({{ $owner | jsonify }});
|
||||||
{{ $repo:= .Site.Params.utterances.repo }}
|
{{ $repo:= .Site.Params.utterances.repo }}
|
||||||
var repo = JSON.parse({{ $repo | jsonify }});
|
var repo = JSON.parse({{ $repo | jsonify }});
|
||||||
|
{{ $baseTheme:= index .Site.Params.themeOptions 0 }}
|
||||||
|
var baseTheme = JSON.parse({{ $baseTheme | jsonify }});
|
||||||
var localTheme = localStorage.getItem('theme');
|
var localTheme = localStorage.getItem('theme');
|
||||||
var utterTheme = localTheme === "dark" || localTheme === "hacker" ? 'photon-dark' : localTheme === 'kimbie' ? 'github-dark-orange' : 'github-light'
|
var utterTheme = checkTheme(localTheme, baseTheme);
|
||||||
|
|
||||||
var myScript = document.createElement('script');
|
var myScript = document.createElement('script');
|
||||||
myScript.setAttribute('src', 'https://utteranc.es/client.js');
|
myScript.setAttribute('src', 'https://utteranc.es/client.js');
|
||||||
myScript.setAttribute('repo', `${owner}/${repo}`);
|
myScript.setAttribute('repo', `${owner}/${repo}`);
|
||||||
|
@ -21,6 +34,8 @@
|
||||||
myScript.onload = function() {
|
myScript.onload = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
document.getElementById('utterances').appendChild(myScript);
|
document.getElementById('utterances').appendChild(myScript);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
|
Loading…
Reference in New Issue