diff options
author | kdevo <kdevo@users.noreply.github.com> | 2020-08-27 11:43:07 +0300 |
---|---|---|
committer | kdevo <kdevo@users.noreply.github.com> | 2020-08-27 11:43:07 +0300 |
commit | 5fa131671cbe91a4c89a833775cbb6df6df39abe (patch) | |
tree | 5a382a955791fea6fa959555fe6af04f48bc4367 /layouts | |
parent | 9cd90653fa395cdf9a47028b99afd561343d8a4a (diff) |
:bug: Only enable Disqus when needed
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/single.html | 2 | ||||
-rw-r--r-- | layouts/partials/disqus.html | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html index ec488c6..01da386 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -30,7 +30,9 @@ </div> </section> <br> + {{ if .Site.DisqusShortname -}} {{ partial "disqus" . }} + {{- end }} </section> </main> diff --git a/layouts/partials/disqus.html b/layouts/partials/disqus.html index 8608efe..b30f78e 100644 --- a/layouts/partials/disqus.html +++ b/layouts/partials/disqus.html @@ -1,16 +1,20 @@ +<!-- Adapted from https://gohugo.io/templates/internal/#disqus --> <section class="disqus"> <div id="disqus_thread"></div> <script type="text/javascript"> - (function() { + + (function() { // Don't ever inject Disqus on localhost--it creates unwanted // discussions from 'localhost:1313' on your Disqus account... if (window.location.hostname == "localhost") - return; - var disqus_shortname = '{{ .Site.DisqusShortname }}'; + return; + var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; + var disqus_shortname = '{{ .Site.DisqusShortname }}'; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); - })(); + })(); </script> <noscript>{{ i18n "enableJavaScript" }} <a href="http://disqus.com/?ref_noscript">Disqus</a>.</noscript> + <a href="https://disqus.com/" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a> </section> |