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
}

有了这两文件就好了

相关推荐
用户2136863783524 分钟前
给 DeepSeek Harness 写了个「技能熔炉」:任何来源的 SKILL.md 一条命令装上
github
七牛开发者1 小时前
告别反复调参,一个 Skill 让 AI 掌握论文图的视觉语法:以 DeepSeek V4.1 Flash 论文图为例
github·agent·deepseek
简创AIGC陶先生1 小时前
【直播切片工作台】第11章:剪辑项目模型 VideoProject
github
MicrosoftReactor2 小时前
技术速递|如何在不牺牲任务质量的前提下,让 AI 编码更具成本效益
人工智能·ai·github·copilot
中科三方2 小时前
DNS拨测到底在拨测什么?
开发语言·github·php·dns·云拨测
digital-Yun6 小时前
Harness 深度图解
github
码流怪侠8 小时前
Sunshine 深度拆解:当 NVIDIA GameStream 闭源后,如何用 4 万颗 Star 重建自托管云游戏
游戏·github·nvidia
Bmob后端云8 小时前
Bmob后端云实战|Python给备忘录接入AI摘要、文本润色功能
算法·github
夜焱辰8 小时前
EO2Weave 浏览器扩展正式上架 Chrome 应用商店:你的 AI 助手,从此住进每一个标签页
github
zzzzzz31011 小时前
anthropics/skills:高关注度“官方技能”项目,应该怎样读
人工智能·开源·github