mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Added dark mode support for Giscus
This commit is contained in:
parent
09c0e1cb6e
commit
9511569d05
@ -6,4 +6,5 @@
|
||||
{{ super() }}
|
||||
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
|
||||
<script src="https://giscus.app/client.js" data-repo="squidfunk/mkdocs-material" data-repo-id="MDEwOlJlcG9zaXRvcnk1MDYxNzQyOA==" data-category="_" data-category-id="DIC_kwDOAwRcVM4CAtJY" data-mapping="pathname" data-reactions-enabled="1" data-emit-metadata="1" data-theme="light" data-lang="en" crossorigin="anonymous" async></script>
|
||||
<script>var giscus,palette=__md_get("__palette");palette&&"object"==typeof palette.color&&"slate"===palette.color.scheme&&(giscus=document.querySelector("script[src*=giscus]")).setAttribute("data-theme","dark"),document.addEventListener("DOMContentLoaded",function(){var t=document.querySelector("[data-md-component=palette]");component$.subscribe(function(e){e.ref===t&&location.reload()})})</script>
|
||||
{% endblock %}
|
||||
|
@ -43,4 +43,23 @@
|
||||
async
|
||||
>
|
||||
</script>
|
||||
|
||||
<!-- Reload on palette change -->
|
||||
<script>
|
||||
var palette = __md_get("__palette")
|
||||
if (palette && typeof palette.color === "object")
|
||||
if (palette.color.scheme === "slate") {
|
||||
var giscus = document.querySelector("script[src*=giscus]")
|
||||
giscus.setAttribute("data-theme", "dark")
|
||||
}
|
||||
|
||||
/* Reload on palette change */
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
var ref = document.querySelector("[data-md-component=palette]")
|
||||
component$.subscribe(function (component) {
|
||||
if (component.ref === ref)
|
||||
location.reload()
|
||||
})
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user