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
}

有了这两文件就好了

相关推荐
编程修仙7 小时前
github的使用
github
白驹过隙^^8 小时前
OB-USP-AGENT安装使用方法
数据库·经验分享·网络协议·tcp/ip·github·ssl
xlp666hub9 小时前
手写 Linux 并发服务器,fork, pthread与 epoll 模型实战(包含深层原理剖析)
github·c
火车叼位10 小时前
小白也能学会:AI分离人声 + FFmpeg替换音轨全流程
github
程序媛Dev11 小时前
平台工程新范式:我扔掉了本地环境,开发体验直接起飞。
github
逛逛GitHub11 小时前
这个 GitHub 神器让 Gemini 写的网站 3 秒上线,累计部署 67 万个网站。
github
GZKPeng11 小时前
github 新版本网页如何对repository管理人员
github
CoderJia程序员甲15 小时前
GitHub 热榜项目 - 日榜(2025-12-16)
llm·github·ai教程
bj_zhb16 小时前
Git 回退到某个 commit
git·github
openinstall全渠道统计16 小时前
开发者指南:广告投放系统搭建与前后端数据打通全流程
windows·git·oracle·eclipse·sqlite·github