Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pavel-pi/kiss-em.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmir Ribić <ribice@gmail.com>2018-12-18 22:22:19 +0300
committerGitHub <noreply@github.com>2018-12-18 22:22:19 +0300
commit9226b41a369f21e19f3aa1c6bc05303fa7730dfc (patch)
tree22e26be83502fa9049d71b8790f0aa7b00ec608e /layouts
parent63961c45eb5cd3ac11d430b53456e77f0352fe70 (diff)
parent22e3350431fa94c296b3b7899fc8cc9961f522d0 (diff)
Merge pull request #58 from kerma/master
Add disqus comment loading on demand
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/disqus.html23
1 files changed, 21 insertions, 2 deletions
diff --git a/layouts/partials/disqus.html b/layouts/partials/disqus.html
index 06c7f78..5cc7836 100644
--- a/layouts/partials/disqus.html
+++ b/layouts/partials/disqus.html
@@ -2,13 +2,32 @@
<section class="section">
<div class="container">
<aside><div id="disqus_thread"></div></aside>
+ {{ if .Site.Params.Features.DisqusOnDemand }}
+ <div id="show_comments"><a id="load_comments" class="button is-link">Load comments</a></div>
+ {{ end }}
<script type="text/javascript">
var disqus_shortname = '{{ .Site.DisqusShortname }}';
- (function() {
+ function disqus() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
- })();
+ }
+ {{ if .Site.Params.Features.DisqusOnDemand }}
+ //Opens comments when linked to directly
+ var hash = window.location.hash.substr(1);
+ if ((hash.length > 8) && (hash.substring(0, 8) === "comment-")) {
+ disqus();
+ document.getElementById("show_comments").style.display = "none";
+ } else {
+ document.getElementById('load_comments').onclick = function() {
+ disqus();
+ document.getElementById("show_comments").style.display = "none";
+ };
+ }
+ {{ else }}
+ disqus();
+ {{ end }}
+
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
</div>