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
}

有了这两文件就好了

相关推荐
mjhcsp29 分钟前
Github Copilot 新手极速上手指南
github·copilot
重生之我来学Python1 小时前
Git-SVN 混合开发,从入门到精通!
开发语言·git·svn·github
u1301301 小时前
GitHub 热榜项目:日榜(2026-09-05)
github
m4Rk_2 小时前
【论文阅读】Agent 记忆机制(61):CFGM——用粗到细的记忆落地贯通经验采集、知识蒸馏与在线纠错
论文阅读·人工智能·学习·开源·github
是2的10次方啊2 小时前
GitNexus:给 AI 代理装上代码知识图谱
github
其实防守也摸鱼3 小时前
OpenClaw 深度解析:从原理到实战的完整指南
运维·服务器·数据库·github·copilot
峰向AI4 小时前
产品经理神器:PRD 直接变可点击网页!
github
Rescenix4 小时前
流式瀑布渐变闪烁根治-硬核技术版
架构·github
阿里嘎多学长5 小时前
2026-09-05 GitHub 热点项目精选
开发语言·程序员·github·代码托管
纪伊路上盛名在5 小时前
Github workflow中如何设置private环境变量
github·workflow·actions·private·api key