前提条件
搭建好 Hexo 博客环境
配置步骤
插件源码地址 https://github.com/x-cold/yuque-hexo
- 安装 npm install -g yuque-hexo –save
- 配置 修改博客根目录下的 package.json 文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| "yuqueConfig": { "postPath": "source/_posts", "cachePath": "yuque.json", "mdNameFormat": "slug", "adapter": "hexo", "concurrency": 5, "baseUrl": "https://www.yuque.com/api/v2", "login": "xituchengxiaoyang", "repo": "blog", "token": "语雀token", "onlyPublished": true, "onlyPublic": true }, "devDependencies": { "yuque-hexo": "^1.6.0" }, "hexo": { "version": "4.2.1" },
|
参数解释
参数名 |
含义 |
默认值 |
postPath |
文档同步后生成的路径 |
source/_posts/yuque |
cachePath |
文档下载缓存文件 |
yuque.json |
mdNameFormat |
文件名命名方式 (title / slug) |
title |
adapter |
文档生成格式 (hexo/markdown) |
hexo |
concurrency |
下载文章并发数 |
5 |
baseUrl |
语雀 API 地址 |
- |
login |
语雀 login (group), 也称为个人路径 |
- |
repo |
语雀仓库短名称,也称为语雀知识库路径 |
- |
onlyPublished |
只展示已经发布的文章 |
false |
onlyPublic |
只展示公开文章 |
false |
baseUrl 是固定的照抄就行,mdNameFormat 建议使用 title,repo 信息在这边看
Token 需要设置一下
- 在 package.json 中配置 scripts
1 2 3 4 5
| { "sync": "yuque-hexo sync", "clean:yuque": "yuque-hexo clean" }
|
完整的 package.json 文件如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| { "name": "hexo-site", "version": "0.0.0", "private": true, "scripts": { "build": "hexo generate", "clean": "hexo clean", "deploy": "hexo deploy", "server": "hexo server", "sync": "yuque-hexo sync", "clean:yuque": "yuque-hexo clean" }, "hexo": { "version": "4.2.1" }, "dependencies": { "hexo": "^4.2.1", "hexo-deployer-git": "^4.0.0", "hexo-generator-archive": "^2.0.0", "hexo-generator-category": "^2.0.0", "hexo-generator-feed": "^3.0.0", "hexo-generator-index": "^3.0.0", "hexo-generator-json-content": "^4.2.3", "hexo-generator-tag": "^2.0.0", "hexo-helper-qrcode": "^1.0.2", "hexo-renderer-ejs": "^2.0.0", "hexo-renderer-less": "^4.0.0", "hexo-renderer-marked": "^6.0.0", "hexo-renderer-stylus": "^2.1.0", "hexo-server": "^3.0.0", "hexo-theme-landscape": "^0.0.3", "yuque-hexo": "^1.9.5" }, "devDependencies": { "yuque-hexo": "^1.9.5" }, "yuqueConfig": { "postPath": "source/_posts/yuque", "cachePath": "yuque.json", "mdNameFormat": "title", "adapter": "hexo", "concurrency": 5, "baseUrl": "https://www.yuque.com/api/v2", "login": "XXXXX", "repo": "XXXX", "token": "XXXXX", "onlyPublished": false, "onlyPublic": false } }
|
- 同步命令
yuque-hexo sync 同步
yuque-hexo clean 清楚本地缓存
一些坑
- 语雀图片无法正常显示
因为语雀图片防盗链机制,图片无法正常显示,需要对主题下的文件做一点修改如我使用的 indigo,需要修改 themes/indigo/layout/_partial/head.ejs ,添加如下的源码
1
| <meta name="referrer" content="no-referrer" />
|
- 部署出错,kex_exchange_identification: Connection closed by remote
github 22 端口 timeout,直接使用 443 端口解决,在**~/.ssh/config **文件中添加如下
1 2 3 4
| Host github.com HostName ssh.github.com User git Port 443
|
- 在命令行工具中使用代理
在.zshrc 或者.bash_profile 中添加如下命令,后重新加载环境变量,需要使用到梯子只需要先执行 on_proxy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| function on_proxy() { export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com" export http_proxy="http://127.0.0.1:9850" export https_proxy=$http_proxy export all_proxy=socks5://127.0.0.1:9850 echo -e "\n" echo -e "proxy is on" }
function off_proxy(){ unset http_proxy unset https_proxy unset all_proxy echo -e "proxy is off" }
|
mac 下查看 clash 中的代理信息如下
不要使用 ping www.google.com来进行测试,因为ping命令使用的是ICMP协议,是不支持代理的。
参考文章
[1] http://www.manongjc.com/detail/61-xmojtxvddsuftbg.html
[2] https://cloud.tencent.com/developer/article/2114329
[3] https://cloud.tencent.com/developer/article/2168702
[4] https://zhuanlan.zhihu.com/p/577256660