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
}

有了这两文件就好了

相关推荐
CoderJia程序员甲9 小时前
GitHub 热榜项目 - 日榜(2026-02-05)
ai·开源·大模型·github·ai教程
weixin_66810 小时前
GitHub 2026年AI项目热度分析报告-AI分析-分享
人工智能·github
MicrosoftReactor12 小时前
技术速递|GitHub Copilot CLI 斜杠命令速查表
github·copilot·cli
wu~97012 小时前
GitHub永不遗忘,使用git push -f来覆盖的提交依旧保留
git·github
m0_6948455713 小时前
music-website 是什么?前后端分离音乐网站部署实战
linux·运维·服务器·云计算·github
独自破碎E13 小时前
已经 Push 到远程的提交,如何修改 Commit 信息?
开发语言·github
jiang_changsheng15 小时前
工作流agent汇总分析 2
java·人工智能·git·python·机器学习·github·语音识别
馨谙16 小时前
Ansible 配置文件详解:让自动化管理更轻松
运维·github·ansible
Gofarlic_OMS16 小时前
Altium许可证状态自动化监控方案
大数据·运维·服务器·人工智能·自动化·github
岱宗夫up16 小时前
GitHub Desktop如何设置中文?这不是个简单问题
git·github