[Gitalk]评论系统
NexT
集成了多种评论系统,当前使用Gitalk
简介
gitalk是一个基于github
开发的评论插件,它将文章评论以issues
形式保存在github
仓库中
实现步骤如下:
- 注册
github
应用 NexT
配置
注册github应用
进入github
注册页面:Register a new OAuth application
Application name
:应用名,方便起见直接填github
用户名Homepage URL
:网站地址Application description
:应用描述Authorization callback URL
:网站地址
注册成功后会生成Client ID
和Client Secret
NexT配置
修改主题_config.yml
# Gitalk
# For more information: https://gitalk.github.io
gitalk:
enable: true
github_id: zjykzj # GitHub repo owner
repo: guestbook # Repository name to store issues
client_id: e15xxxxx63dce # GitHub Application Client ID
client_secret: 76cxxxxxf766 # GitHub Application Client Secret
admin_user: zjykzj # GitHub repo owner and collaborators, only these guys can initialize gitHub issues
distraction_free_mode: true # Facebook-like distraction free mode
# When the official proxy is not available, you can change it to your own proxy address
proxy: https://cors-anywhere.herokuapp.com/https://github.com/login/oauth/access_token # This is official proxy adress
# Gitalk's display language depends on user's browser or system environment
# If you want everyone visiting your site to see a uniform language, you can set a force language value
# Available values: en | es-ES | fr | ru | zh-CN | zh-TW
language: zh-CN
- 设置
enable
为true
github_id
填入github
帐号repo
填入github
仓库名(注意:是仓库名不是仓库地址),评论将会以issues
形式保存在该仓库下client_id
填入注册生成的值client_secret
填入注册生成的值admin_user
填入github
帐号,用于初始化评论账户
Error: Not Found
问题描述:在文章底部评论框中出现错误信息
Error: Not Found
解决:和配置选项的填写有关,注意填写的内容
隐藏评论框
设置gitalk
评论系统后,将会在每篇文章末尾添加评论框,而对于标签页/类别页等不需要评论的文章,可在front-matter
设置属性进行隐藏
comments: false
Error: Request failed with status code 403
这是由于代理服务器出错的问题,经过查询,发现是NexT
提供的反向代理已停止服务
# When the official proxy is not available, you can change it to your own proxy address
proxy: https://cors-anywhere.herokuapp.com/https://github.com/login/oauth/access_token # This is official proxy adress
# Gitalk's display language depends on user's browser or system environment
当前的解决方案就是自己新建一个反向代理服务器,启动nginx
服务,配置如下:
location = /login/oauth/access_token {
add_header Access-Control-Allow-Origin 'https://xxx.xxx.xxx';
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
if ($request_method = 'OPTIONS') {
return 204;
}
proxy_pass https://github.com;
}
自定义反向代理以重定向github
地址,使用如下地址进行替换:
https://xxx.xxx.xxx/login/oauth/access_token
相关阅读
- Gitalk
- Hexo 搭建:配置 Gitalk 评论系统
- gitalk提示Error Not Found #130
- gitalk/gitalk
- Hexo中Gitalk配置使用教程-可能是目前最详细的教程 | ioChen's Blog #3
- hexo next 主题配置 gitalk 评论后无法初始化创建 issue #115
- 解决使用 Gitalk 登录授权报 403 的问题
- Error: Request failed with status code 403
- PSA: Public demo server (cors-anywhere.herokuapp.com) will be very limited by January 2021, 31st #301
- 在授权gitalk后出现403错误 #429
- 为博客添加 Gitalk 评论区