文章
评论系统

评论系统 comment

Redefine 主题支持 waline twikoo gitalk giscus 四种评论系统,你可以根据自己的喜好选择一种。

如果你想对文章单独关闭评论,请在文章的 front-matter 中加入 comment: false

如果你想对页面单独开启评论,请在页面的 front-matter 中加入 comment: true

全局开关

配置项名称:comment.enable

是否启用评论。

类型可选值默认值
布尔值true | falsetrue

评论系统选择

配置项名称:comment.system

类型可选值默认值
字符串waline | gitalk | twikoo | giscuswaline

Waline 配置

配置项名称:comment.config.waline

服务端

请访问 Waline 官网 #快速开始 (opens in a new tab),按照官网的指引配置好 Waline 服务端.

vercel.app 默认域名在中国大陆地区被墙,所以建议在 Vercel 上面绑定自定义域名。如果暂时没有自定义域名的,可以邮件联系我或者加我微信 do-not-go-plzzz,我有多余的域名可以给你解析用。

客户端

拿到你需要的 serverUrl (即 vercel 应用的链接,可以绑定自定义域名)后,填写到 _config.redefine.yml 中。

_config.redefine.yml
comment:
  config:
    waline:
      serverUrl: https://example.example.com #你拿到的 serverUrl

更多关于 Waline 评论系统的信息,请访问 Waline 官网 (opens in a new tab)

Gitalk 配置

更多关于 Gitalk 评论系统的信息,请访问 Gitalk 官网 (opens in a new tab)

配置项名称:comment.config.gitalk

获取 GitHub OAuth App

注册或登录 GitHub (opens in a new tab)创建一个新的 OAuth App (opens in a new tab),其中 Homepage URLAuthorization callback URL 均填写自己博客的域名即可。

OAuth App 创建成功后,把 Client IDClient Secret 保存起来,下面要用到。注意 Homepage URLAuthorization Callback URL 结尾要加 /

image-20230418164336539

新建 GitHub 仓库

回到 GitHub (opens in a new tab)创建一个新的仓库(repository) (opens in a new tab) 用来存放 Gitalk 评论,并打开 Issues,手动增加一个 Issue,内容随便填写即可

填写配置

把自己的 GitHub 用户名仓库名 、OAuth App 的 Client IDClient Secret 分别填写在主题配置文件里。

comment:
  config:
    gitalk:
      clientID: 你的 Client ID
      clientSecret: 你的 Client Secret
      repo: 你的仓库名
      owner: 你的 GitHub 用户名

示例:

comment:
  config:
    gitalk:
      clientID: 1234567890abcdef1234
      clientSecret: 1234567890abcdef1234567890abcdef12345678
      repo: gitalk
      owner: EvanNotFound

效果

Screenshot 2023-03-22 at 7.42.52 PM

Twikoo 配置

更多关于 Twikoo 评论系统的信息,请访问 Twikoo 官网 (opens in a new tab)

配置项名称:comment.config.twikoo

服务端

请访问 Twikoo 官网 #快速上手 (opens in a new tab),按照官网的指引配置好 Twikoo 服务端。(推荐使用 Vercel 部署方式)

客户端

拿到你需要的 server_url 后,填写到 _config.redefine.yml 中。

其中,region 仅在使用腾讯云函数时需要填写,其他情况下可以不填。

_config.redefine.yml
comment:
  config:
    twikoo:
      server_url: https://example.example.com #你的 server_url
      region: #你的 region(可选)

Giscus 配置

更多关于 Giscus 评论系统的信息,请访问 Giscus 官网 (opens in a new tab)

配置项名称:comment.config.giscus

请根据 Giscus 官网 (opens in a new tab)中进行配置,并在主题配置文件中填写。

示例配置:

_config.redefine.yml
comment:
  system: giscus
  config:
    ...
    giscus:
      repo: Ching367436/ching367436.github.io # Github repository name
      repo_id: R_kgDOJAMXOw # Github repository id
      category: Announcements # Github discussion category
      category_id: DIC_kwDOJNMYO84CVdDe # Github discussion category id
      mapping: title
      strict: 0
      reactions_enabled: 1
      emit_metadata: 0
      lang: en
      input_position: bottom
      loading: not-lazy