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
}

有了这两文件就好了

相关推荐
CoderJia程序员甲3 小时前
GitHub 热榜项目 - 周榜(2026-09-26)
ai·大模型·llm·github
miofly8 小时前
GitHub 周榜趋势速报 | 2026-10-02
开源·github
阿里嘎多学长9 小时前
2026-09-29 GitHub 热点项目精选
开发语言·程序员·github·代码托管
老李IT笔记11 小时前
激活锁状态怎么检测:三个入口,四种返回值,一份排查顺序
git·智能手机·github
m4Rk_12 小时前
【论文阅读】Agent 记忆机制(87):VizoMem——把文本历史转化为可检索的视觉记忆
论文阅读·人工智能·学习·开源·github
lpfasd12312 小时前
GitHub非AI开源方向调研报告
人工智能·开源·github
hasty12 小时前
签名是真的,分支却不对:GitHub CLI 制品证明的大小写边界
github
u13013015 小时前
GitHub 热榜项目:日榜(2026-10-01)
人工智能·github
漂着的圆木15 小时前
Agent执行安全:Taskflow无容器架构风险边界核对
github·安全架构·ai agent·部署边界
miofly15 小时前
GitHub 今日推荐|archify:AI 代理自动生成可交互架构图的技能模块
开源·github