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
}

有了这两文件就好了

相关推荐
摆烂菜鸡沧9967 分钟前
【自用整理】本地关联GitHub多账号设置
git·github
yuanyuan2o228 分钟前
Transformers NLP 任务:阅读理解问答
人工智能·算法·自然语言处理·nlp·github
nebula-AI29 分钟前
Understand Anything 简要使用文档
人工智能·ai·github·项目管理·知识图谱·dashboard
MicrosoftReactor31 分钟前
技术速递|使用 GitHub Copilot CLI 构建 Emoji 列表生成器
ai·github·copilot·cli
带娃的IT创业者2 小时前
1-Click GitHub Token Stealing:深入解析 VSCode 中的惊险漏洞
ide·vscode·github·安全漏洞·github token·1-click
lauo2 小时前
ibbot手机:一部手机,双重革命
人工智能·智能手机·架构·开源·github
JavaGuide17 小时前
Claude Code 怎么学?推荐 4 个高质量开源教程,从入门到实战
github·ai编程·claude
我命由我1234518 小时前
Android 开发问题:Could not find com.github.PicnicSupermarket:FingerPaintView:1.2.
android·github·android studio·安卓·android jetpack·android-studio·android runtime
行走__Wz18 小时前
本地项目初次上传到GitHub教程
github
CoderJia程序员甲19 小时前
GitHub 热榜项目 - 周榜(2026-05-31)
ai·大模型·llm·github·ai教程