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
}

有了这两文件就好了

相关推荐
高频因子挖掘机19 分钟前
同一交易日出现重复 K 线:去重前先确认时间、来源和粒度
后端·github·api
SL_staff3 小时前
从邮箱传文档到协同流重构:企业文档协作的系统性破局实践
java·开源·github
用户7273744138845 小时前
版本锁定实战:从 `git tag` 到 `package-lock.json` 的完整闭环
github
暖心hebbie设计学习5 小时前
GitHub 热榜周报(10.19)|5 个把 AI 装回本地的开源项目:多 agent 控制台、本地语音、节点式生成(含技术看点)
人工智能·github
用户别睡觉6 小时前
从 0 到 1 开源:基于 FastAPI 和本地大模型打造一个提示词安全网关
github
mr_g6 小时前
一个注解搞定 AGI,两个注解搞定 AMI —— SmartCall 让 Java 对接 Asterisk 简单到离谱
github
sbjdhjd8 小时前
从签名重放到 Agent Harness:一堂安全课程如何把前端逆向、MCP 与工程约束串起来
网络安全·ai·github·agent·webshell·mcp·harness
逛逛GitHub10 小时前
火了两周的 30 万 Star 逆向 GitHub 开源神器,网友都用它来干啥?
github
wflynn12 小时前
GitHub 日榜趋势速报 | 2026-10-18
开源·github
疯狂敲代码的老刘12 小时前
d2r-mobile:3.2千星开源暗黑破坏神2 iOS兼容层,3天冲上GitHub日榜
ios·github