Created
December 10, 2013 04:01
-
-
Save haacked/7885542 to your computer and use it in GitHub Desktop.
Disqus Jekyll template include
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% comment %} Load script if disquss comments are enabled and `page.comments` is either empty (index) or set to true {% endcomment %} | |
{% if site.disqus_short_name and page.comments != false %} | |
<script type="text/javascript"> | |
var disqus_shortname = '{{ site.disqus_short_name }}'; | |
{% if page.comments == true %} | |
{% comment %} `page.comments` can be only be set to true on pages/posts, so we embed the comments here. {% endcomment %} | |
// var disqus_developer = 1; | |
var disqus_identifier = '{% if page.disqus_identifier %}{{ page.disqus_identifier}}{% else %}{{ site.url }}{{ page.url }}{% endif %}'; | |
var disqus_url = '{{ site.url }}{{ page.url }}'; | |
var disqus_script = 'embed.js'; | |
{% endif %} | |
(function () { | |
{% if page.comments == true %} | |
var embedScript = document.createElement('script'); | |
embedScript.type = 'text/javascript'; | |
embedScript.async = true; | |
embedScript.src = 'http://' + disqus_shortname + '.disqus.com/embed.js'; | |
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(embedScript); | |
{% endif %} | |
var countScript = document.createElement('script'); | |
countScript.type = 'text/javascript'; | |
countScript.async = true; | |
countScript.src = 'http://' + disqus_shortname + '.disqus.com/count.js'; | |
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(countScript); | |
}()); | |
</script> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice