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
}

有了这两文件就好了

相关推荐
怕浪猫2 小时前
NVIDIA 全产品谱系与演进
javascript·面试·github
一条Go3 小时前
Grafana 面板嵌入:为什么 kiosk 必须是「裸参数」
后端·github
一条Go3 小时前
开源新生代雷达 · 第 20 期
github
小帅不太帅6 小时前
一年一次黑五,为了买软件真省钱,我做了个开源小站
前端·人工智能·github
用户69371750013848 小时前
AI 帮我写了大半年的代码,我却越来越不会写代码了
前端·后端·github
长不大的杨瑞杰12 小时前
GitHub Copilot Browser Use 实战:让 AI 在浏览器里调试与自动化测试
人工智能·github·copilot·playwright·github copilot·browser use
大侠Luffy12 小时前
用 EmbeddingGemma 2 做一个本地照片与短视频搜索工具
开源·github·ai编程
咖啡色格调12 小时前
项目已托管在 Gitee,如何同时推送到 GitHub
gitee·github
人人都是软件工程师12 小时前
前端接了 Agent,为什么还是满屏自定义代码?读懂 AG-UI 的 31 个事件
人工智能·github
怕浪猫13 小时前
GLM-5.4 深度拆解:750B 参数如何「循环」出 2-3T 级智能?
算法·面试·github