Skip to content

Commit 7519e01

Browse files
authored
Merge pull request #1 from felixnie/bugfix/fix-disqus
Make Disqus work with Hydejack's color toggle and transfer animation
2 parents c78296b + d81ba75 commit 7519e01

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

_includes/my-comments.html

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
{% assign disqus = site.disqus | default:site.disqus_shortname %}
22
{% if disqus %}
3+
4+
<!-- Fixing the Disqus iframe transparency issue on some browsers -->
5+
<style>
6+
:root {
7+
color-scheme: light dark;
8+
}
9+
/* make sure Disqus iframe uses light mode */
10+
iframe {
11+
color-scheme: light;
12+
}
13+
</style>
14+
315
<div id="disqus_thread"></div>
416
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
517
<script>!function(w, d) {
@@ -10,15 +22,33 @@
1022
config() {
1123
this.page.url = w.location.href;
1224
this.page.title = d.title;
25+
this.page.identifier = w.location.pathname;
1326
},
1427
});
1528
} else {
1629
w.disqus_config = function disqusConfig() {
1730
this.page.url = w.location.href;
1831
this.page.title = d.title;
32+
this.page.identifier = w.location.pathname;
1933
};
20-
w.loadJSDeferred(d.getElementById("_hrefDisqus").href + '/embed.js');
34+
w.loadJSDeferred(d.getElementById("_hrefDisqus").href + 'embed.js');
2135
}
2236
}
37+
38+
d.addEventListener('hydejack-dark-mode-toggle', (e) => {
39+
setTimeout(() => {
40+
if (w.DISQUS) {
41+
w.DISQUS.reset({
42+
reload: true,
43+
config: function () {
44+
this.page.url = w.location.href;
45+
this.page.title = d.title;
46+
this.page.identifier = w.location.pathname;
47+
}
48+
});
49+
}
50+
}, 500);
51+
});
52+
2353
}(window, document);</script>
24-
{% endif %}
54+
{% endif %}

0 commit comments

Comments
 (0)