Hexo 评论系统
由于 Hexo 博客系统是静态博客,所以它本身无法支持评论等动态的功能。不过,有很多第三方的评论系统都可以通过添加 JS 代码的方式让 Hexo 博客支持评论功能。
常见的评论系统包括:Valine、Disqus、Gitment 等等。
添加 Valine 评论系统
注册 LeanCloud
由于 valine 评论系统是放在 LeanCloud 上的,因此需要先打开 https://www.leancloud.cn 网址注册一个 LeanCloud 账号。
注册完成后创建一个应用,比如名字为 blog,然后进入应用,在 设置 -> 应用凭证 中找到 APP ID 和 APP Key。
Hexo 配置
在 hexo 工程下执行如下命令安装插件
npm install next-theme/hexo-next-valine
在 _config.yml 文件末尾插入如下内容(可以是 hexo 或 theme 的 _config.yml)
# Valine
# For more information: https://valine.js.org, https://github.com/xCss/Valine
valine:
enable: false
appId: # your leancloud application appid
appKey: # your leancloud application appkey
serverURLs: # When the custom domain name is enabled, fill it in here
placeholder: Just go go # comment box placeholder
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
将 enable
项改为 true
,复制前面生成的 appId 和 appKey。