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 小时前
Prompt Engineering 面试怎么考?这 5 个范式你必须会
面试·程序员·github
可乐ea9 小时前
GitHub Security Lab 开源 Fuzzing Taskflow:让 LLM 智能体自己跑完 C/C++ 模糊测试
jvm·c++·github·模糊测试·mcp·代码agent·智能体自动化
TOOLS指南10 小时前
GitHub 和 ai.github 是什么?两者有什么区别
人工智能·github
贾斯汀frank10 小时前
Fleurdelix OS已预装办公套件ONLYOFFICE桌面编辑器
github
wflynn10 小时前
GitHub 日榜趋势速报 | 2026-09-30
开源·github
Cosolar16 小时前
云端部署阿里 Qwen-Image-2.1 保姆级教程
人工智能·后端·github
miofly17 小时前
GitHub 今日推荐|REDox:64 位 token 表示结构化数据,内存占用降 70% 支持多格式互转
开源·c#·github
奋进的LY17 小时前
spacy的安装和使用教程
人工智能·python·深度学习·github
guru17 小时前
手写一个 Tool-Calling Agent:为什么要先不用框架
github
miofly18 小时前
GitHub 日榜趋势速报 | 2026-10-03
开源·github