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
}

有了这两文件就好了

相关推荐
雾岛心情11 分钟前
【小铭邮件】小铭邮件管理工具箱之利用CSV同步日历
github·工具·邮件·小铭邮件工具箱·o365
MicrosoftReactor19 分钟前
技术速递|面向初学者的 GitHub Copilot CLI:交互模式与非交互模式
ai·github·copilot·cli
梁辰兴22 分钟前
Dev-Sidecar 下载与安装
github·dns·软件分享·dev-sidecar·开源仓库
程序员柒叔1 小时前
OpenClaw 一周动态-2026-W23
人工智能·github·agent·openclaw
呆萌的代Ma1 小时前
解决docker网络问题,通过GitHub Actions打包dockerfile
docker·容器·github
jingling5552 小时前
gitHub开源项目 | 不用剪辑技能,也能做出 Screen Studio 级演示视频:开源 Recordly 值得试试
开源·github·音视频
comcoo2 小时前
Windows 部署龙虾 AI OpenClaw,快速构建本地私有化 AI 智能体
人工智能·github·开源软件·open claw·open claw部署
傻啦嘿哟3 小时前
日志分析:利用OpenClaw日志排查“403”和“503”错误
java·git·github
Soari3 小时前
GitHub 开源项目解析:microsoft/markitdown —— 面向 LLM 的多格式文档转 Markdown 工具
microsoft·开源·github·markdown·rag
摆烂菜鸡沧9963 小时前
【自用记录】修改GitHub提交历史作者
git·github