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
}

有了这两文件就好了

相关推荐
码流怪侠几秒前
【GitHub】Strix 深度解析:开源 AI 渗透测试工具的架构、原理与实战
github·agent·ai编程
OpenTiny社区3 小时前
Coding Agent 到底是怎么工作的,它又为什么会在复杂代码库里失真?
前端·github·agent
王飞飞不会飞6 小时前
macbert训练过程记录
人工智能·github
じ☆ve 緈辐6 小时前
使用github上传代码(包含视频)
github
阿拉雷️8 小时前
AI编程工作流搭建实战:用Codex+Claude+GitHub Copilot搭了一套完整流水线
github·copilot·ai编程
杖雍皓9 小时前
没有服务器如何构建现代 Web 应用:平台选型与组合策略
运维·服务器·前端·react.js·github·netlify·vercel
修己xj19 小时前
差生文具多?我给自己改造了一款AI周计划工具
github
阿里嘎多学长1 天前
2026-07-07 GitHub 热点项目精选
开发语言·程序员·github·代码托管
GoGeekBaird1 天前
我最近在写 BeeWeave,想把 Agent 用过的上下文留住
后端·github·ai编程