Fixed Giscus initial light/dark mode handling (#4059)

Inconsistency of theme used when page first loaded.
This commit is contained in:
William 2022-06-26 16:43:33 +08:00 committed by GitHub
parent d524af2910
commit 98e351a299
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,10 +64,9 @@ calling the `super()` function at the beginning of the block:
<!-- Reload on palette change -->
<script>
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object")
if (palette.color.scheme === "slate") {
if (palette && typeof palette.color === "object") {
var giscus = document.querySelector("script[src*=giscus]")
giscus.setAttribute("data-theme", "dark") // (1)!
giscus.setAttribute("data-theme", palette.color.scheme === "slate" ? "dark" : "light") // (1)!
}
/* Register event handlers after documented loaded */