Halyul/hexo-theme-mdui

View on GitHub
layout/_partials/comment.ejs

Summary

Maintainability
Test Coverage
<% if(theme.comment.use === 'custom') { %>
  <%-partial('../_custom/custom_comment')%>
<% } else if (theme.comment.use === 'disqus') { %>
  <div id="disqus_thread"></div>
  <script>
    themeRuntime.commentRest.function = function (newIdentifier, newUrl, newTitle) {
      DISQUS.reset({
        reload: true,
        config: function () {
          this.page.identifier = newIdentifier;
          this.page.url = newUrl;
          this.page.title = newTitle;
        }
      });
    }
    var disqus_config = function () {
      this.page.url = '<%= page.permalink %>';  // Replace PAGE_URL with your page's canonical URL variable
      this.page.identifier = '<%= page.permalink %>'; // 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 = '//<%= theme.comment.shortname %>.disqus.com/embed.js';
      s.setAttribute('data-timestamp', +new Date());
      (d.head || d.body).appendChild(s);
    })();
  </script>
  <noscript><%- __('posts.disqus_no_script') %></noscript>
<% } else if (theme.comment.use === 'valine') { %>
  <div id="comments"></div>
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  <script>
    var notify = '<%= theme.comment.valine.notify %>' == true ? true : false;
    var verify = '<%= theme.comment.valine.verify %>' == true ? true : false;
    var GUEST_INFO = ['nick','mail','link'];
    var guest_info = '<%= theme.comment.valine.guest_info %>'.split(',').filter(function(item){
      return GUEST_INFO.indexOf(item) > -1
    });
    guest_info = guest_info.length == 0 ? GUEST_INFO :guest_info;
    window.onload = function() {
        new Valine({
            el: '#comments',
            notify: notify,
            verify: verify,
            app_id: "<%= theme.comment.valine.appid %>",
            app_key: "<%= theme.comment.valine.appkey %>",
            avatar:"<%= theme.comment.valine.avatar %>",
            placeholder: "<%= theme.comment.valine.placeholder %>",
            guest_info:guest_info
        });
    }
  </script>
<% } %>