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
}

有了这两文件就好了

相关推荐
小弥儿2 小时前
GitHub今日热榜 | 2026-09-01:迷你小模型登场
学习·microsoft·开源·github
QUOR3 小时前
Zorv AI 内置浏览器技术架构与开发指南(新版)
架构·github
u1301303 小时前
GitHub 热榜项目:日榜(2026-09-01)
github
younuo36553 小时前
广州网站搭建费用明细:域名、服务器与开发成本全解析
服务器·前端·github
百变梦仔3 小时前
Codex 启动回复合格后,我会用三类证据验收前端改动
前端·github
峰向AI18 小时前
316k+ Star 史上第二热门项目,没有一行代码
github
dong_junshuai18 小时前
每天一个开源项目#86 ECC:245K星的 Agent 工程操作层
开源·github·agent
Natural20 小时前
混合检索 + RRF + Rerank 实战评测:三条路线在 47 个真实问题上的取舍
github
一点一木21 小时前
憋了7周没动静,OpenClaw 2.0带着16000个PR杀回来了
人工智能·github
一点一木1 天前
🚀 2026 年 8 月 GitHub 十大热门项目排行榜 🔥
人工智能·github