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
}

有了这两文件就好了

相关推荐
Debug的新时代农民工13 小时前
git 冲突
github
瞎掰13 小时前
我开源了一个 Web 扫描器,在 Metasploitable 2 上发现了 83 个漏洞
github
dhjabc_115 小时前
从0到1打造一个GitHub优质资源管理器(一个完整的PyQt6桌面项目实战日记)
github
runafterhit19 小时前
开源知识库GitHub使用经验总结
开源·github
Yunzenn20 小时前
深度解析字节前沿研究-Cola DLM第 04 章:Cola DLM 架构全景 —— 三层解耦的设计哲学
java·linux·python·深度学习·面试·github·transformer
阿里嘎多学长21 小时前
2026-05-21 GitHub 热点项目精选
开发语言·程序员·github·代码托管
杖雍皓1 天前
编程范式的下一次跃迁:深度解析全新的 GitHub Copilot 独立桌面应用
github·copilot
JiaWen技术圈2 天前
GitOps 最佳实践:ArgoCD + GitHub Actions 完整落地
github·argocd
王二麻子6662 天前
Ctrl+V 粘贴截图,Claude Code + DeepSeek 直接烂对话?这个开源项目把坑填了
github