<% if (theme.disqus.disqusjs) { %>
  <div class="disqus" style="width:100%">
    <div id="disqus_thread"></div>
    <script>
      function loadDisqus() {
        addCssLink('<%= url_join(theme.static_prefix.disqusjs, 'disqusjs.css') %>');
        addScript('<%= url_join(theme.static_prefix.disqusjs, 'disqus.js') %>', function () {
          new DisqusJS({
            shortname: '<%= theme.disqus.shortname %>',
            apikey: '<%= theme.disqus.apikey %>'
          });
        });
      }
      createObserver(loadDisqus, 'disqus_thread');
    </script>
    <noscript>Please enable JavaScript to view the
      <a href="https://disqus.com/?ref_noscript" rel="nofollow noopener">comments powered by Disqus.</a>
    </noscript>
  </div>
<% } else { %>
  <div class="disqus" style="width:100%">
    <div id="disqus_thread"></div>
    <script type="text/javascript">
      function loadDisqus() {
        var disqus_config = function () {
          this.page.url = '<%= config.url %>/<%= page.path %>';
          this.page.identifier = '/<%= page.path %>';
        };
        (function () {
          var d = document,
            s = d.createElement('script');
          s.src = '//' + '<%- theme.disqus.shortname %>' + '.disqus.com/embed.js';
          s.setAttribute('data-timestamp', new Date());
          (d.head || d.body).appendChild(s);
        })();
      }
      createObserver(loadDisqus, 'disqus_thread');
    </script>
    <noscript>Please enable JavaScript to view the
      <a href="https://disqus.com/?ref_noscript" rel="nofollow noopener">comments powered by Disqus.</a>
    </noscript>
  </div>
<% } %>
