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
}

有了这两文件就好了

相关推荐
梦想三三24 分钟前
Git与GitHub基础入门:从零开始掌握版本控制与代码托管(完整图文教程)
人工智能·git·elasticsearch·github
青禾网络2 小时前
前端做音画匹配这件事,我从"随机塞"到"AI 自动对齐"
前端·github
用户081602610573 小时前
AgentGate:一行命令给你的 AI Agent 加上企业级弹性层
github
怕浪猫5 小时前
面向自我改进的驾驭工程Harness Engineering for Self-Improvement
github·agent·ai编程
hanqunfeng7 小时前
GitHub Actions Workflow 详细指南
github
haluhalu.11 小时前
prompts.chat:03-core-prompting-principles
prompt·github
阿里嘎多学长1 天前
2026-07-10 GitHub 热点项目精选
开发语言·程序员·github·代码托管
今夕资源网1 天前
AI声音克隆软件 CosyVoice今夕一键整合包解压即用 阿里巴巴通义实验室开源 github斩获22K星标
人工智能·github·多国语言·声音克隆·零样本语音克隆·感情·ai语音克隆
胡萝卜术1 天前
从聊天模型到本地执行助手:Remote MCP 多工具 Agent 实战
面试·架构·github
慕容引刀1 天前
告别Commit信息纠结:使用Git AI Commit插件实现规范化提交
人工智能·git·github·visual studio code·visual studio