diff --git a/assets/sass/_partial/_post.scss b/assets/sass/_partial/_post.scss index f8c41056..85d62757 100644 --- a/assets/sass/_partial/_post.scss +++ b/assets/sass/_partial/_post.scss @@ -51,4 +51,10 @@ justify-content: center; } + // This is to match the color scheme of Disqus so that its background could be transparent + // See: https://fvsch.com/transparent-iframes +.comment [id*="disqus"] iframe { + color-scheme: light; +} + @import '_toc'; diff --git a/layouts/partials/comments/disqus.html b/layouts/partials/comments/disqus.html index f1f5817c..d237c593 100644 --- a/layouts/partials/comments/disqus.html +++ b/layouts/partials/comments/disqus.html @@ -20,6 +20,21 @@ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); document.getElementById('load_disqus_container').style.display = 'none'; + + // disqus needs to be reloaded when the theme is changed + const themeToggles = document.querySelectorAll('.theme-toggle'); + themeToggles.forEach(toggle => { + toggle.addEventListener('click', function (e) { + e.preventDefault(); + DISQUS.reset({ + reload: true, + config: function () { + this.page.identifier = '{{ .Site.Config.Services.Disqus.Shortname }}'; + this.page.url = {{ .Permalink }}; + } + }); + }); + }); };