Hexo Next 评论系统 Valine 使用

为Next主题新增评论系统

配置LeanCloud

  1. 访问LeanCloud注册Leancloud账号
  2. 登陆LeanCloud,创建新应用

  3. 查看数据存储中是否有Comment和Counter两个Class,如果没有,需要自行创建,权限设置为’无限制’
  4. 进入安全中心,关闭除’数据存储’以外的服务,并且设置’Web 安全域名’,设置安全域名时,需要注意,域名需包含’http’或’https’协议标识
  5. 进入应用凭证,复制AppID、AppKey以及REST API 另用

更新代码

  1. 文件系统跳转到项目根目录,执行npm install next-theme/hexo-next-valine
  2. 编辑Next主题配置文件,新增以下配置
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    # Valine
    # For more information: https://valine.js.org, https://github.com/xCss/Valine
    valine:
    enable: true
    appId: '' # LeanCloud中复制的AppID
    appKey: '' # LeanCloud中复制的AppKey
    serverURLs: ''# LeanCloud中复制的REST API服务器地址
    avatar: mm # gravatar style
    meta: [ nick, mail, link ] # Custom comment header
    pageSize: 10 # pagination size
    visitor: false # leancloud-counter-security is not supported for now. When visitor is set to be true, appid and appkey are recommended to be the same as leancloud_visitors' for counter compatibility. Article reading statistic https://valine.js.org/visitor.html
    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

大功告成,谢谢🙏