hexo博客部署
Hexo
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick Start
Create a new post
1 | $ hexo new "My New Post" |
More info: Writing
Clean
1 | $ hexo clean |
Run server
1 | $ hexo server |
More info: Server
Generate static files
1 | $ hexo generate |
More info: Generating
Deploy to remote sites
1 | $ hexo deploy |
More info: Deployment
Actions自动化部署
Hexo自动化工作流总是遇到问题,今天终于解决了。实现了自动部署,终于不用先在本地PC生成静态文件了。方便在不同环境直接通过修改md文件实现对博客的更新。
部署过程
新建一个博客源码私有仓库
BlogSource
创建一个有 repo 和 workflow 权限的 GitHub Token
将上述Token添加到私有仓库的Secrets,命令为HEXO_DEPLOY
创建工作流文件:
.github\workflows\hexo-deploy.yml
内容如下:
1 | name: Hexo Deploy GitHub Pages |
其中,用到的部署Action:https://github.com/h4m5t/hexo-deploy-github-pages-action
我这里是push到gh-pages分支了。要注意同步修改仓库设置中的Build Branch
源代码仓库中的.gitignore文件内容:
1 | .DS_Store |
遇到的问题
- Actions总是报权限错误。删除掉源代码仓库中的node_modules文件夹后解决。
- themes文件夹下内容push报错。删除掉themes文件夹下.git文件后解决。
参考
https://akilar.top/posts/f752c86d/
https://github.com/cys2004/blog_source
https://juejin.cn/post/7133235874858270728#heading-2
mermaid流程图
修改:_config.butterfly.yml
1 | # mermaid |
方法1
在博客根目录下执行:
1 | npm install hexo-filter-mermaid-diagrams --save |
参考:https://github.com/jerryc127/hexo-theme-butterfly/issues/1228#issuecomment-1554223960
安装此插件后,可以使用Typora支持的格式,方便本地预览和远程查看。
例如:
可以根据如下源码生成流程图:
1 | <pre class="mermaid">graph LR |
graph LR A[Attacker crafts
malicious payload
with JNDI lookup] --> C{Log4j parses:
Contains JNDI lookup?} C -->|Yes| D[Execute
JNDI lookup] C -->|No| E[Normal log] D --> F[Connect to
attacker's server] F --> G[Download &
execute
malicious class] G --> H[Attacker gains
server control] classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px; classDef highlight fill:#f9d5e5,stroke:#333,stroke-width:2px; classDef decision fill:#e3f2fd,stroke:#333,stroke-width:1px; classDef danger fill:#ffebee,stroke:#333,stroke-width:1px; class A,H highlight; class C decision; class G danger;
sequenceDiagram 前端->>前端: 用户首次打开前端页面 前端->>后台: version : 0
请求同步数据 后台->>前端: 返回数据,同时携带最大的version note right of 后台: 返回数据结构:{"version":100, data:[{},{},{}]}
方法2
使用butterfuly官方给出的引用方法。
参考:https://butterfly.js.org/posts/4aa8abbe/?highlight=mermaid#mermaid
写法:
1 | {% mermaid %} |
示例:
graph LR A[Attacker crafts<br>malicious payload<br>with JNDI lookup] --> C{Log4j parses:<br>Contains JNDI lookup?} C -->|Yes| D[Execute<br>JNDI lookup] C -->|No| E[Normal log] D --> F[Connect to<br>attacker's server] F --> G[Download &<br>execute<br>malicious class] G --> H[Attacker gains<br>server control] classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px; classDef highlight fill:#f9d5e5,stroke:#333,stroke-width:2px; classDef decision fill:#e3f2fd,stroke:#333,stroke-width:1px; classDef danger fill:#ffebee,stroke:#333,stroke-width:1px; class A,H highlight; class C decision; class G danger;
pie title Key elements in Product X "Calcium" : 42.96 "Potassium" : 50.05 "Magnesium" : 10.01 "Iron" : 5