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
}

有了这两文件就好了

相关推荐
uhakadotcom2 小时前
Python 中,`None` 不等于 `False`导致的问题
后端·面试·github
小弥儿4 小时前
GitHub今日热榜 | 2026-07-05:阿里巴巴浏览器Agent上榜
学习·开源·github
uhakadotcom5 小时前
什么是 “无界限的列表积累” 问题
后端·面试·github
AC赳赳老秦21 小时前
防火墙规则批量配置实战:OpenClaw 自动生成模板、批量下发与合规性校验全解析
java·开发语言·人工智能·python·github·php·openclaw
FPGA验证小袁1 天前
EMIF BFM设计与实现:把复杂时序装进“一键读写”的黑盒
github
汤姆yu1 天前
macOS系统下Aider完整安装、配置与实战使用教程
大数据·人工智能·算法·macos·github·copilot
小弥儿1 天前
GitHub今日热榜 | 2026-07-04
学习·开源·github
CoderJia程序员甲1 天前
GitHub 热榜项目 - 周榜(2026-07-04)
ai·大模型·llm·github
REDcker1 天前
GitHub SSH 连接失败排障实录
运维·ssh·github
菜鸟是大神1 天前
【Hermes入门11讲】第七讲:定时自动化——让Hermes成为你的24小时助手
人工智能·github·hermes