Fixed endless redirect in palette change example

This commit is contained in:
squidfunk 2022-01-16 12:34:51 +01:00
parent f9e9418462
commit 749c19c4bc
3 changed files with 5 additions and 7 deletions

View File

@ -71,9 +71,8 @@ calling the `super()` function at the beginning of the block:
/* Register event handlers after documented loaded */
document.addEventListener("DOMContentLoaded", function() {
var ref = document.querySelector("[data-md-component=palette]")
component$.subscribe(function (component) {
if (component.ref === ref)
location.reload()
ref.addEventListener("change", function() {
location.reload()
})
})
</script>

View File

@ -6,5 +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>
<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(){document.querySelector("[data-md-component=palette]").addEventListener("change",function(){location.reload()})})</script>
{% endblock %}

View File

@ -56,9 +56,8 @@
/* Register event handlers after documented loaded */
document.addEventListener("DOMContentLoaded", function() {
var ref = document.querySelector("[data-md-component=palette]")
component$.subscribe(function (component) {
if (component.ref === ref)
location.reload()
ref.addEventListener("change", function() {
location.reload()
})
})
</script>