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
}

有了这两文件就好了

相关推荐
Jiude5 小时前
AI 写代码太快之后,团队协作反而更难了
人工智能·架构·github
2401_876964139 小时前
27考研余炳森概率论|喻老李良2027资料网课
windows·git·考研·svn·eclipse·github·概率论
AhriProGramming9 小时前
GitHub开源项目推荐-1:pyd_packer
github
独自归家的兔10 小时前
AI界的 GitHub?Hugging Face 全面解析
人工智能·github
逛逛GitHub12 小时前
GitHub 上刚开源的国产 3D 高斯浏览器,杭州六小龙给力啊。
github
code_li14 小时前
免费服务器指南:GitHub Pages搭建静态网站全攻略
github·部署·免费服务器
阿里嘎多学长15 小时前
2026-05-28 GitHub 热点项目精选
开发语言·程序员·github·代码托管
小小程序员mono16 小时前
模型进入「日更时代」:GPT-5.6 泄露、Claude 4.8 逼近、Gemini 3.5 上线、国产杀疯了摘要
人工智能·重构·开源·github
Larcher16 小时前
「Codex + DeepSeek 用户请进:你的对话记录是不是也卡到想砸键盘?」
人工智能·github·编程语言
程序员柒叔18 小时前
Dify 一周动态-2026-W22
人工智能·大模型·github·agent·知识库·dify