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
}

有了这两文件就好了

相关推荐
Hommy885 小时前
【剪映小助手】视频处理接口
开源·github·音视频·视频剪辑自动化·剪映api
铁皮哥6 小时前
【agent 开发】Claude Code 的 Skill 是怎么被加载的?从 name/description 到 SKILL.md 再到资源文件
java·服务器·数据库·python·gitee·github·软件工程
老虎海子7 小时前
从零手搓一个 AI 编程助手:Mini Claude Code 完全指南
人工智能·git·vscode·python·github
lxllzwj52013149 小时前
Mac如何像shell一样丝滑的使用item2连接服务器.
服务器·macos·github
开发者每周简报10 小时前
十个奇异 github 项目
github
Arden Zhao10 小时前
Gihtub HTTP添加为HTTPS证书
https·github
HelloGitHub10 小时前
《HelloGitHub》第 122 期
开源·github
上海云盾-小余11 小时前
服务器入侵应急处置:入侵排查与溯源恢复全流程
运维·服务器·github
lpfasd12311 小时前
2026年第21周GitHub趋势周报
github
纪伊路上盛名在11 小时前
Github 命令行搜索工具
人工智能·数据分析·github