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
}

有了这两文件就好了

相关推荐
粥里有勺糖10 小时前
视野修炼-技术周刊第139期 | AI 不会让时间变多
前端·github·ai编程
一点一木12 小时前
🚀 2026 年 11 月 GitHub 十大热门项目排行榜 🔥
人工智能·github
OpenTiny社区14 小时前
当 AI 开始写 UI,我们缺的不是模型,是"设计词汇"
前端·github·ai编程
逛逛GitHub14 小时前
Codex 自带的远程功能用着不爽,直接换成这个远程控制神器了。
github
CoderJia程序员甲14 小时前
GitHub 热榜项目 - 周榜(2026-11-28)
github
LiuPig刘皮哥15 小时前
github桌宠desktop-pet star前22在干嘛?
github·桌宠·xiaokeai
七牛云行业应用15 小时前
Antigravity 迁移清单:Claude Code、Codex、Cursor 哪些能带过来
人工智能·ai·github
欧雷殿16 小时前
没有数据勿谈智能:揭秘我的数据底座
数据挖掘·github·ai编程
心如鉄补18 小时前
GitHub Actions 自动化:5 个真实运维提效案例
运维·自动化·github
徐小夕19 小时前
万字分享:CRDT 算法在 Word 文档中的工程化落地
前端·vue.js·github