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 分钟前
深度重构:Agent Skills——从 Prompt 工程到能力工程
javascript·架构·github
csdn_aspnet4 小时前
GitHub Actions自动化运维实战,用CI/CD流水线实现测试、部署、安全扫描一体化
运维·安全·ci/cd·自动化·github
BerrySen1786 小时前
我的AI辅助开发工具链2026版
开源·github
dong_junshuai7 小时前
每天一个开源项目#40 Apache Ossie:1K Stars的AI/BI语义层通用标准
github
Lary_Rock7 小时前
MTK SecureBoot全链路配置指南
前端·vscode·github
逛逛GitHub8 小时前
终于有一个蒸馏 Apple 风格的 Skill 了,GitHub 上有 10.5K 人点赞。
github
dong_junshuai13 小时前
# 每天一个开源项目#39 Hallmark:9.5K Stars,58道门禁拒绝AI设计味
github
小弥儿13 小时前
GitHub今日热榜 | 2026-07-16:AI知识库与反AI味设计成今日双主线
人工智能·学习·github
不加糖43514 小时前
CI/CD 与 GitHub Actions 入门
ci/cd·github
gis开发之家14 小时前
《Vue3 从入门到大神32篇》Vue3 源码详解(二):从 GitHub Clone 到断点调试,手把手搭建源码阅读环境
vue.js·前端框架·github·vue3·vue3源码