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
}

有了这两文件就好了

相关推荐
遁神银灵子27 分钟前
OMO(oh-my-openagents)插件在OpenCode Desktop v1.4.33以上版本失效问题研究
github
码流怪侠2 小时前
【GitHub】TextGen:开源本地大模型运行平台的终极解决方案
python·程序员·github
小雨青年2 小时前
GitHub Copilot Commit Message 生成与自定义配置优化指南
人工智能·github·copilot
无限进步_2 小时前
【C++】AVL树完全解析:从平衡因子到四种旋转
c语言·开发语言·数据结构·c++·后端·算法·github
华万通信king3 小时前
2026 年 GitHub AI 趋势周报:Skills 生态崛起,Agent 框架去中心化
人工智能·去中心化·github
逛逛GitHub4 小时前
GitHub 上 3.7 万的 Star,终端里浏览文件的开源工具。
github
GISer_Jing4 小时前
基于 GitHub Actions 端到端工程化落地——AI全栈项目实战案例
人工智能·github
YuePeng18 小时前
我用 30 行 Java 注解,做出了别人花三周写的管理后台,还顺手接入了 DeepSeek
后端·github
无心水20 小时前
【Hermes:MCP 与工具实战】28、GitHub MCP 深度实战:PR 审查、Issue、自动汇报全搞定
人工智能·github·issue·openclaw·养龙虾·hermes·honcho
逛逛GitHub21 小时前
GitHub 上狂揽 1.8 万 Star!开源平替的 Claude Design。
github