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
}

有了这两文件就好了

相关推荐
阿米亚波8 小时前
【C/C++包管理器】vcpkg(by microsoft)
c语言·c++·git·vscode·microsoft·github·vcpkg
打工的小王10 小时前
github教程之多人协作
github
笨笨狗吞噬者11 小时前
IRIS: shell 中的智能实时输入提示工具
github·shell
fthux13 小时前
MCP协议开发实战:从零搭建AI Agent工具链
前端·人工智能·ai·开源·github
@CLoudbays_Martin1113 小时前
Linux 服务器如何查看是否被植入后门?
linux·服务器·网络·安全·github·ssl
一次旅行13 小时前
Ollama本地私有化大模型完整工程实战
人工智能·机器学习·github
华科大胡子13 小时前
GitHub Copilot 能换成本地模型吗?—— 本地化替代方案深度解析
人工智能·github·copilot
TunerT_TQ1 天前
Valhalla 静态工程审阅 #024|蚂蚁集团Ant Design 源码证据驱动评测【大厂开源基础设施特辑】
开源·github·蚂蚁集团·#推荐系统·#typescript·#antdesign
tokenKe1 天前
Cloudflare Computer: 给每个 AI Agent 一台专属电脑 | SSP Github Daily
人工智能·github