Gahing's blog Gahing's blog
首页
知识体系
  • 前端基础
  • 应用框架
  • 工程能力
  • 应用基础
  • 专业领域
  • 业务场景
  • 前端晋升 (opens new window)
  • Git
  • 网络基础
  • 算法
  • 数据结构
  • 编程范式
  • 编解码
  • Linux
  • AIGC
  • 其他领域

    • 客户端
    • 服务端
    • 产品设计
软素质
  • 面试经验
  • 人生总结
  • 个人简历
  • 知识卡片
  • 灵感记录
  • 实用技巧
  • 知识科普
  • 友情链接
  • 美食推荐 (opens new window)
  • 收藏夹

    • 优质前端信息源 (opens new window)
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

Gahing / francecil

To be best
首页
知识体系
  • 前端基础
  • 应用框架
  • 工程能力
  • 应用基础
  • 专业领域
  • 业务场景
  • 前端晋升 (opens new window)
  • Git
  • 网络基础
  • 算法
  • 数据结构
  • 编程范式
  • 编解码
  • Linux
  • AIGC
  • 其他领域

    • 客户端
    • 服务端
    • 产品设计
软素质
  • 面试经验
  • 人生总结
  • 个人简历
  • 知识卡片
  • 灵感记录
  • 实用技巧
  • 知识科普
  • 友情链接
  • 美食推荐 (opens new window)
  • 收藏夹

    • 优质前端信息源 (opens new window)
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • 个人简历

  • 人生总结

  • 实用技巧

  • 影剧观感

  • 教育

  • 服务搭建

    • Code Server搭建指南
    • deepfake 项目搭建
    • 博客

      • 几款好看的博客主题
      • 博客收录注意事项
      • vuepress踩坑记录
      • 博客分类脑图生成
      • 博客评论踩坑记录
        • gitalk
          • vuepress 使用方式
          • 存在的问题
        • utterances 使用
          • 使用方式
          • 存在的问题
          • utterances 原理
          • 讲下 beaudar
      • 博客配置全文搜索
      • 博客配置资源缓存
      • 如何部署博客
      • 给网站添加一只看板娘
    • 域名解析常见问题
  • 灵感记录
  • 理财投资

  • 生活常识

  • 知识科普

  • 自媒体

  • 面试经验

  • 闲言碎语
  • 服务搭建
  • 博客
gahing
2023-04-14
目录

博客评论踩坑记录

本篇文章将介绍个人博客搭建时,几种常用的评论方案,以及遇到的坑

# 主流的几种评论方案

# gitalk

采用 github issue 作为评论内容

# vuepress 使用方式

在 vuepress 中使用 vuepress-plugin-comment 进行配置,底层是采用的 gitalk npm 包

    [
      'vuepress-plugin-comment', // 评论
      {
        choosen: 'gitalk',
        options: {
          clientID: '',
          clientSecret: '',
          repo: 'blog-gitalk-comment', // GitHub 仓库
          owner: 'francecil', // GitHub仓库所有者
          admin: ['francecil'], // 对仓库有写权限的人
          // gitalk 跨域代理问题可以看这个帖子 https://prohibitorum.top/7cc2c97a15b4.html
          proxy: 'https://safe-cors-server.vercel.app//github_access_token',
          // distractionFreeMode: true,
          pagerDirection: 'last', // 'first'正序 | 'last'倒序
          id: '<%- (frontmatter.permalink || frontmatter.to.path).slice(-16) %>', //  页面的唯一标识,长度不能超过50
          title: '「评论」<%- frontmatter.title %>', // GitHub issue 的标题
          labels: ['Gitalk', 'Comment'], // GitHub issue 的标签
          body:
            '页面:<%- window.location.origin + (frontmatter.to.path || window.location.pathname) %>', // GitHub issue 的内容
        },
      },
    ],
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

# 存在的问题

  • 默认的跨域中转服务被墙,需要自建代理,参考 https://prohibitorum.top/7cc2c97a15b4.html 基于 vercel 快速搭建一个免费的服务
  • 默认未创建 issue,需要写个脚本在部署服务时批量创建,若某篇文章已创建则跳过
  • 配置的权限过于松散,且明文配置在页面中,可能有安全风险(?)

# utterances 使用

utterance (opens new window)

采用 github issue 作为评论内容,与 gitalk 不同的是, utterances 提供了一个中间服务和 github app 来鉴权,安全性会更好一点。

同时由于无需配置密钥,用户接入成本很低,博客也无需提前创建 github issue

# 使用方式

  1. 新建评论仓库
  2. 打开 utterances github app (opens new window) ,为其授予新建评论仓库的权限
  3. 在页面中插件 utterances 的脚本

对于 vuepress 仓库,可以参考 https://github.com/francecil/blog/tree/master/docs/.vuepress/plugins/commemt 这边的代码,后续会抽成 npm 包

# 存在的问题

  • 基于 iframe 展示评论,加载速度和性能相对 gitalk 较差,同时页面主题色同步需要一些 iframe 通信的成本。
  • 依赖 utterances 服务,若 utterances 服务关闭则无法使用。

不过数据不会丢失(存在 github issues 中),同时 utterances 也提供了 utterances-oauth 自部署服务的方案

# utterances 原理

见 https://lipk.org/blog/2020/06/08/run-utterances/

# 讲下 beaudar

国产版本:https://beaudar.lipk.org/ ,访问速度更快,支持了一些新功能

注意分支配置,新建的插件默认是 main 分支,beaudar 默认是 master 分支

使用的时候一直鉴权报错,估计是 beaudar 服务维护问题,暂时放弃使用

编辑 (opens new window)
上次更新: 2024/09/01, 23:56:56
博客分类脑图生成
博客配置全文搜索

← 博客分类脑图生成 博客配置全文搜索→

最近更新
01
浅谈代码质量与量化指标
08-27
02
快速理解 JS 装饰器
08-26
03
Vue 项目中的 data-v-xxx 是怎么生成的
09-19
更多文章>
Theme by Vdoing | Copyright © 2016-2024 Gahing | 闽ICP备19024221号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式