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
}

有了这两文件就好了

相关推荐
JavaGuide5 小时前
一个神级 PR Review Agent 诞生了:读 diff、写总结、找风险全自动!
github·ai编程
逛逛GitHub7 小时前
1.3 万人点赞的 GitHub 项目,让 AI Agent 操作 Office 文件。
github
OpenTiny社区8 小时前
Skill 设计:封装、评测、运营,一次讲透
前端·github
本地化文档9 小时前
xlwings-docs-l10n
python·github·excel·gitcode·sphinx
徐小夕10 小时前
倒腾2天,我开源了一款AI驱动的实时 3D CAD / 参数化建模工作台
前端·架构·github
Zeno乌鸦11 小时前
用 OpenAI SDK 配置自定义 Base URL:一次多模型接入实践
github
用户2959485550511 小时前
重力空间的一次实践——我做了个与众不同的本地知识库
github
dong_junshuai11 小时前
每天一个开源项目#36 dcg:3.3K Stars 的 AI 命令安全闸门,亚毫秒拦截灾难操作
github
带娃的IT创业者11 小时前
从 iptv-org/iptv 看开源协作:如何像 AI Agent 一样思考工程化实践
人工智能·开源·github·软件开发·ai agent·工程化实践·开源协作