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

推荐订阅源

Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Security Latest
Security Latest
P
Palo Alto Networks Blog
AWS News Blog
AWS News Blog
NISL@THU
NISL@THU
T
Threatpost
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Latest news
Latest news
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
J
Java Code Geeks
P
Privacy International News Feed
阮一峰的网络日志
阮一峰的网络日志
S
Schneier on Security
博客园 - 聂微东
Project Zero
Project Zero
美团技术团队
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Scott Helme
Scott Helme
I
Intezer
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hacker News: Front Page
S
Security @ Cisco Blogs
博客园 - 司徒正美
O
OpenAI News
Last Week in AI
Last Week in AI
L
LINUX DO - 热门话题
酷 壳 – CoolShell
酷 壳 – CoolShell
SecWiki News
SecWiki News
月光博客
月光博客
S
Security Affairs
The GitHub Blog
The GitHub Blog
P
Privacy & Cybersecurity Law Blog
S
Secure Thoughts
V
V2EX
S
Securelist
F
Fortinet All Blogs
W
WeLiveSecurity
D
Docker
博客园 - 三生石上(FineUI控件)
Simon Willison's Weblog
Simon Willison's Weblog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
V
Visual Studio Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Engineering at Meta
Engineering at Meta

FrWalker Blog

代码开发与环境管理工具汇总 求职-LeetCode热题100刷题记录 新机迁移-hexo\vscode\便携git\miniconda\i卡环境配置 通用印刷电路板全自动布线算法 基于元器件手册的智能建库算法 博客语法记录 柔性电路板FPC自动布线 拓竹P1S初体验 不更换插件解决Hexo博客Latex公式的渲染问题 修改博客加密插件hexo-blog-encrypt 3.1.9,适配移动端 强化学习-1-多臂老虎机 强化学习-2-马尔可夫决策过程 强化学习-3-动态规划 强化学习-4-时序差分 强化学习-5-Dyna-Q算法 强化学习-6-DQN算法 2024华为软件精英挑战赛-智慧港口 3.liunx shell及其脚本理解 2.linux文件系统及用户管理
cdn加速hexo博客_2次开发hexo-cdn-jsdelivr
FrWalker · 2025-02-19 · via FrWalker Blog

发表于更新于

字数总计:681阅读时长:2分钟 新加坡

hexo开发hexohexo-cdn-jsdelivrcdn

cdn加速hexo博客_2次开发hexo-cdn-jsdelivr

hexo-cdn-jsdelivr是一款hexo博客的cdn加速插件,它可以帮助你快速的将博客相对和指定路径下的资源提取出来,并进行资源路径前缀的更改,从而实现博客的指定cdn资源加速。但随着hexo的版本更新,原插件的一些功能已经无法使用,所以本文二次开发了hexo-cdn-jsdelivr-plus插件,并将其发布到npm上,欢迎大家使用。

改进说明

1.去掉指定前缀的自动修改

原插件在指定前缀cdn_url_prefix后,会默认加上latest等标识,导致不支持相关格式的cdn访问失败,所以去掉了自动修改的功能,完全遵循用户指定的前缀。

2.支持博客图片的语法更为简洁

原插件长时间未更新,只支持hexo博客的早期语法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!-- You can use cdn_css(path) to replace css(path) in hexo -->
<%- cdn_css(path) %>

<!-- This is used to replace js(path) -->
<%- cdn_js(path) %>

<!-- This will return a url link which is the cdn link of the asset -->
<%- cdn_asset(path) %>

<!-- Examples -->
<%- cdn_css('style.css') %>
<!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/<username>/<repo>@latest/css/style.css"> -->

<%- cdn_js('test.js') %>
<!-- <script src="https://cdn.jsdelivr.net/gh/<username>/<repo>@latest/js/test.js"></script> -->

<img src="<%- cdn_asset('assets/test.webp') %>"/>
<!-- <img src="https://cdn.jsdelivr.net/gh/<username>/<repo>@latest/assets/test.webp"/> -->

修改后支持在博客直接使用markdown原生语法,包括内嵌html代码,更加简洁无感:

alt text

3.支持修改Front-matter参数

对于Post Front-matter 中值为相对路径的参数,也支持自动添加cdn前缀,目前使用cover参数进行测试,后续根据是否有需求考虑将支持更多参数或所有参数。

使用

安装

1
npm install hexo-cdn-jsdelivr-plus --save

配置

除语法外,配置同原插件相同,参考hexo-cdn-jsdelivr

更新日志

hexo-cdn-jsdelivr-plus第一次发布,支持博客图片的语法更为简洁,去掉了指定前缀的自动修改,支持修改Front-matter cover参数。
支持下列markdown语法:

1
2
- `!$[](img.webp)` #加$是为了防止被渲染,无视即可
- `<img src="img.webp">`

因为想要使用anzhiyu tags有关图片Gallery和image的自定义样式语法,重新优化了hexo-cdn-jsdelivr-plus@v1.0.1.
新增支持语法:

1
2
- `{% image 链接 %} `
- `{% inlineImg [src] %}`

同时插件不再将图片渲染为html代码,只负责识别相对路径资源并替换为CDN链接。

头像头像

FrWalker

a blog for sharing my thoughts and experiences

本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 FrWalker Blog