给hexo添加评论功能
配置
这里用的是 gitalk 构建的评论区,首先需要安装,在博客根目录输入命令
npm i --save gitalk
安装后在配置文件会出现 gitalk 的配置信息,形如
# gitalk
# https://github.com/gitalk/gitalk
gitalk:
client_id: 'GitHub Application Client ID'
client_secret: 'GitHub Application Client Secret'
repo: 'GitHub repo'
owner: 'GitHub repo owner'
admin: 'GitHub repo owner and collaborators, only these guys can initialize github issues'
language: en # en, zh-CN, zh-TW, es-ES, fr, ru
perPage: 10 # Pagination size, with maximum 100.
distractionFreeMode: false # Facebook-like distraction free mode.
pagerDirection: last # Comment sorting direction, available values are last and first.
createIssueManually: true # Gitalk will create a corresponding github issue for your every single page automatically
option:
主要要填的是 client_id, client_secret, repo, owner, admin
,前两个需要在 GitHub 上生成。在 GitHub 上 点击 setting > Developer setting > OAuth Apps,选择 Register a new application,填写相关信息即可,其中 Homeback URL 是填博客的地址,callback URL 是填认证后回去的地址。这个 OAuth 其实就是 GitHub 的第三方认证。
repo
填写仓库名字,owner
填写仓库的所有者,admin
填写对仓库有写权限的用户。
References
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Ruoy's Blog!
评论