4. 评论系统配置指南

696 字
3 分钟
4. 评论系统配置指南

评论系统配置指南#

配置文件位置#

src/config/commentConfig.ts

支持的评论系统#

评论系统说明难度
Giscus基于 GitHub Discussions简单
Twikoo腾讯云开发版简单
WalineVercel 部署版中等
Artalk自建后端版较难
Disqus国外老牌评论系统简单
none不启用评论系统-

Giscus 配置(推荐)#

Giscus 是一个基于 GitHub Discussions 的评论系统,免费、稳定、易用。

1. 安装 GitHub App#

访问 https://github.com/apps/giscus ,点击 “Install” 安装到你的 GitHub 仓库。

2. 配置仓库#

安装后,在仓库的 Settings → Pages 中:

  • Source 选择 GitHub Actions

3. 获取配置参数#

访问 https://giscus.app/zh-CN ,填写你的仓库信息,获取以下参数:

giscus: {
// 设置 Giscus 评论系统仓库(格式:用户名/仓库名)
repo: "你的用户名/你的仓库名",
// 仓库 ID(从 giscus.app 获取)
repoId: "R_xxxxxxxxxxxx",
// 评论分类名称
category: "General",
// 分类 ID(从 giscus.app 获取)
categoryId: "DIC_xxxxxxxxxxxx",
// 映射方式:pathname, URL, title 等
mapping: "pathname",
// 是否启用 reactions
reactionsEnabled: "1",
// 评论输入位置:bottom, top
inputPosition: "bottom",
// 语言:zh-CN, en 等
lang: "zh-CN",
},

4. 更多配置项#

giscus: {
// 严格模式
strict: "0",
// 是否发送元数据
emitMetadata: "0",
// 加载方式:lazy, eager
loading: "lazy",
},

Twikoo 配置#

Twikoo 是一个基于腾讯云开发的评论系统,部署简单。

1. 获取环境 ID#

  1. 进入 https://console.cloud.tencent.com/tcb
  2. 创建一个云开发环境
  3. 在云开发控制台中,开通「云函数」服务
  4. 创建一个环境后,在环境设置中获取环境 ID

2. 配置示例#

twikoo: {
// 环境 ID
envId: "your-env-id-xxxxx",
// 语言
lang: "zh-CN",
// 是否启用访问量统计
visitorCount: true,
},

Waline 配置#

Waline 是一个基于 Vercel 部署的评论系统。

1. 部署 Waline 服务#

  1. Fork https://github.com/walinejs/waline 到你的 GitHub
  2. 在 Vercel 中导入该项目
  3. 配置环境变量:
    • LEAN_ID: LeanCloud 应用 ID
    • LEAN_KEY: LeanCloud 应用 Key
    • LEAN_MASTER_KEY: LeanCloud Master Key
  4. 部署后获取服务 URL

2. 配置示例#

waline: {
// Waline 服务地址
serverURL: "https://your-waline.vercel.app",
// 语言
lang: "zh-CN",
// 登录模式
login: "enable",
// 表情包配置
emoji: [
"https://unpkg.com/@waline/emojis@1.4.0/weibo",
"https://unpkg.com/@waline/emojis@1.4.0/bilibili",
],
// 访问量统计
visitorCount: true,
},

切换评论系统#

在 commentConfig.ts 中修改 type 字段:

export const commentConfig: CommentConfig = {
// 切换评论系统
type: "giscus", // 可选: giscus, twikoo, waline, artalk, disqus, none
// ...
},

禁用评论功能#

方法一:设置 type 为 none

type: "none",

方法二:在文章 frontmatter 中单独禁用

---
title: 我的文章
comment: false // 这篇文章禁用评论
---

常见问题#

Q: 评论不显示?#

  1. 检查浏览器控制台是否有错误
  2. 确认配置参数是否正确
  3. 确认评论系统服务是否正常运行

Q: 如何开启访问量统计?#

在对应评论系统的配置中设置 visitorCount: true

Q: 如何修改评论框语言?#

在配置中找到 lang 字段,设置为 zh-CN(中文)或 en(英文)

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或赞助支持!

赞助
4. 评论系统配置指南
https://blogboy.eu.cc/posts/4/
作者
Coldairboy
发布于
2026-03-27
许可协议
CC BY-NC-SA 4.0

评论区

Profile Image of the Author
Coldairboy
记录学习笔记、折腾过程和日常灵感。
公告
Hi,欢迎来到 Coldairboy学习笔记。
音乐
封面

音乐

暂未播放

0:00 0:00
暂无歌词
分类
标签
站点统计
文章
31
分类
3
标签
5
总字数
36,702
运行时长
0 天
最后活动
0 天前

目录