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程序员甲2 小时前
GitHub 热榜项目 - 日榜(2026-03-08)
ai·大模型·llm·github·ai教程
车骑7 小时前
用 EasyBot 搭一个「一人内容工作台」,文图视频全搞定
大模型·github
CoderJia程序员甲8 小时前
GitHub 热榜项目 - 日榜(2026-03-10)
人工智能·ai·大模型·github·ai教程
CoderJia程序员甲8 小时前
GitHub 热榜项目 - 日榜(2026-03-11)
github
研究点啥好呢11 小时前
3月10日GitHub热门项目推荐|自动化的浪潮
运维·人工智能·ai·自动化·github
IT 行者12 小时前
每天了解几个MCP SERVER:GitHub
github·mcp
AI成长日志13 小时前
【GitHub开源项目】OpenClaw深度解析——开源多模态大模型系统的架构设计与核心实现
人工智能·系统架构·开源·github
宝桥南山13 小时前
GitHub Copilot - 尝试一下Plan mode
microsoft·微软·github·aigc·copilot·ai编程
J心流13 小时前
SSH远程连接 github/云效 的操作流程
运维·ssh·github
ascarl201013 小时前
Kylin V10 服务器,解决Xorg 占用内存很高的问题
服务器·github·kylin