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
}

有了这两文件就好了

相关推荐
CoovallyAIHub13 分钟前
VisionClaw:智能眼镜 + Gemini + Agent,看一眼就能帮你搜、帮你发、帮你做
算法·架构·github
CoovallyAIHub23 分钟前
低空安全刚需!西工大UAV-DETR反无人机小目标检测,参数减少40%,mAP50:95提升6.6个百分点
算法·架构·github
橙露1 小时前
Shell 脚本实战:自动化备份、监控、告警脚本模板
运维·自动化·github
FollowHeart2 小时前
自建私有日记本:MyDiary —— 属于你的 NAS 极简写作空间
vue.js·github
阿里嘎多学长2 小时前
2026-03-31 GitHub 热点项目精选
开发语言·程序员·github·代码托管
逛逛GitHub3 小时前
把 Claude Code 变成你的桌面宠物,这个开源项目好有创意啊。
github
Goodwin3 小时前
TypeScript 成 AI 应用层标配?GitHub Trending 告诉你2026前端往哪走
前端·人工智能·github
七夜zippoe4 小时前
OpenClaw 多渠道统一管理:构建全平台智能消息中枢
开发语言·microsoft·github·多渠道·openclaw
scilwb7 小时前
SolidWorks导出URDF导入Isaac Sim报错崩溃?一键清洗与修复工具开源
github
一点一木7 小时前
🚀 2026 年 3 月 GitHub 十大热门项目排行榜 🔥
人工智能·github