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
}

有了这两文件就好了

相关推荐
darkb1rd13 小时前
lingbot-map:流式 3D 重建实战指南与解析
开源·github·好物分享
AC赳赳老秦15 小时前
HR必备:OpenClaw批量筛选简历、发送面试通知,优化招聘流程
运维·人工智能·python·eclipse·github·deepseek·openclaw
yyuuuzz15 小时前
独立站搭建:从入门到避坑实战
前端·git·github
splage16 小时前
Nginx 反向代理之upstream模块以及完整配置反向代理示例
git·nginx·github
jiayong2317 小时前
GitHub 二开并持续同步上游稳定分支详细指南
github
逛逛GitHub18 小时前
暴击设计行业的 Claude Design ,系统提示词在 GitHub 上泄露了。
github
程序猿阿伟20 小时前
《QClaw隐藏的GitHub自动化神级用法》
运维·自动化·github
夜宵饽饽1 天前
Agent文件系统检索核心:Grep和Glob工具
javascript·github
白玉cfc1 天前
Git提交规范
git·github
极客小云1 天前
【AiCodeAudit 2.0 发布:基于调用图与局部子图的 AI 代码安全审计平台】
人工智能·网络安全·语言模型·大模型·github·安全性测试·代码复审