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
}

有了这两文件就好了

相关推荐
峰向AI16 小时前
Superpower 不是最「聪明」的,这个开源项目让模型学会资深工程师的肌肉记忆
github
YuePeng16 小时前
卖了几年的 BI 模块突然免费:24 种图表,一条 SQL 一张图
github
dong_junshuai16 小时前
每天一个开源项目#82 9.2K星God's Eye View:公开信号3D地球
开源·github
简创AIGC陶先生17 小时前
第1章:项目全景与架构总览
github
怕浪猫17 小时前
ZCode 周末送额度活动开启:3 亿 Token 免费领取
github
P1Browser17 小时前
指纹浏览器安全吗?从浏览器环境隔离、数据存储到安全风险解析
网络·tcp/ip·安全·网络安全·github·php
todoitbo20 小时前
用蓝耘元生代做 GitHub 热榜解读:Dify Chatflow 接入和真实项目分析
ai·github·api·dify·蓝耘
猫头虎21 小时前
GitHub 入门教程:如何加入并为开源项目贡献代码
gitee·开源·gitlab·github·开放原子·开源协议·gitcode
樱花落木兰21 小时前
Git 超全零基础教程|三区原理、全套命令、分支协作、冲突解决、IDEA 集成(面试必备)
ide·git·json·github
TunerT_TQ1 天前
IBM |css-gridish 源码分析:4 个 JavaScript 文件背后的 CSS Grid 可视化工具
开源·github·资讯