This repository has been archived on 2024-11-01. You can view files and clone it, but cannot push or open issues or pull requests.
blog/themes/kiera/layouts/partials/disqus.html

64 lines
2.3 KiB
HTML
Raw Permalink Normal View History

2024-10-28 16:26:25 -05:00
<section class="comments-block">
<button id="show-comments" style="display: none;"><i class="fa fa-comments"></i> {{ T "comments" }}</button>
</section>
<section id="disqus_thread"></section>
<script>
(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_loaded = false;
var disqus_shortname = '{{ .Site.Config.Services.Disqus.Shortname }}';
var disqus_button = document.getElementById("show-comments");
var disqus_autoload = {{ .Site.Params.commentAutoload }};
var disable_comment = {{ .Params.disableComments }};
if (disable_comment)
return;
disqus_button.style.display = "";
if (disqus_autoload){
disqus();
}else{
disqus_button.addEventListener("click", disqus, false);
}
function disqus() {
if (!disqus_loaded) {
disqus_loaded = true;
var e = document.createElement("script");
e.type = "text/javascript";
e.async = true;
e.src = "//" + disqus_shortname + ".disqus.com/embed.js";
(document.getElementsByTagName("head")[0] ||
document.getElementsByTagName("body")[0])
.appendChild(e);
//Hide the button after opening
document.getElementById("show-comments").style.display = "none";
}
}
//Opens comments when linked to directly
var hash = window.location.hash.substr(1);
if (hash.length > 8) {
if (hash.substring(0, 8) == "comment-") {
disqus();
}
}
//Remove this is you don't want to load comments for search engines
if (/bot|google|baidu|bing|msn|duckduckgo|slurp|yandex/i.test(navigator.userAgent)) {
disqus();
}
})();
</script>