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
}

有了这两文件就好了

相关推荐
Smoothcloud润云9 小时前
从“预测下一个词”到“预测下一个世界状态”:世界模型作为AGI新范式的深度分析报告
人工智能·测试工具·微服务·容器·github·状态模式·agi
CoovallyAIHub12 小时前
ICLR 2026 | VLM自己学会调检测器:VTool-R1用强化学习教视觉模型使用工具推理
算法·架构·github
CoovallyAIHub12 小时前
RK3588上111 FPS:轻量YOLOv8+异步视频处理系统实现无人机自主电力巡检
算法·架构·github
逛逛GitHub17 小时前
一个饺子馆在 GitHub 上开源了自己的 Skill。 北京海淀,杏坛路,北京邮电大学旁边,有一家快 20 年的饺子馆——金谷园。 好像几乎所有的北邮小伙
github
CoderJia程序员甲18 小时前
GitHub 热榜项目 - 日榜(2026-04-13)
ai·大模型·github·ai教程
BothSavage18 小时前
OpenHarness源码研究-1-配置打包管理
github
FreeBuf_18 小时前
黑客滥用 GitHub 和 GitLab 托管恶意软件并实施凭证钓鱼攻击
gitlab·github
三无推导19 小时前
GitHub爆火项目ChinaTextbook——开源如何重新定义教育普惠的边界
学习·开源·github
韩数20 小时前
为了能同时开发多个项目,我烧了几亿 token 开源了一个轻量级 AI-Native IDE
后端·程序员·github
硬汉嵌入式20 小时前
GitHub Copilot for Eclipse 即将开源
eclipse·github·copilot