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
}

有了这两文件就好了

相关推荐
鸿蒙布道师3 小时前
ChatGPT深度研究功能革新:GitHub直连与强化微调
人工智能·深度学习·神经网络·自然语言处理·chatgpt·数据挖掘·github
陈苏同学3 小时前
从 Git 到 GitHub - 使用 Git 进行版本控制 - Git 常用命令
git·github
白总Server4 小时前
微软系统 红帽系统 网络故障排查:ping、traceroute、netstat
linux·运维·服务器·microsoft·中间件·架构·github
opentrending14 小时前
Github 热点项目 Cursor开源代替,AI代理+可视化编程!支持本地部署的隐私友好型开发神器。
人工智能·开源·github
刃神太酷啦2 天前
C++入门(下)--《Hello C++ World!》(2)(C/C++)
java·c语言·c++·git·算法·github
正经码农3 天前
团队协作的润滑剂——GitHub与协作流程
github
北上ing3 天前
Github上如何准确地搜索开源项目
开源·github
ElenaYu3 天前
使用Homebrew下载配置git和连接GitHub(Mac版)
git·macos·github
CoderJia程序员甲4 天前
RAG_Techniques:探索GitHub热门RAG技术开源项目
ai·llm·github·ai教程·rag技术
孔令飞4 天前
如何从GitHub上调研优秀的开源项目,并魔改应用于工作中?
ai·云原生·golang·kubernetes·开源·github