disqus.swig 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. {%- if theme.disqus.count %}
  2. <script>
  3. function loadCount() {
  4. var d = document, s = d.createElement('script');
  5. s.src = 'https://{{ theme.disqus.shortname }}.disqus.com/count.js';
  6. s.id = 'dsq-count-scr';
  7. (d.head || d.body).appendChild(s);
  8. }
  9. // defer loading until the whole page loading is completed
  10. window.addEventListener('load', loadCount, false);
  11. </script>
  12. {%- endif %}
  13. {%- if page.comments %}
  14. <script>
  15. var disqus_config = function() {
  16. this.page.url = {{ page.permalink | json }};
  17. this.page.identifier = {{ page.path | json }};
  18. this.page.title = {{ page.title | json }};
  19. {% if __('disqus') !== 'disqus' -%}
  20. this.language = '{{ __('disqus') }}';
  21. {% endif -%}
  22. };
  23. NexT.utils.loadComments(document.querySelector('#disqus_thread'), () => {
  24. if (window.DISQUS) {
  25. DISQUS.reset({
  26. reload: true,
  27. config: disqus_config
  28. });
  29. } else {
  30. var d = document, s = d.createElement('script');
  31. s.src = 'https://{{ theme.disqus.shortname }}.disqus.com/embed.js';
  32. s.setAttribute('data-timestamp', '' + +new Date());
  33. (d.head || d.body).appendChild(s);
  34. }
  35. });
  36. </script>
  37. {%- endif %}