博客添加评论功能

博客现在支持评论了,基于 Giscus,登录 GitHub 账号即可留言。

没有看到评论区

如果开着代理,评论区可能加载不出来。原因可能是 giscus.app 侧拦截了代理的请求。在代理软件的规则文件中配置直连 giscus 即可:

1
DOMAIN-SUFFIX,giscus.app,DIRECT

保存规则后刷新页面,评论区正常加载。

Giscus

Giscus 是一个基于 GitHub Discussions 的评论系统,开源免费,无需数据库,评论数据直接存在仓库的 Discussions 里,访客登录 GitHub 账号即可留言。

配置方法

  1. 在 GitHub 仓库设置中开启 Discussions 功能。
  2. 在仓库里安装 giscus app
  3. giscus.app 填写仓库信息和评论区设置,一般分类选择 announcements,页面与 discussion 映射关系选择 pathname,其他默认即可
  4. giscus 会生成参数,将参数填入主题配置,以 Fluid 为例,修改 _config.fluid.yml 即可:
1
2
3
4
5
6
7
8
9
10
11
12
13
post:
comments:
enable: true
type: giscus

giscus:
repo: your-name/your-repo
repo-id: R_xxxxxxxxx
category: Announcements
category-id: DIC_xxxxxxxxx
mapping: pathname
theme-light: light
theme-dark: dark