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
}

有了这两文件就好了

相关推荐
蚕豆糯米饭4 小时前
Github Copilot 研发效能提升实战指南
ai·github·copilot·ai编程
AlfredZhao6 小时前
GitHub 克隆他人私有仓库:从授权到下载
github
智能制造产品经理代码提升7 小时前
Windows Git 多 GitHub 账号切换(GCM 管理凭据,不覆盖原有账号)
github
Wang's Blog8 小时前
Java框架快速入门: Spring Security+OAuth2之核心角色与授权流程
java·spring·github
dong_junshuai8 小时前
每天一个开源项目#100 OpenCodeReview:2.6万星的低噪声AI审查器
程序员·开源·github
峰向AI8 小时前
还在用 Ableton?这个 3.5K Star 的免费音序器,让你在手机上写微分音音乐
github
SL_staff9 小时前
战略落地的最后一公里:从目标到个人日历的自动化链路实现
java·github·全栈
凌奕9 小时前
OpenCodeReview 架构拆解:AI Code Review 为什么不能只是 Git Diff + LLM?
llm·github·agent
m4Rk_13 小时前
【论文阅读】Agent 记忆机制(70):RecMem——只在记忆反复出现时才调用 LLM 做巩固
论文阅读·人工智能·学习·开源·github
u13013014 小时前
GitHub 热榜项目:日榜(2026-09-14)
人工智能·github