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
}

有了这两文件就好了

相关推荐
dong_junshuai3 分钟前
每天一个开源项目#59 AirLLM:27.6K星,3.72GB显存跑2.8T模型
人工智能·程序员·github
lpfasd1235 分钟前
2026年第31周GitHub趋势周报
github
Jul1en_1 小时前
【Claude Code Compact】源码级别的学习上下文压缩
java·前端·学习·github·ai编程
逛逛GitHub2 小时前
Karpathy 刚发了一个帖子,怎么判断一个新模型到底行不行?
github
m4Rk_3 小时前
【论文阅读】Agent 记忆机制(28):MEM1——将记忆压缩融入推理,实现近似恒定上下文的长程智能体
论文阅读·人工智能·学习·开源·github
逛逛GitHub3 小时前
盘点 17 个 7 月份 GitHub 上夯夯夯的开源项目。
github
在水一缸6 小时前
从“反向技能“到协作革命:当开源重新定义AI编程助手
开源·github·ai编程·开发者工具·ai编程助手·ai协作·claude cowork
用户526835677908 小时前
存储运维实战:基于 Ceph Event 监听与 Python 适配器的分布式存储健康度物理声光响应架构
github
dong_junshuai8 小时前
每天一个开源项目#58 DwarfStar:2万星原生引擎,让DeepSeek V4跑在Mac上
github
ZeroNews内网穿透9 小时前
无公网 IP 打通 CI/CD:内网穿透对接 GitHub Actions 自动部署内网服务
运维·tcp/ip·ci/cd·github·远程工作·内网穿透