Skip to content

Commit 749c19c

Browse files
committed
Fixed endless redirect in palette change example
1 parent f9e9418 commit 749c19c

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

docs/setup/adding-a-comment-system.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ calling the `super()` function at the beginning of the block:
7171
/* Register event handlers after documented loaded */
7272
document.addEventListener("DOMContentLoaded", function() {
7373
var ref = document.querySelector("[data-md-component=palette]")
74-
component$.subscribe(function (component) {
75-
if (component.ref === ref)
76-
location.reload()
74+
ref.addEventListener("change", function() {
75+
location.reload()
7776
})
7877
})
7978
</script>

material/overrides/blog.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
{{ super() }}
77
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
88
<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>
9-
<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>
9+
<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>
1010
{% endblock %}

src/overrides/blog.html

+2-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ <h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
5656
/* Register event handlers after documented loaded */
5757
document.addEventListener("DOMContentLoaded", function() {
5858
var ref = document.querySelector("[data-md-component=palette]")
59-
component$.subscribe(function (component) {
60-
if (component.ref === ref)
61-
location.reload()
59+
ref.addEventListener("change", function() {
60+
location.reload()
6261
})
6362
})
6463
</script>

0 commit comments

Comments
 (0)