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
}

有了这两文件就好了

相关推荐
troy12810 小时前
Python 基础语法(九):Django/Flask/FastAPI 三大 Web 框架详细对比解析
python·jupyter·django·flask·github·fastapi
dong_junshuai14 小时前
每天一个开源项目#103 BrowserSkill:4.7K星,Agent接管真实浏览器
开源·github·agent
dong_junshuai14 小时前
每天一个开源项目#102 六阶段代码复核流程范式
开源·github·agent
峰向AI15 小时前
别再给 AI 助手单独付费了,腾讯开源 3.6K 星标的全家共享平台
github
逛逛GitHub16 小时前
我近期看到的最有创意的 GitHub 开源项目,太惊艳了。
github
m4Rk_17 小时前
【论文阅读】Agent 记忆机制(73):MemGAS——让长期对话记忆按问题选择粒度并关联证据
论文阅读·人工智能·学习·开源·github
横木沉20 小时前
IntelliJ IDEA 无法识别 Git:Git is not installed 问题解决
java·git·github·intellij-idea
小麦在野20 小时前
独立 App 开发系列:用 GitHub Pages 托管隐私政策和用户协议
android·github
用户68559861145521 小时前
我做了一套知识结构规格,它最核心的约束是拒绝替你填内容
github
简创AIGC陶先生21 小时前
【直播切片工作台】第14章:种子数据 Seeder
github