Firefly博客添加评论功能
491 字
2 分钟
Firefly博客添加评论功能
除了友链之外,再加个评论的功能,那就可以收到大伙的评论了!
我选择使用giscus来实现评论功能。主要是它不需要依赖于数据库,而且配置也比较简单,最主要的是依赖于Github并且纯免费!!!
配置giscus#
- 首先,你需要创建一个新的GitHub库用来保存博客的那些评论,你需要确保该仓库是公开的,否则访客将无法查看
Discussion。 - 然后,你需要给你的这个仓库repo安装giscus app,否则访客将无法评论和回应。
- 最后,你需要确保
Discussions功能已在你的仓库中启用。
打开giscus官方网站 https://giscus.app/,进行配置:
- 语言:选择你目前正在使用的语言
- 仓库:填写你刚刚创建的仓库(格式为你的用户名/仓库名)
- 页面 ↔️ discussion 映射关系(默认即可)
- Discussion 分类(默认即可)
- 特性(默认即可)
- 主题(默认即可)
按照顺序配置好之后,下方会自动生成
`<script src="https://giscus.app/client.js" data-repo="[在此输入仓库]" data-repo-id="[在此输入仓库 ID]" data-category="[在此输入分类名]" data-category-id="[在此输入分类 ID]" data-mapping="pathname" data-strict="0" data-reactions-enabled="1" data-emit-metadata="0" data-input-position="bottom" data-theme="preferred_color_scheme" data-lang="zh-CN" crossorigin="anonymous" async></script>`添加评论到指定页面#
只需要在每个页面对应的.astro文件中的</MainGridLayout>前面添加上方生成的代码即可。
比如我要在文章页面添加评论,找到src\pages\posts\[...slug].astro文件,在文件中找到</MainGridLayout>标签,在其前面添加上方生成的代码即可。
`<Icon name="material-symbols:chevron-right-rounded" class="text-[2rem] text-[var(--primary)]" /> </div>} </a> </div><!-- giscus评论 -->+ <script src="https://giscus.app/client.js"+ data-repo="AULyPc/aulypc.github.io"+ data-repo-id="xxxxxxxxxxx"+ data-category="Announcements"+ data-category-id="xxxxxxxxxxxxx"+ data-mapping="pathname"+ data-strict="0"+ data-reactions-enabled="1"+ data-emit-metadata="0"+ data-input-position="top"+ data-theme="preferred_color_scheme"+ data-lang="zh-CN"+ crossorigin="anonymous"+ async>+</script></MainGridLayout><style is:global>#post-container :nth-child(1) { animation-delay: calc(var(--content-delay) + 0ms) }#post-container :nth-child(2) { animation-delay: calc(var(--content-delay) + 50ms) }#post-container :nth-child(3) { animation-delay: calc(var(--content-delay) + 100ms) }#post-container :nth-child(4) { animation-delay: calc(var(--content-delay) + 175ms) }#post-container :nth-child(5) { animation-delay: calc(var(--content-delay) + 250ms) }#post-container :nth-child(6) { animation-delay: calc(var(--content-delay) + 325ms) }</style>`最后效果如图 
支持与分享
如果这篇文章对你有帮助,欢迎分享给更多人或打赏支持!
Firefly博客添加评论功能
https://firefly.cuteleaf.cn/posts/20260807-firefly-comments/相关文章智能推荐
1
通过 Google Workspace 实现 14 人民币每年购买 com net 等顶级域名(续费同价)
域名2026-08-07
2
宝可梦机场之八月免费兑换码猜猜我是谁(答案:飞天螳螂)
机场2026-08-01
3
宝可梦机场之七月免费兑换码猜猜我是谁(答案:小火马)
机场2026-07-01
4
Firefly 一款清新美观的 Astro 博客主题模板
文章示例Firefly 是一款基于 Astro 框架和 Fuwari 模板开发的清新美观且现代化个人博客主题模板,专为技术爱好者和内容创作者设计。该主题融合了现代 Web 技术栈,提供了丰富的功能模块和高度可定制的界面,让您能够轻松打造出专业且美观的个人博客网站。
5
Firefly 简单使用指南
博客指南如何使用 Firefly 博客模板。
随机文章随机推荐














