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
}

有了这两文件就好了

相关推荐
LiaCode32 分钟前
别让 AI 把仓库写成“代码平行宇宙”:从 Deslop 看生成前查重
前端·后端·github
m4Rk_1 小时前
【论文阅读】Agent 记忆机制(62):DCM-Agent——用双簇记忆化解优化问题的多范式冲突
论文阅读·人工智能·学习·开源·github
逛逛GitHub2 小时前
GPT-6 Astra 上线 24 小时,看看外网爆火的惊艳玩法。
github
golang学习记2 小时前
Cursor Origin:Cursor要造一个AI时代的Github
人工智能·github·cursor
u1301302 小时前
GitHub 热榜项目:日榜(2026-09-06)
github
mr_g4 小时前
SmartCall源码解析:实时对话轮次拦截器RealtimeTurnInterceptor实现原理
github
zzzll11115 小时前
新手如何使用 GitHub?从零开始的完整入门指南
github
CoderJia程序员甲6 小时前
GitHub 热榜项目 - 周榜(2026-09-06)
ai·大模型·llm·github·ai教程
zzzzzz31010 小时前
picoclaw:从“迷你部署代理”看轻量化项目该怎样被理解
人工智能·开源·github
DeepAgent1 天前
AI Agent 项目赏析:DeerFlow 2.0 —— 一个真正“长跑“的 SuperAgent 是怎么设计出来的?
github·agent