使用 Valine 开启 Hexo 评论系统
关于评论系统
博客搭建好之后,由于当时已经晚上12点了,并没有一鼓作气的开启评论系统,就一直拖到了现在。。。
今天终于想起来开启评论系统,在网上搜索了一下 hexo 的评论系统,有以下几个:
- gitment:基于 GitHub Issue 作为评论存储仓库,但是一直长时间无人维护
- gitalk:同
gitment
使用 Github Issue,且页面比gitment
更精美 - disqus:界面好看,支持 Facebook、twitter、Google+ 等账号登陆,但是 需要科学上网
- valine:基于 LeanCloud 的无后端评论系统,支持匿名评论
- 来必力:韩国的评论系统,功能强大,支持多社交帐号登录,链接不太稳定,不支持匿名评论
对于我来讲,我更偏向于使用 gitalk
作为评论系统,省心~但是 gitalk
类的评论系统被反馈有安全风险,虽然是 GitHub 的锅,但是会对访客(还不是我。。。)的账户安全带来很大的不确定性,所以最终我还是选择了支持匿名评论的 Valine
注册 LeanCloud
Valine 是基于 LeanCloud 进行使用的,所以我们需要在 LeanCloud 进行注册
因为现在 LeanCloud 国内版要求备案域名,所以使用国际版
配置 LeanCloud
- 创建应用:
- 切换到存储页面:
- 【结构化数据】-【创建 class】
- 修改 ACL 的 write 权限,设置成下图效果
- 切换到【设置】
- 【安全中心】-【Web 安全域名】,输入博客会用到的域名,如
http://jiz4oh.com
、https://jiz4oh.com
- 【应用 Keys】-【AppID】
【应用 Keys】-【AppKey】
这两个数据在下一步中使用(可点击后面的按钮快速复制)
配置 next
打开 next 的配置文件,如我是
_confg.next.yml
,将下列代码复制进去,注意缩进valine: enable: true appId: # 拷贝上一步的 ID appKey: # 拷贝上一步的 Key placeholder: # Comment box placeholder avatar: mm # Gravatar style meta: [nick, mail, link] # Custom comment header pageSize: 10 # Pagination size lang: # Language, available values: en, zh-cn visitor: false # Article reading statistic comment_count: true # If false, comment count will only be displayed in post page, not in home page recordIP: false # Whether to record the commenter IP serverURLs: # When the custom domain name is enabled, fill it in here (it will be detected automatically by default, no need to fill in) enableQQ: false # Whether to enable the Nickname box to automatically get QQ Nickname and QQ Avatar requiredFields: [] # Set required fields: [nick] | [nick, mail]