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
}

有了这两文件就好了

相关推荐
CSDN官方博客6 小时前
GitHub Copilot 新手极速上手指南
github·copilot
用户57844292286211 小时前
GraphRAG 与 LightRAG
github
峰向AI11 小时前
别再花几万块搭 Agent 了,[微软开源] 3500 行框架让 AI 自己练级
github
解道Jdon18 小时前
JDK 27发布:紧凑对象头、G1默认、量子安全TLS
ide·windows·git·svn·eclipse·github·visual studio
m4Rk_18 小时前
【论文阅读】Agent 记忆机制(72):EMA——在写入前决定什么值得记住
论文阅读·人工智能·学习·开源·github
OpenTiny社区18 小时前
从开发到运行:OpenTiny NEXT 如何构建 Agent 时代的 Web 应用?
前端·github·ai编程
政安晨19 小时前
政安晨【超级AI智能体~技术简报】- Skills 元方法论霸榜 + Agent Harness 爆发 + 反直觉叙事的胜利
github·开源项目·ai agent·技术简报·政安晨
QUOR19 小时前
ZorvAI APK 插件框架 · 技术架构与功能介绍
github·apk·编程语言
孙琦Ray19 小时前
Homebrew/BrewUI:Homebrew 官方出的 macOS 图形客户端,把 brew 的装包、更新包变成点选
人工智能·开源·github
HelloGitHub20 小时前
从一份 README 到 3 万星,RustFS 这一年都干了什么?
开源·github