2019-09-30 15:38:41 +03:00
|
|
|
<!--
|
|
|
|
The Disqus lazy loading.
|
|
|
|
-->
|
|
|
|
|
2021-12-01 16:48:57 +03:00
|
|
|
{% if site.disqus.comments and page.comments %}
|
|
|
|
|
2021-09-14 15:45:17 +03:00
|
|
|
<div id="disqus_thread" class="pt-2 pb-2">
|
2021-09-28 11:29:13 +03:00
|
|
|
<p class="text-center text-muted small">
|
2021-02-25 19:50:42 +03:00
|
|
|
Comments powered by <a href="https://disqus.com/">Disqus</a>.
|
2020-07-29 23:58:05 +03:00
|
|
|
</p>
|
2019-09-30 15:38:41 +03:00
|
|
|
</div>
|
|
|
|
|
2021-09-14 15:45:17 +03:00
|
|
|
<script type="text/javascript">
|
|
|
|
var disqus_config = function () {
|
|
|
|
this.page.url = '{{ page.url | absolute_url }}';
|
|
|
|
this.page.identifier = '{{ page.url }}';
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Lazy loading */
|
2019-09-30 15:38:41 +03:00
|
|
|
|
2021-09-14 15:45:17 +03:00
|
|
|
var disqus_observer = new IntersectionObserver(function (entries) {
|
|
|
|
if(entries[0].isIntersecting) {
|
|
|
|
(function () {
|
|
|
|
var d = document, s = d.createElement('script');
|
|
|
|
s.src = 'https://{{ site.disqus.shortname }}.disqus.com/embed.js';
|
|
|
|
s.setAttribute('data-timestamp', +new Date());
|
|
|
|
(d.head || d.body).appendChild(s);
|
|
|
|
})();
|
|
|
|
|
|
|
|
disqus_observer.disconnect();
|
2019-09-30 15:38:41 +03:00
|
|
|
}
|
2021-09-14 15:45:17 +03:00
|
|
|
}, { threshold: [0] });
|
2019-09-30 15:38:41 +03:00
|
|
|
|
2021-09-14 15:45:17 +03:00
|
|
|
disqus_observer.observe(document.querySelector('#disqus_thread'));
|
|
|
|
|
|
|
|
/* Auto switch theme */
|
|
|
|
|
|
|
|
function reloadDisqus() {
|
|
|
|
/* Disqus hasn't been loaded */
|
|
|
|
if (typeof DISQUS === "undefined") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (document.readyState == 'complete') {
|
|
|
|
DISQUS.reset({ reload: true, config: disqus_config });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const modeToggle = document.querySelector(".mode-toggle");
|
|
|
|
|
|
|
|
if (modeToggle !== null) {
|
|
|
|
modeToggle.addEventListener('click', reloadDisqus);
|
|
|
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', reloadDisqus);
|
|
|
|
}
|
|
|
|
|
2021-01-18 18:27:43 +03:00
|
|
|
</script>
|
2021-12-01 16:48:57 +03:00
|
|
|
|
|
|
|
{% endif %}
|