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
}

有了这两文件就好了

相关推荐
Jurio.8 小时前
本机开发 + 多机执行的极简远端运行工具
linux·git·python·github·远程工作
Hical_W11 小时前
为 C++ Web 框架设计三层 PMR 内存池:从原理到实战
c++·github
CoovallyAIHub14 小时前
无人机拍叶片→AI找缺陷:CEA-DETR改进RT-DETR做风电叶片表面缺陷检测,mAP50达89.4%
算法·架构·github
CoovallyAIHub14 小时前
混合训练反而更差?VLM Agent在训练前协调跨数据集标注,文档布局检测F-score从0.860提升至0.883
算法·架构·github
OpenTiny社区14 小时前
多端开发头疼?TinyVue 3.30 一招搞定,AI还帮你写代码!
前端·vue.js·github
峰向AI15 小时前
Vercel 官方出品,你的 24 小时 AI 编程助手
人工智能·github
研究点啥好呢16 小时前
Github热门项目推荐 | 开放数据的新时代
大数据·人工智能·机器学习·github·数据
逛逛GitHub16 小时前
帮你节省 65% 的 token,这个 GitHub 项目让 Claude 模仿原始人。
github
字符串str19 小时前
nikto中文解释和常用的github信息收集语法
github
墨问开源21 小时前
我把19位顶级投资大佬「塞进」终端,这个开源AI Hedge Fund到底能不能赚钱?
github