Hexo Next Theme添加Waline评论框和邮件提醒

之前文章下面一直使用的是Valine评论框,Valine已经不开源了,所以也遭到了开源社区的抛弃。

使用新版本的 Hexo NexT,哪怕是安装了主题作者提供的 Valine 插件,也不能正常使用。

不过有非常完美的替代方案,使用 Waline,数据结构都是相同的,迁移起来非常方便。

在 Hexo NexT 主题下配置 Waline 评论系统和邮件提醒的方法:

一、安装插件

1
npm install @waline/hexo-next

并在 _config.next.yml 配置文件里面配置参数

这下面有些参数可能是没有用的,这个自行研究一下。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
waline:
enable: true # When enable is set to be true, leancloud_visitors is recommended to be closed for the re-initialization problem within different leancloud adk version.
appid: # your leancloud application appid
appkey: # your leancloud application appkey
serverURL: # https://my-waline-beryl.vercel.app/ Vercel 地址
avatar: mm # gravatar style
meta: [nick, mail, link] # Custom comment header
pageSize: 10 # pagination size
visitor: true # 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
enableQQ: false # Whether to enable the Nickname box to automatically get QQ Nickname and QQ Avatar
requiredFields: [] # Set required fields: [nick] | [nick, mail]
libUrl: # Waline.min.js file URL in CDN (or local path)

二、注册leanCloud

推荐注册海外版,使用国内版的话,在域名上会有限制,需要备案之类的。

三、Vercel部署

根据官网的安装方法,一步步操作就行

https://waline.js.org/guide/get-started/

在部署的时候,如果需要配置邮件提醒,还需要添加如下环境变量。