Ability to use delayed Disqus comments
This commit is contained in:
parent
1a5d075d00
commit
9cad5e961f
3 changed files with 39 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ pygmentsCodefencesGuessSyntax = true
|
|||
readingTime = true
|
||||
useHLJS = true
|
||||
socialShare = true
|
||||
delayDisqus = false
|
||||
# gcse = "012345678901234567890:abcdefghijk" # Get your code from google.com/cse. Make sure to go to "Look and Feel" and change Layout to "Full Width" and Theme to "Classic"
|
||||
|
||||
#[[Params.bigimg]]
|
||||
|
|
|
|||
|
|
@ -41,9 +41,23 @@
|
|||
|
||||
{{ if (.Params.comments) | or (and (or (not (isset .Params "comments")) (eq .Params.comments nil)) (and .Site.Params.comments (ne .Type "page"))) }}
|
||||
{{ if .Site.DisqusShortname }}
|
||||
{{ if .Site.Params.delayDisqus }}
|
||||
<div class="disqus-comments">
|
||||
<button id="show-comments" class="btn btn-default" type="button">{{ i18n "show" }} <span class="disqus-comment-count" data-disqus-url="{{ trim .Permalink "/" }}">{{ i18n "comments" }}</span></button>
|
||||
<div id="disqus_thread"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var disqus_config = function () {
|
||||
this.page.url = '{{ trim .Permalink "/" }}';
|
||||
};
|
||||
|
||||
</script>
|
||||
</div>
|
||||
{{ else }}
|
||||
<div class="disqus-comments">
|
||||
{{ template "_internal/disqus.html" . }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if .Site.Params.staticman }}
|
||||
<div class="staticman-comments">
|
||||
|
|
|
|||
|
|
@ -112,4 +112,28 @@
|
|||
<!-- End Piwik Code -->
|
||||
{{ end }}
|
||||
|
||||
{{ if (.Site.Params.delayDisqus) (and .Site.DisqusShortname) }}
|
||||
<!-- Delayed Disqus -->
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$('#show-comments').on('click', function(){
|
||||
var disqus_shortname = '{{ .Site.DisqusShortname }}';
|
||||
|
||||
(function() {
|
||||
var disqus = document.createElement('script');
|
||||
disqus.type = 'text/javascript';
|
||||
disqus.async = true;
|
||||
disqus.src = '//' + disqus_shortname + '.disqus.com/embed.js';
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(disqus);
|
||||
})();
|
||||
|
||||
$(this).hide();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
<script id="dsq-count-scr" src="//{{ .Site.DisqusShortname }}.disqus.com/count.js" async></script>
|
||||
<!-- End Delayed Disqus -->
|
||||
{{ end }}
|
||||
|
||||
{{- partial "footer_custom.html" . }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue