将hexo的评论系统由gitment改成Valine

首先注册LeanCloud,注册后添加应用,而后选择应用>设置>应用key就能够看到本身的AppID和AppKey了。html

<!-- more -->git

而后进入本身的主题目录(好比个人主题是默认的landscape):github

删除配置gitment时/themes/landscape/layout/_partial/post目录下添加的git.ejs文件,api

而后编辑/themes/landscape/layout/_partial/目录下的article.ejs,将本来配置gitment时添加在最后的那段代码删掉,添加:安全

<% if (!index){ %>
  <% if (post.comments){ %>
    <div id="vcomments"></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>
        new Valine({
            el: '#vcomments',
            appId: '你的appid',
            appKey: '你的appkey',
            notify:true, 
            verify:true, 
            visitor:true,
            avatar:'mm', 
            placeholder: '嘻嘻嘻' 
        })
    </script>
  <% } else { %>
    <div class="vcomments"></div>
  <% } %>
<% } %>

其中notify为邮件提醒功能是否开启,verify为验证码功能,visitor为文章访问量统计功能,avatarGravatar 头像展现方式。app

在leancloud的应用>设置>安全中心>Web安全域名中添加你的域名。post

而后就OK啦!!ui

有其余问题能够访问Valine官方文档查看。url

关于出现Code 403: 访问被api域名白名单拒绝,请检查你的安全域名设置.的问题:.net

个人问题是同时在github和coding上部署了,可是在leancloud的应用>设置>安全中心>Web安全域名中只添加了github的域名,所以在coding的那个域名访问时就会出现上述问题,添加域名便可解决问题。

相关文章
相关标签/搜索