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
}

有了这两文件就好了

相关推荐
真好啊又活了一天40 分钟前
服务器和虚机配置IPV6
运维·服务器·github
Cosolar1 小时前
极简简历:开源免费,希望帮助到更多求职者
开源·github·敏捷开发
Cosolar2 小时前
极简智库:快速搭建你的开源项目教程阅读平台,让 docs/ 目录被更多人看见
java·架构·github
敢敢是只喵i2 小时前
false不等于没填:一次 AI 接入业务系统的SDK的修复记录
github
一条Go2 小时前
历史告警归档:为什么"删掉主库行"是最后一步
后端·架构·github
TunerT_TQ2 小时前
Valhalla L3 开源评测|Apache Doris:面向AI Agent的实时分析与混合检索数据库
github
panyz2 小时前
不想再开 7 个标签页查AI额度,我用 Node 写了个本地看板
人工智能·开源·github
逛逛GitHub3 小时前
又 3 个刚开源但要火的 GitHub 项目,在 iPhone 上跑 macOS。
github
OpenTiny社区5 小时前
AI Agent场景组件库 TinyRobot v1.0 正式发布:一站式打造您的AI助手
vue.js·github
GoGeekBaird7 小时前
换个 AI 就要重新介绍一遍自己?我用 OneSelf 给自己搭了个个人站
github·agent