mirror of
https://github.com/davegallant/davegallant.github.io.git
synced 2025-08-06 00:33:39 +00:00
Switch prism and comments theme on changes
This commit is contained in:
@@ -5,25 +5,22 @@
|
||||
.Page.Site.Params.comments.utterances.github.repository -}}
|
||||
|
||||
<script>
|
||||
// load utteranc comment
|
||||
var getTheme = window.localStorage && window.localStorage.getItem("theme");
|
||||
getTheme =
|
||||
getTheme == null
|
||||
? window.matchMedia &&
|
||||
window.matchMedia("(prefers-color-scheme: light)").matches
|
||||
? "light"
|
||||
: "dark"
|
||||
: getTheme;
|
||||
// load comments
|
||||
var getTheme =
|
||||
window.matchMedia &&
|
||||
window.matchMedia("(prefers-color-scheme: light)").matches
|
||||
? "light"
|
||||
: "dark";
|
||||
getTheme = getTheme == null ? "dark" : getTheme;
|
||||
|
||||
let theme = getTheme === "dark" ? "gruvbox-dark" : "github-light";
|
||||
let s = document.createElement("script");
|
||||
s.src = "https://utteranc.es/client.js";
|
||||
s.setAttribute("repo", '{{ print $username "/" $repository }}');
|
||||
s.setAttribute("issue-term", "{{ $issueTerm }}");
|
||||
s.setAttribute("theme", theme);
|
||||
s.setAttribute("crossorigin", "anonymous");
|
||||
s.setAttribute("async", "");
|
||||
let script = document.createElement("script");
|
||||
script.src = "https://utteranc.es/client.js";
|
||||
script.setAttribute("repo", '{{ print $username "/" $repository }}');
|
||||
script.setAttribute("issue-term", "{{ $issueTerm }}");
|
||||
script.setAttribute("theme", theme);
|
||||
script.setAttribute("crossorigin", "anonymous");
|
||||
script.setAttribute("async", "");
|
||||
document.querySelector("div.comments").innerHTML = "";
|
||||
document.querySelector("div.comments").appendChild(s);
|
||||
document.querySelector("div.comments").appendChild(script);
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user