mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed Giscus initial light/dark mode handling (#4059)
Inconsistency of theme used when page first loaded.
This commit is contained in:
parent
d524af2910
commit
98e351a299
@ -64,12 +64,11 @@ 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 */
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
var ref = document.querySelector("[data-md-component=palette]")
|
||||
|
Loading…
Reference in New Issue
Block a user