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
}

有了这两文件就好了

相关推荐
捣鼓软件12 小时前
告别“玄学咒语“:这个 GitHub 项目把 GPT-Image2 的提示词变成了“可复用代码“!
gpt·github
dong_junshuai14 小时前
每天一个开源项目#79 Apache Maka:3K星本地Agent工作台
开源·github·agent
峰向AI14 小时前
Apache Maka:解决 AI 最大痛点,对话工具调用全部本地有据可查
github
前端Hardy16 小时前
GitHub 243K+Star!这个项目给 AI 装上了完整工程体系
github
那年窗外下的雪.18 小时前
AIDC 学习日志|第 14 天|MAC Flapping 与 EVPN 多归属分层排障
网络·git·学习·macos·github·spine
fthux20 小时前
装修还没开工,AI已经替你把坑踩了一遍
人工智能·ai·开源·github·open source·renopit
老王的笔记v1 天前
42期 鼠鼠格式转换工具整合图片文档音视频转换,Windows和Mac免费使用
windows·开源·github·音视频
tg_xianheyun1 天前
腾讯云国际账号注册代充值服务商怎么选?
大数据·运维·服务器·云计算·github·腾讯云·cdn加速
m4Rk_1 天前
【论文阅读】Agent 记忆机制(49):MemCoE——先学习如何组织记忆,再学习具体记住什么
论文阅读·人工智能·学习·开源·github
想风1 天前
Claude Code 实用技巧工作坊 —— Boris Cherny
前端·后端·github