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
}

有了这两文件就好了

相关推荐
徐小夕2 小时前
借助AI,1周,0后端成本,我开源了一款Office预览SDK
前端·vue.js·github
CoderJia程序员甲2 小时前
GitHub 热榜项目 - 日榜(2026-03-18)
ai·大模型·llm·github·ai教程
逛逛GitHub3 小时前
硅谷大佬把自己 Claude Code 武器库给开源了,1 周就 2 万点赞。
github
星浩AI4 小时前
清华团队开源!我给孩子制作了 AI 互动课堂,手把手教你给孩子做一个
人工智能·后端·github
NGC_66115 小时前
滑块验证:从原理到实战,拆解人机验证的核心逻辑
github
无限进步_7 小时前
深入解析C++容器适配器:stack、queue与deque的实现与应用
linux·开发语言·c++·windows·git·github·visual studio
irpywp9 小时前
autoresearch:自主目标导向迭代的无限游戏
开源·github·karpathy·autoresearch
汪海游龙10 小时前
03.19 AI 精选:开源异步编程 Agent 框架
github·hacker news
NocoBase10 小时前
【教程】用 NocoBase 2.0 搭建一个极简的 IT 工单系统
人工智能·开源·github·无代码
sandwu10 小时前
OpenClaw 3.13 正式发布:新增 Chrome DevTools MCP、会话绑定、插件生态全面升级
人工智能·github