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
}

有了这两文件就好了

相关推荐
穆梓兰煊4 分钟前
Flutter端云协同推理架构解析
flutter·github
七牛云行业应用1 小时前
DeepSeek Harness 自定义 Skill 教程:从 SKILL.md 到可复用 Agent 工作流
算法·github
逛逛GitHub2 小时前
清华在 GitHub 上开源的 Agent 工作台,最近更新了 2.0 版本。
github
u1301303 小时前
GitHub 热榜项目:日榜(2026-10-14)
人工智能·github
誰能久伴不乏5 小时前
QT工业上位机一次「指令静默丢失」的排查
qt·docker·github
胡大伟5 小时前
麦当劳的开发者大赛:麦当劳 MCP 实测——一个藏在 inputSchema 里的参数
github
大苦根5 小时前
RAG 重排器对比:从 Bi-Encoder 到 Cross-Encoder,以及为什么 bge-reranker-v2-m3 是中文 RAG 的默认答案
github
大苦根5 小时前
RAPTOR 树状检索:从论文到一份能跑的代码,以及它为什么不是银弹
github
阿里嘎多学长5 小时前
2026-10-14 GitHub 热点项目精选
开发语言·程序员·github·代码托管
zzu123zsw6 小时前
不只是命令行补全:GitHub Copilot SDK 如何把 CLI 智能体引擎嵌入企业工作流?
github·copilot