-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
85ab262
commit 0056cb7
Showing
74 changed files
with
73 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,19 +31,19 @@ tags: | |
|
||
### 1. 新建 `用户名.github.io` 仓库 | ||
|
||
![gh-create-repo1.jpg](/images/Init-my-first-hexo-blog/gh-create-repo1.jpg) | ||
![gh-create-repo1.webp](/images/Init-my-first-hexo-blog/gh-create-repo1.webp) | ||
|
||
记住这串 `仓库的ssh地址` 后面要用到 | ||
![ssh-link.jpg](/images/Init-my-first-hexo-blog/ssh-link.jpg) | ||
![ssh-link.webp](/images/Init-my-first-hexo-blog/ssh-link.webp) | ||
|
||
![gh-create-repo2.jpg](/images/Init-my-first-hexo-blog/gh-create-repo2.jpg) | ||
![gh-create-repo2.webp](/images/Init-my-first-hexo-blog/gh-create-repo2.webp) | ||
|
||
### 2. 部署你的 ssh 私钥 到仓库变量中 | ||
|
||
![deploy-key1.jpg](/images/Init-my-first-hexo-blog/deploy-key1.jpg) | ||
![deploy-key1.webp](/images/Init-my-first-hexo-blog/deploy-key1.webp) | ||
|
||
填入你的私钥 | ||
![deploy-key2.jpg](/images/Init-my-first-hexo-blog/deploy-key2.jpg) | ||
![deploy-key2.webp](/images/Init-my-first-hexo-blog/deploy-key2.webp) | ||
|
||
### 3. 初始化 hexo 博客目录 | ||
|
||
|
@@ -54,7 +54,7 @@ tags: | |
hexo init mobeicanyue.github.io && cd mobeicanyue.github.io | ||
``` | ||
执行结果如下 | ||
![init-hexo.jpg](/images/Init-my-first-hexo-blog/init-hexo.jpg) | ||
![init-hexo.webp](/images/Init-my-first-hexo-blog/init-hexo.webp) | ||
|
||
### 4. 初始化 git 仓库并提交到 github | ||
|
||
|
@@ -64,7 +64,7 @@ git add . | |
git commit -m "Initial commit" | ||
``` | ||
执行结果如下 | ||
![init-git.jpg](/images/Init-my-first-hexo-blog/init-git.jpg) | ||
![init-git.webp](/images/Init-my-first-hexo-blog/init-git.webp) | ||
|
||
把下面 git@xxx 地址换成你仓库的 ssh 地址 | ||
|
||
|
@@ -73,31 +73,31 @@ git remote add origin [email protected]:mobeicanyue/mobeicanyue.github.io.git | |
git push -u origin master | ||
``` | ||
执行结果如下 | ||
![git-push.jpg](/images/Init-my-first-hexo-blog/git-push.jpg) | ||
![git-push.webp](/images/Init-my-first-hexo-blog/git-push.webp) | ||
|
||
此时我们刷新一下 github 仓库,就可以看到我们的代码已经提交上去了 | ||
但是网页第一次构建肯定是失败的(打叉),因为还没配置 github action | ||
|
||
![github-code.jpg](/images/Init-my-first-hexo-blog/github-code.jpg) | ||
![github-code.webp](/images/Init-my-first-hexo-blog/github-code.webp) | ||
|
||
### 5. 新建 gh-pages 分支并将其设置为 pages 的默认部署分支 | ||
|
||
点击分支 | ||
![new-branch1.jpg](/images/Init-my-first-hexo-blog/new-branch1.jpg) | ||
![new-branch1.webp](/images/Init-my-first-hexo-blog/new-branch1.webp) | ||
创建 gh-pages 分支 | ||
![new-branch2.jpg](/images/Init-my-first-hexo-blog/new-branch2.jpg) | ||
![new-branch2.webp](/images/Init-my-first-hexo-blog/new-branch2.webp) | ||
设置 gh-pages 为 pages 的默认部署分支 | ||
![set-branch.jpg](/images/Init-my-first-hexo-blog/set-branch.jpg) | ||
![set-branch.webp](/images/Init-my-first-hexo-blog/set-branch.webp) | ||
|
||
|
||
### 6. 编写 github actions 代码 | ||
|
||
1) 修改 _config.yml 文件的 repo 改成你仓库的 ssh 地址 | ||
![config.jpg](/images/Init-my-first-hexo-blog/config.jpg) | ||
![config.webp](/images/Init-my-first-hexo-blog/config.webp) | ||
|
||
2) 在 hexo 博客文件夹的 .github 目录创建 deploy.yml 文件 | ||
|
||
![new-file.jpg](/images/Init-my-first-hexo-blog/new-file.jpg) | ||
![new-file.webp](/images/Init-my-first-hexo-blog/new-file.webp) | ||
|
||
下面的代码只需要修改你的用户名和邮箱 | ||
|
||
|
@@ -149,12 +149,12 @@ jobs: | |
<br> | ||
3) 最后提交代码并推送 | ||
![commit-push.jpg](/images/Init-my-first-hexo-blog/commit-push.jpg) | ||
![commit-push.webp](/images/Init-my-first-hexo-blog/commit-push.webp) | ||
### 7. 访问站点,部署成功! | ||
地址为 `https://用户名.github.io` | ||
|
||
![success.jpg](/images/Init-my-first-hexo-blog/success.jpg) | ||
![success.webp](/images/Init-my-first-hexo-blog/success.webp) | ||
|
||
<br> | ||
<br> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: 将 jpg 转换为 webp | ||
date: 2023-12-28 00:25:25 | ||
tags: | ||
--- | ||
> 本文主要介绍如何将 Jpg 转换为 WebP。 | ||
> 为什么要转换为 WebP 呢?因为 WebP 图片通常比 JPEG 图片更小,同时保持相似的视觉质量。也是现代浏览器支持、推荐使用的图片格式之一。 | ||
### 1. 安装 cwebp | ||
|
||
archlinux 系列的 | ||
```bash | ||
sudo pacman -S libwebp | ||
``` | ||
### 2. 转换 | ||
我编写了一个脚本,可以将当前 `images` 目录下的所有 jpg 文件转换为 webp 文件。 | ||
遍历所有文件夹并将图片转换为 WebP 格式。 | ||
```bash | ||
# 使用 find 命令遍历所有子文件夹中的图片文件 | ||
find images -type f \( -iname \*.jpg -o -iname \*.jpeg -o -iname \*.png \) -exec sh -c ' | ||
for file do | ||
# 获取文件的相对路径和文件名 | ||
relpath=$(dirname "$file") | ||
filename=$(basename "$file") | ||
# 使用 cwebp 将图片转换为 WebP 格式并保存到当前目录 | ||
cwebp "$file" -o "${relpath}/${filename%.*}.webp" | ||
# 删除原始图片文件已注释, 建议先在测试环境中运行一下再放到代码仓库中运行 | ||
# rm "$file" | ||
done | ||
' sh {} + | ||
``` | ||
可以看到确实图片体积减少很多,但是由于这张图片清晰度有点低,所以压缩后画质当然也不高。 | ||
![compare.webp](/images/Transfer-jpg-to-webp/compare.webp) | ||
|
||
### 3. 更改博客中的图片链接 | ||
|
||
vscode 或者别的 ide 批量替换你用到的 markdown 图片链接,将 .jpg 替换为 .webp 即可。 | ||
![replace.webp](/images/Transfer-jpg-to-webp/replace.webp) | ||
|
||
> 在部署博客之前,记得先在本地测试一下,看看是否有问题。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-92.1 KB
source/images/Fix-article-updated-time-on-github-pages/error-time.jpg
Binary file not shown.
Binary file added
BIN
+44.6 KB
source/images/Fix-article-updated-time-on-github-pages/error-time.webp
Binary file not shown.
Binary file removed
BIN
-132 KB
source/images/Fix-article-updated-time-on-github-pages/fluid-config.jpg
Binary file not shown.
Binary file added
BIN
+71.6 KB
source/images/Fix-article-updated-time-on-github-pages/fluid-config.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.