jsdelivr 被墙,hexo-next 切换为自定义 CDN

Thank you all for your tests, feedback and support. I am personally sorry for the issues we had today.
We can consider the issue as resolved, now its a question of DNS propagation getting to everyone.
Our official announcement regarding the problems today:
Unfortunately today jsDelivr unexpectedly lost its ICP license in China. As effect the regional CDN disabled our account.This resulted in the extended outage we had in mainland China and Taiwan.
Other regions were unaffected.
We understand how difficult it was for our users to experience this unique situation.
From now on all Chinese traffic will be served by “near China” locations provided by global CDN providers.
This will have the additional benefit of better failover logic in the future.
https://github.com/jsdelivr/jsdelivr/issues/18348#issuecomment-997777996
在 jsDelivr
被吊销 ICP 许可证五个月后,fastly.jsdelivr.net
开始遭到污染,非魔法上网已经不能正常加载,各中原因不做讨论,无外乎滥用
本博客使用 Hexo 框架和 NexT 主题,默认使用的是 JSDelivr 作为 静态资源的 CDN 服务提供商,为了能正常访问,所以需要切换到国内 CDN
1. 升级 Next 主题
hexo-theme-next
在 v8.9.0已经支持自定义 cdn
使用 npm 管理的
1
2目前最新的是8.11.1,大于8.9.0就可以
npm install hexo-theme-next@8.11.1使用 git 仓库管理的使用 git pull
2. 修改 Next 主题 CDN
参照 issuses
运营方 | 节点 | 地域 | 链接及格式 | 上游 | 备注 |
---|---|---|---|---|---|
75CDN (360 前端) | 360 自有节点? | 全球 | https://lib.baomitu.com/{cdnjs 格式} | cdnjs | |
阿里云 | 全球 | https://unpkg.zhimg.com/{unpkg 格式} | unpkg | ||
百度 | 百度云 | 全球 | https://code.bdstatic.com/npm/{unpkg 格式} | 内建 npm 镜像(上游淘宝 cmpnjs) | |
饿了么 | 阿里云 | 中国大陆 | https://npm.elemecdn.com/{unpkg 格式} | unpkg? |
修改本地_config.next.yml
1 | # It's recommended to use the same version as in `_vendors.yml` to avoid potential problems. |
3. 修改谷歌字体库
修改_config.next.yml
配置项
1 | font: |
4. 修改 Valine
npm install next-theme/hexo-next-valine#v2.0.0
新版 (2.1.0) 已经更换 CDN,可以直接使用
博客使用了 Valine 作为评论系统,依赖于 next-theme/hexo-next-valine,查看源码发现将 cdn.jsdelivr.net
写死在代码里
https://github.com/next-theme/hexo-next-valine/blob/main/valine.njk
1 | ... |
修改 node_modules/hexo-next-valine/valine.njk
1 | {%- if next_data %} |
使用 patch-package
修改 node_module,配合 github/actions 使用
1 | npm i patch-package -D |
生成补丁包
1 | npx patch-package hexo-next-valine |
_config.next.yml
增加配置项
1 | valine: |
- 标题: jsdelivr 被墙,hexo-next 切换为自定义 CDN
- 作者: tsvico
- 创建于 : 2022-05-18 13:19:57
- 更新于 : 2024-01-30 16:07:01
- 链接: https://blog.tbox.fun/2022/2394798680.html
- 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。