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
}

有了这两文件就好了

相关推荐
面包狗AI4S9 小时前
GitHub AI4S 项目观察(2026-08-07—2026-08-13)
人工智能·github
华科大胡子10 小时前
GitHub Actions自动化运维实战技术文章大纲
github
fthux10 小时前
装闭 RenoPit 源码解析(14):Demo模式、健康检查与Docker部署
人工智能·ai·开源·github·open source·renopit
TunerT_TQ11 小时前
Meta React 源码静态评测:从 4540 个源文件看 React Compiler 的工程化演进
meta·开源·github
峰向AI12 小时前
再也不怕换工具失忆了:它给 AI 编程助手装上"长期记忆"
github
tokenKe13 小时前
AirLLM:一张 4GB 显卡,把 70B 模型“流“起来 |SSP Github Daily
github
喜乐MI18 小时前
Git 分支操作避坑指南:merge、cherry-pick、revert 与 reset 怎么选?
git·github
程序员老赵18 小时前
Docker 部署禅道 ZenTao:轻松搭建研发项目管理平台
前端·后端·github
敢敢是只喵i19 小时前
已经登录 BailingHub,为什么 AI 还是不能查询订单?匿名预览与业务身份不是一回事
github
dong_junshuai19 小时前
每天一个开源项目#73 Munder Difflin:2.3K Star 的本地多Agent办公室
开源·github·agent