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
}

有了这两文件就好了

相关推荐
孟陬19 小时前
别再社死了!`includeIf` 一招搞定 Git 提交者信息错乱,守护你的邮箱隐私
git·github
Cyril_KI21 小时前
大模型长文生成中的幻觉与事实性:研究进展综述
大模型·llm·github·综述·幻觉
逛逛GitHub21 小时前
3 个近期"优质"的 AI 开源项目, 有点绝。
架构·github
Pluto5381 天前
第一个app产品的迭代
ios·github
liuccn1 天前
Ubuntu 22.04 离线升级 OpenSSH 到 9.8p1
linux·ubuntu·github
fruge1 天前
GitHub Actions CI/CD 自动化部署完全指南
ci/cd·自动化·github
lkbhua莱克瓦241 天前
Java练习——正则表达式2
java·开发语言·笔记·正则表达式·github·学习方法
ZhiqianXia2 天前
github 软件安全术语
安全·github
苦学编程的谢2 天前
Redis_3_Redis介绍+常见命令
数据库·redis·github
Rverdoser2 天前
制作网站的价格一般由什么组成
前端·git·github