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
}

有了这两文件就好了

相关推荐
m4Rk_20 分钟前
【论文阅读】Agent 记忆机制(54):MINJA——普通用户如何仅通过查询污染 Agent 的长期记忆
论文阅读·人工智能·学习·开源·github
峰向AI21 分钟前
公众号创作 Skill 集合:从定位到排版,终于有流水线了
github
苏灿烤鱼11 小时前
没有机密文件,也没有付费数据,在浏览器里造一颗"间谍卫星"
前端·javascript·github
粥里有勺糖14 小时前
视野修炼-技术周刊第131期 | Bun 与 pnpm Rust 化
前端·github·agent
旅之灵夫17 小时前
【GitHub项目推荐--HyperFrames:用 HTML 写视频,为 AI Agent 而生的渲染框架】
github
峰向AI18 小时前
阿里内部用了2年的代码审查工具开源了:21k Star背后的「工业级」设计
github
zandy101118 小时前
2026vibe coding背后 :Kimi Code、Cursor、Claude Code、GitHub Copilot等五款工具架构演进全面分析
架构·github·copilot
zandy101118 小时前
网络支付合规三重门:Kimi Code、Cursor、GitHub Copilot等五款AI编程工具国内实战测评
github·copilot·ai编程
ssshooter20 小时前
Tauri + GitHub Actions 自动化发布 Android APK 技术总结
android·github·android studio
wdfk_prog21 小时前
GitHub push 失败:如何扫描并清理 Git 历史中的大文件
git·elasticsearch·github