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
}

有了这两文件就好了

相关推荐
u1301301 小时前
GitHub 热榜项目:月榜(2026-09-30)
人工智能·github
m4Rk_3 小时前
【论文阅读】Agent 记忆机制(86):Skill-Pro——用 Non-Parametric PPO 将交互经验演化为可复用技能
论文阅读·人工智能·学习·开源·github
别动我齐刘海3 小时前
简历技术栈全面复习——UDP / TCP / CAN / ZMQ / Protobuf 通信工程
网络·c++·python·tcp/ip·机器学习·udp·github
data analyse 4565 小时前
埋点工具的私有化部署成本高吗?
前端·数据分析·github
miofly7 小时前
GitHub 今日推荐|company-brain:在 Slack 里给团队装个会主动干活的 AI
开源·github
用户3831703705411 小时前
PowerFS 是用 Rust 写的、面向 AI/GPU 训练的下一代分布式文件系统
github
钮钴禄·爱因斯晨12 小时前
用iPhone操作Codex CLI:ToDesk远程终端让我接回了开发环境
github
miofly13 小时前
GitHub 日榜趋势速报 | 2026-10-01
开源·github
阿里嘎多学长14 小时前
2026-09-30 GitHub 热点项目精选
开发语言·程序员·github·代码托管
miofly1 天前
GitHub 今日推荐|DiPlay:让 iPhone CarPlay 直连 BYD 车机,无需硬件适配器
开源·github