add disqus to template conditionally on shortName parameter

master
David Kebler 2017-03-30 11:44:42 -07:00
parent 63e08c26b5
commit cd31dbcc62
2 changed files with 45 additions and 0 deletions

View File

@ -7,6 +7,7 @@
{{ partial "hero.html" . }} {{ partial "hero.html" . }}
{{ partial "sections.html" . }} {{ partial "sections.html" . }}
</main> </main>
{{ if .Site.DisqusShortname }} {{ partial "disqus.html" . }} {{ end }}
{{ partial "js.html" . }} {{ partial "js.html" . }}
</body> </body>
</html> </html>

View File

@ -0,0 +1,44 @@
<div id="disqus_thread"></div>
<script type="text/javascript">
(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 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>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com/" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
<!-- from disqus
<div id="disqus_thread"></div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://landingpage-guide.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
-->
<!-- goes in body before closing tag for count -->
<!-- <script id="dsq-count-scr" src="//landingpage-guide.disqus.com/count.js" async></script> -->