mirror of
https://github.com/davegallant/davegallant.github.io.git
synced 2025-08-05 08:13:40 +00:00
28 lines
1.1 KiB
HTML
28 lines
1.1 KiB
HTML
{{- $scriptSrc := "https://utteranc.es/client.js" -}} {{- $issueTerm :=
|
|
.Page.Site.Params.comments.utterances.issueTerm -}} {{- $label :=
|
|
.Page.Site.Params.comments.utterances.label -}} {{- $username :=
|
|
.Page.Site.Params.comments.utterances.github.username -}} {{- $repository :=
|
|
.Page.Site.Params.comments.utterances.github.repository -}}
|
|
|
|
<script>
|
|
// load comments
|
|
var getTheme =
|
|
(localStorage && localStorage.getItem("theme")) ||
|
|
(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 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(script);
|
|
</script>
|