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
}

有了这两文件就好了

相关推荐
独隅3 小时前
GitHub Actions 自动化运维实战:CI/CD 流水线一体化效果展示
运维·自动化·github
fthux3 小时前
装闭 RenoPit 源码解析(05):FastAPI与Celery如何执行AI装修分析
人工智能·ai·开源·github·open source·renopit
YuePeng8 小时前
一个注解起家,25 个模块收尾:Erupt 的生态版图长这样
后端·github
我是若尘10 小时前
发布分支落后于主干,MR 全是冲突?聊聊业界怎么治这个“祖传”难题
github
笨鸟先飞,勤能补拙11 小时前
网络安全等级保护 2.0:从定级备案、建设整改到持续合规的系统指南
网络·人工智能·windows·安全·web安全·网络安全·github
echoVic11 小时前
CI 已经绿了,为什么你的 Agent 还在用旧规则?
github
echoVic11 小时前
AI 评审最怕的不是漏报,而是审完以后代码已经变了
github
Patrick在香港13 小时前
Claude API + Python:香港MPF基金回报率自动化分析框架
windows·python·数据分析·自动化·github·ai编程·数据可视化
u13013015 小时前
GitHub 热榜项目:日榜(2026-08-10)
github
dong_junshuai15 小时前
每天一个开源项目#62 pdf-inspector:0.47秒解析200份PDF
开源·github