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
}

有了这两文件就好了

相关推荐
cnnews25 分钟前
Ubuntu 编译 postmarketOS
linux·运维·arm开发·ubuntu·github·音视频
逛逛GitHub2 小时前
把最新开源的 2B 端侧模型接入 DeepSeek Harness,有点子神奇。
github
Boop_wu4 小时前
[redis] redis 快速入门
数据库·redis·github
m4Rk_5 小时前
【论文阅读】Agent 记忆机制(63):SAMem——把经验记忆细化为带长期价值的状态—Thought
论文阅读·人工智能·学习·开源·github
海盗12346 小时前
AI 新闻日报 2026-09-07:GitHub 多模型编排、OpenClaw 2.0 多智能体、人形机器人破人类纪录
人工智能·机器人·github
u1301306 小时前
GitHub 热榜项目:日榜(2026-09-07)
github
QUOR6 小时前
ZorvAI 可视化小卡片:七层自研 Canvas 渲染引擎架构全解析
github
可乐ea6 小时前
一个任务一条「模型流水线」:GitHub HydraFusion 多模型运行时编排拆解
github·ai智能体·agent架构·多模型编排·大模型路由
程序员柒叔7 小时前
Dify -- 定时任务系统
人工智能·github·agent·dify·rag
阿里嘎多学长8 小时前
2026-09-07 GitHub 热点项目精选
开发语言·程序员·github·代码托管