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
}

有了这两文件就好了

相关推荐
小弥儿6 小时前
GitHub今日热榜 | 2026-07-19
人工智能·学习·github·知识图谱
dong_junshuai8 小时前
每天一个开源项目#43 KTransformers:18.5K星的异构MoE推理引擎
github
OpenTiny社区11 小时前
TinyRobot v0.5.0 新版本强在哪?
前端·vue.js·github
humbinal14 小时前
同时支持 gui & cli 的 parquet 文件查看工具,高性能小清新!
hive·python·rust·spark·开源·github·parquet
华科大胡子14 小时前
GitHub Actions 自动化运维实战:从入门到精通
github
fliter17 小时前
不用再反复 stash:用 Git Worktree 同时开发多个分支
后端·github
Tenifs17 小时前
在 VS Code 中,你可以通过修改全局或项目目录下的 settings.json 文件来彻底关闭 GitHub Copilot
github·copilot
Cosolar18 小时前
深入理解 AI Agent:设计原理与工程实践
人工智能·面试·github
love530love2 天前
ComfyUI 插件发布 GitHub Release + Comfy Registry (官方节点商店)完整复盘教程(从零开始)
人工智能·windows·github·devops
CoderJia程序员甲2 天前
GitHub 热榜项目 - 周榜(2026-07-18)
ai·大模型·llm·github·ai教程