Hexo Fluid 配置 Giscus

[TOC]

使用Giscus在Hexo Fluid文章中评论功能。

giscus官网:https://giscus.app

准备工作

Giscus 的运作原理

   giscus 加载时,会使用 GitHub Discussions 搜索 API 根据选定的映射方式(如 URLpathname<title> 等)来查找与当前页面关联的 discussion。如果找不到匹配的 discussion,giscus bot 就会在第一次有人留下评论或回应时自动创建一个 discussion。

  访客如果想要评论,必须按照 GitHub OAuth 流程授权 giscus app 代表他发布,或者可以直接在 GitHub Discussion 里评论。你可以在 GitHub 上管理评论。

配置

  接下来在 giscus 的官网 配置模块选择所需配置:

  其中 Discussion 分类那里 giscus 推荐使用的 是 Announcements ,但是我没有弄好,索性就用 General 了,全部选好后,下边会出现一个你选的配置 <script> 标签。在 Fluid 的 _config.yml 文件中把对应位置 配置填上去即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
giscus:
repo:
repo_id:
category:
category_id:
# Available values: pathname | url | title | og:title
mapping: pathname
# Available values: 0 | 1
reactions_enabled: 1
# Available values: 0 | 1
emit_metadata: 0
# Available values: light | dark | dark_high_contrast | transparent_dark | preferred-color-scheme
theme: preferred_color_scheme
# Available values: en | zh-CN
lang: zh-CN
# Place the comment box above the comments
input_position: top

  注意在 Fluid 开启评论插件

1
2
3
4
5
6
7
8
# 评论插件
# Comment plugin
comments:
enable: true
# 指定的插件,需要同时设置对应插件的必要参数
# The specified plugin needs to set the necessary parameters at the same time
# Options: utterances | disqus | gitalk | valine | waline | changyan | livere | remark42 | twikoo | cusdis | giscus | discuss
type: giscus


Hexo Fluid 配置 Giscus
https://1zqqx.github.io/2025/03/29/Hexo-Fluid-配置-Giscus/
作者
1zqqx
发布于
2025年3月29日
许可协议