Halyul / hexo-theme-mdui

GNU General Public License v3.0
185 stars 35 forks source link

feat:add valine comment system #74

Closed xCss closed 7 years ago

xCss commented 7 years ago

add valine comment system.

_config.yml

# use:disqus、valine
comment:
    use: 
    shortname:
    # https://valine.js.org
    valine: 
      appid:  # your leancloud appId
      appkey:  # your leancloud appKey
      notify: false #mail notify
      verify: false #verify code
      avatar: mm # gravatar style
      placeholder: Just go go # comment box placeholder
      guest_info: nick,mail,link # reviewer attributes

layout/_partials/comment.ejs

<% 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>
<% } %>

layout/post.ejs

-          <% if (theme.comment.use === 'disqus' || theme.comment.use === 'custom') { %>
+          <% if (theme.comment.use) { %>