vitepress搭建的博客系统cdn引入github discussions评论系统

github仓库必须是公开的

按照CDN的方式引入

打开discussions模块

安装giscus app


配置giscus

就是刚安装了giscus app的仓库

页面往下走,生成了代码:

配置vitepress

采用了CDN的方式引入

使用web component

随便找个地方试试组件

效果

有了

优化

那么多页面,一个一个的添加评论组件不现实。封装个评论组件覆盖原来的vitepress layout

  1. 在.vitepress目录下的theme目录下创建组件
html 复制代码
<!-- Layout.vue -->
<template>
  <Layout>
    <template #doc-after>
      <giscus-widget
        id="comments"
        repo="chergn/questions"
        repoid=""
        category="Announcements"
        categoryid=""
        mapping="title"
        term="Welcome to giscus!"
        reactionsenabled="1"
        emitmetadata="0"
        inputposition="top"
        theme="light"
        lang="en"
        loading="lazy"
      ></giscus-widget>
    </template>
  </Layout>
</template>

<script lang="ts" setup>
import DefaultTheme from "vitepress/theme";
const { Layout } = DefaultTheme;
</script>
  1. 在.vitepress目录下的theme目录下的index.js文件配置layout
javascript 复制代码
import DefaultTheme from 'vitepress/theme'
import CommentLayout from './CommentLayout.vue'

export default {
  extends: DefaultTheme,
  // 使用注入插槽的包装组件覆盖 Layout
  Layout: CommentLayout
}

有了这两文件就好了

相关推荐
峰向AI10 小时前
24000本书,一个项目全搞定:这个开源宝藏让我重新认识了读书
github
mCell10 小时前
GitHub Actions 玩法大赏:一台远程主机的七种活法
linux·github·agent
hajimi10 小时前
Agent Skill 实战:我把大疆行业无人机上云的坑,固化成了一个技能包
github
笨鸟先飞,勤能补拙13 小时前
AI与深度学习:从原理到应用
人工智能·windows·vscode·深度学习·机器学习·网络安全·github
前端小卡拉13 小时前
DeepSeek 把 Agent Harness 开源了:Everything is a Plugin,一个手搓过 harness 的人怎么看
github
TunerT_TQ14 小时前
Microsoft 微软 Fluent UI 源码静态评测:从工程结构、测试线索到交付治理的完整解读
microsoft·开源·github
逛逛GitHub15 小时前
国产桌面端 Agent 进化了,支持定时任务、接入Obsidian、丰富SKill
github
子林super15 小时前
OpenCode的Harness机制与模块
github
fthux15 小时前
装闭 RenoPit 源码解析(12):从AI分析结果到React避坑报告
人工智能·ai·开源·github·open source·renopit
TunerT_TQ15 小时前
Microsoft 微软 AI-For-Beginners 静态评测:一套 AI 入门课程,为什么不能只按代码仓库来评价?
microsoft·开源·github