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
}

有了这两文件就好了

相关推荐
逛逛GitHub1 小时前
把你的 AirPods 当鼠标用,这 3 个黑科技 GitHub 开源项目有趣。
github
徐小夕4 小时前
开源Vector-Graph-RAG:向量+图谱双引擎,打破纯向量RAG的效果天花板
前端·vue.js·github
GitHub实测笔记4 小时前
zoxide 本机实测:一万条记查询中 5.7ms0.10 版 import --from
github
Brookty6 小时前
Git与GitHub系统学习|本地Git工作模型:终端与进程、CWD、HEAD/Index/工作树及Git对象
git·github
miofly1 天前
Genie 4新增原生音频,实时世界模型加入声音生成
开源·github
dong_junshuai1 天前
每天一个开源项目#155 MuJoCo:从接触求解到控制时序的物理引擎
github
GitHub实测笔记1 天前
eza 本机实测:一万文件 -l 中位 48ms、ls 21.5ms;脚本里裸跑 eza 输出为空
github
一条Go1 天前
开源新生代雷达 · 第 04 期
github
一条Go1 天前
告警指纹:一次故障为什么只产生一条 FIRING 记录
后端·架构·github
wyxspark1 天前
在本地 AI 中实现绝对可复现:一份 12,810 条哈希的硬核工程记录
github