惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
Engineering at Meta
Engineering at Meta
博客园 - 司徒正美
T
Tailwind CSS Blog
F
Full Disclosure
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
小众软件
小众软件
IT之家
IT之家
J
Java Code Geeks
Y
Y Combinator Blog
Microsoft Security Blog
Microsoft Security Blog
B
Blog
V
V2EX
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
The Cloudflare Blog
Recent Announcements
Recent Announcements
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
罗磊的独立博客
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
MongoDB | Blog
MongoDB | Blog
U
Unit 42
H
Heimdal Security Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google Online Security Blog
Google Online Security Blog
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
PCI Perspectives
PCI Perspectives
博客园 - 三生石上(FineUI控件)
I
InfoQ
SecWiki News
SecWiki News
N
News and Events Feed by Topic
D
DataBreaches.Net
Schneier on Security
Schneier on Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

ike‘s blog

mac软件推荐 用Siri来控制Windows电脑开机关机吧 clickhouse的一些优化建议和工具 2023sumppary 记录一下我的第一个网页游戏Mazeball 如何使用Clickhouse的索引 如何从zookeeper切换为clickhouse—keeper cloki分布式查询和clickhouse副本存储 使用ilogtail+cloki+clickhouse来做日志系统吧 clickhouse集群部署指南 快速安装部署clickhouse和cloki 快速部署thanos架构 如何使用go的jwt 如何修改git commit记录 业务容器化需要注意的一些地方 游戏企划 Prometheus Metrics精简优化2 来在线听音乐吧 Chatgpt的API入门 简单搭建国内也可以使用的chatgpt Prometheus Metrics精简优化 Kubernetes的探针机制 本地部署chatAI【chatglm】 AI绘画工具webui简单入门 之 高清化 写在地下城邂逅Ⅳ·灾厄篇·完结之后 AI绘画工具webui简单入门 之 工具安装 grafanadb迁移到mysql kubectl常用命令 开始写博客啦 隐私政策URL Markdown Example Include Video in the Posts Markdown Extended Features Simple Guides for Fuwari Golang net/http & HTTP Serve 源码分析
如何部署gitalk作为评论系统
ike · 2023-03-15 · via ike‘s blog

本来搭建好了博客,但是总觉的少了一些功能,没错,博客怎么能少了评论功能!(虽然可能没什么人评论) 但本着我可以不用但不能没有的精神,刚好也有大大推荐了gitalk,就研究了下,发现集成第三方评论系统gitalk集成非常简单,只需要申请github账号的Secret然后前端里加下面一段代码就好了

    <script>
      import 'gitalk/dist/gitalk.css';
      import Gitalk from 'gitalk';
    
      const gitalk = new Gitalk({
        clientID: myclientID,
        clientSecret: mySecret,
        repo: 'myrepo',
        owner: 'myusername',
        admin: ['myusername'],
        id: window.location.pathname,
        distractionFreeMode: false
      });
    
      gitalk.render('gitalk-container');
    </script>
    
    <div id="gitalk-container"></div>

就搞定了!但是又有一个问题,就是ClientID和Secret是明文的,放到github上太危险了,那有什么好方法呢,查了下,vercel是支持环境变量的,astro也支持,那就好办了。 查了一番官方文档,然后进行了以下操作,成功把vercel关联到项目,然后生成了.env文件。

npm i -g vercel
vercel --version
vercel login
vercel link --yes
vercel env ls
vercel env pull

接下来就简单了,只需要在Vercel的项目Setting中把Environment Variables添加下myclientIDmySecret,然后在代码里替换成import.meta.env.CLIENT_IDimport.meta.env.CLIENT_Secret就搞定!现在再push到github仓库里,就没有安全隐患了~

    <script>
      import 'gitalk/dist/gitalk.css';
      import Gitalk from 'gitalk';
    
      const gitalk = new Gitalk({
        clientID: import.meta.env.CLIENT_ID,
        clientSecret: import.meta.env.CLIENT_Secret,
        repo: 'myrepo',
        owner: 'myusername',
        admin: ['myusername'],
        id: window.location.pathname,
        distractionFreeMode: false
      });
    
      gitalk.render('gitalk-container');
    </script>
    
    <div id="gitalk-container"></div>

Twikoo#

astro也支持twikoo的评论系统,后端参考官网Twikoo文档,前端只需要npm i twikoo然后配置

<script>
      import twikoo from "twikoo";
      twikoo({
        envId: "https://your vercel site", // your environment ID or url
        el: "#tcomment", // the container ID which will show the comment
        //lang: "en-GB", // language for the comment template. for the full list, refer to https://github.com/imaegoo/twikoo/blob/main/src/client/utils/i18n/index.js
      }).then(() => {
        console.log("comment loading success");
      });
</script>
<div id="tcomment"></div>

就可以了,当然别忘了再env.d.ts里吧declare module "twikoo";加上,声明下twikoo就不会报声明类型错误了。

Analytics#

velcel还支持查看流量访问,只需要npm i -g vercel安装完velcel后在官网项目里启动Analytics里的Audiences,然后创建完目录后在页面里引入下面的代码就搞定了~

<script defer src="/_vercel/insights/script.js"></script>