{"id":13442217,"url":"https://github.com/x-cold/yuque-hexo","last_synced_at":"2025-03-20T13:32:59.023Z","repository":{"id":38628520,"uuid":"146150500","full_name":"x-cold/yuque-hexo","owner":"x-cold","description":"同步语雀的文章到你的 Hexo 项目吧！","archived":false,"fork":false,"pushed_at":"2024-02-23T09:14:00.000Z","size":144,"stargazers_count":712,"open_issues_count":25,"forks_count":82,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-01T00:52:56.196Z","etag":null,"topics":["blog","download","hexo","nodejs","sync","yuque"],"latest_commit_sha":null,"homepage":"http://blog.lxstart.net/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/x-cold.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-08-26T04:12:59.000Z","updated_at":"2024-09-10T12:20:24.000Z","dependencies_parsed_at":"2024-02-23T10:29:43.738Z","dependency_job_id":"6c770ca3-0a36-48d6-b3ae-fd869c7d415d","html_url":"https://github.com/x-cold/yuque-hexo","commit_stats":{"total_commits":143,"total_committers":19,"mean_commits":7.526315789473684,"dds":0.5104895104895104,"last_synced_commit":"0624bc0834570935f87ef72260a86ef74f3600f8"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-cold%2Fyuque-hexo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-cold%2Fyuque-hexo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-cold%2Fyuque-hexo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-cold%2Fyuque-hexo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/x-cold","download_url":"https://codeload.github.com/x-cold/yuque-hexo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221768499,"owners_count":16877650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blog","download","hexo","nodejs","sync","yuque"],"created_at":"2024-07-31T03:01:43.078Z","updated_at":"2024-10-28T02:31:41.802Z","avatar_url":"https://github.com/x-cold.png","language":"JavaScript","funding_links":[],"categories":["HarmonyOS","JavaScript"],"sub_categories":["Windows Manager"],"readme":"# yuque-hexo\n\n[![NPM version][npm-image]][npm-url]\n[![build status][gitflow-image]][gitflow-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/yuque-hexo.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/yuque-hexo\n[gitflow-image]: https://github.com/x-cold/yuque-hexo/actions/workflows/nodejs.yml/badge.svg?branch=master\n[gitflow-url]: https://github.com/x-cold/yuque-hexo/actions/workflows/nodejs.yml\n[codecov-image]: https://codecov.io/gh/x-cold/yuque-hexo/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/x-cold/yuque-hexo\n[david-image]: https://img.shields.io/david/x-cold/yuque-hexo.svg?style=flat-square\n[david-url]: https://david-dm.org/x-cold/yuque-hexo\n[download-image]: https://badgen.net/npm/dt/yuque-hexo\n[download-url]: https://npmjs.org/package/yuque-hexo\n\nA downloader for articles from yuque（语雀知识库同步工具）\n\n# Usage\n\n## Premise\n\n\u003e 建议使用 Node.js \u003e= 12 \n\n事先拥有一个 [hexo](https://github.com/hexojs/hexo) 项目，并在 `package.json` 中配置相关信息，可参考 [例子](#Example)。\n\n## Config\n\n### 配置 YUQUE_TOKEN\n\n出于对知识库安全性的调整，使用第三方 API 访问知识库，需要传入环境变量 YUQUE_TOKEN，在语雀上点击 个人头像 -\u003e 设置 -\u003e Token 即可获取。传入 YUQUE_TOKEN 到 yuque-hexo 的进程有两种方式：\n\n- 设置全局的环境变量 YUQUE_TOKEN\n- 命令执行时传入环境变量\n  - mac / linux: `YUQUE_TOKEN=xxx yuque-hexo sync`\n  - windows: `set YUQUE_TOKEN=xxx \u0026\u0026 yuque-hexo sync`\n\n### 配置 图床TOKEN(可选)\n语雀的url存在防盗链的问题，直接部署可能导致图片无法加载。\n如果需要语雀URL上传到图床中并替换原链接，就需要配置上传密钥。\n\n访问图床的密钥管理获取密钥，然后传入密钥到yuque-hexo\n- 腾讯云[API密钥管理](https://console.cloud.tencent.com/cam/capi)\n- 阿里云[API密钥管理](https://ram.console.aliyun.com/manage/ak)\n- 七牛云[API密钥管理](https://portal.qiniu.com/user/key)\n- 又拍云[操作员管理](https://console.upyun.com/account/operators/)\n- GitHub图床[生成Github Token](https://github.com/settings/tokens)\n\u003e 又拍云的SECRET_ID=操作员账号，SECRET_KEY=操作员密码\n\u003e \n\u003e Github图床的`SECRET_ID=用户名`，`SECRET_KEY=Github Token`。\n\u003e 注意在生成`token`时，记得勾选上读写权限，即 `write:packages`和`read:packages`\n\n- 在设置YUQUE_TOKEN的基础上配置SECRET_ID和SECRET_KEY\n- 命令执行时传入环境变量\n  - mac / linux: `YUQUE_TOKEN=xxx SECRET_ID=xxx SECRET_KEY=xxx yuque-hexo sync`\n  - windows: `set YUQUE_TOKEN=xxx SECRET_ID=xxx SECRET_KEY=xxx \u0026\u0026 yuque-hexo sync`\n\n\n### 配置知识库\n\n\u003e package.json\n\n```json\n{\n  \"name\": \"your hexo project\",\n  \"yuqueConfig\": {\n    \"postPath\": \"source/_posts/yuque\",\n    \"cachePath\": \"yuque.json\",\n    \"mdNameFormat\": \"title\",\n    \"adapter\": \"hexo\",\n    \"concurrency\": 5,\n    \"baseUrl\": \"https://www.yuque.com/api/v2\",\n    \"login\": \"yinzhi\",\n    \"repo\": \"blog\",\n    \"onlyPublished\": false,\n    \"onlyPublic\": false,\n    \"lastGeneratePath\": \"lastGeneratePath.log\",\n    \"imgCdn\": {\n      \"enabled\": false,\n      \"concurrency\": 0,\n      \"imageBed\": \"qiniu\",\n      \"host\": \"\",\n      \"bucket\": \"\",\n      \"region\": \"\",\n      \"prefixKey\": \"\"\n    }\n  }\n}\n```\n\n| 参数名        | 含义                                 | 默认值               |\n| ------------- | ------------------------------------ | -------------------- |\n| postPath      | 文档同步后生成的路径                 | source/\\_posts/yuque |\n| cachePath     | 文档下载缓存文件                     | yuque.json           |\n| lastGeneratePath | 上一次同步结束的时间戳的文件             |                       |\n| mdNameFormat  | 文件名命名方式 (title / slug)        | title                |\n| adapter       | 文档生成格式 (hexo/markdown)         | hexo                 |\n| concurrency   | 下载文章并发数                       | 5                    |\n| baseUrl       | 语雀 API 地址                        | -                    |\n| login         | 语雀 login (group), 也称为个人路径   | -                    |\n| repo          | 语雀仓库短名称，也称为语雀知识库路径 | -                    |\n| onlyPublished | 只展示已经发布的文章                 | false                |\n| onlyPublic    | 只展示公开文章                       | false                |\n| imgCdn        | 语雀图片转CDN配置                    |                |\n\u003e slug 是语雀的永久链接名，一般是几个随机字母。\n\nimgCdn 语雀图片转图床配置说明\n\n注意：开启后会将匹配到的所有的图片都上传到图床\n\n| 参数名       | 含义                                                                                      | 默认值     |\n|-----------|-----------------------------------------------------------------------------------------|---------|\n| enabled   | 是否开启                                                                                    | false   |\n| concurrency | 上传图片并发数, 0代表无限制，使用github图床时，并发问题严重，建议设置为1                                               | 0       |\n| imageBed  | 选择将图片上传的图床\u003cbr/\u003e目前支持腾讯云(cos)、阿里云(oss)和七牛云(qiniu)，又拍云(upyun)，Github图床(github)\u003cbr/\u003e默认使用七牛云 | 'qiniu' |\n| host      | 使用七牛云/又拍云图床时，需要指定CDN域名前缀                                                                |         |\n| bucket    | 图床的bucket名称                                                                             | -       |\n| region    | 图床的的region                                                                              | -       |\n| prefixKey | 文件前缀                                                                                    | -       |\n\n\u003e host 说明\n\u003e\n\u003e 由于七牛云默认使用CND进行图片外链访问（默认提供30天的临时域名或者添加自定义CDN域名），所以需要指定访问的域名前缀\n\u003e 例如：'host': `http://image.1874.cool`，域名后面不需要加斜杠\n\n\u003e 又拍云和七牛云有点类似，默认使用临时域名访问，但不同的是又拍云的临时域名暂时是由`服务名.test.upcdn.net`组成，默认为http访问\n\u003e \n\u003e 如果使用临时域名，host可不填。使用自定义域名，默认为http访问，如果需要指定协议为https，则需要填写完整的域名\n\u003e \n\u003e 例如 'host': `upyun.1874.cool`或 `https://upyun.1874.cool ` \n\n\u003e Github图床的默认域名是`raw.githubusercontent.com`，如果要使用jsdelivr进行加速，可以配置`host`为`cdn.jsdelivr.net`，\n\u003e \n\u003e 例如 'host': `cdn.jsdelivr.net`\n\n\u003e bucket和region说明\n\u003e \n\u003e [获取腾讯云的bucket和region](https://console.cloud.tencent.com/cos/bucket)，示例：{ bucket: \"blog\", region: \"ap-guangzhou\" }\n\u003e \n\u003e [获取阿里云的bucket和region](https://oss.console.aliyun.com/bucket)，示例：{ bucket: \"blog\", region: \"oss-cn-shenzhen\" }\n\u003e \n\u003e [获取七牛云的bucket(空间)和region(机房)](https://portal.qiniu.com/kodo/overview)，示例：{ bucket: \"blog\", region: \"Zone_z2\" }\n\u003e \n\u003e 七牛云机房取值: 华东(Zone_z0)华北(Zone_z1)华南(Zone_z2)\n\u003e \n\u003e 又拍云没有bucket和region的概念，只有服务名。所以这里的bucket=服务名，region暂时保留不需要填写\n\u003e \n\u003e Github图床也没有bucket和region的概念。所以bucket=仓库名，region暂时保留不需要填写\n\n\u003e prefixKey 说明\n\u003e\n\u003e 如果需要将图片上传到bucket的根目录，那么prefixKey不用配置。\n\u003e\n\u003e 如果想上传到指定目录blog/image下，则需要配置prefixKey为\"prefixKey\": \"blog/image\"。\n\u003e\n\u003e 目录名前后都不需要加斜杠\n\n\u003e 配置示例: [yuque-hexo配置示例](https://github.com/LetTTGACO/yuque-hexo-example)\n\n\n## Install\n\n```bash\nnpm i -g yuque-hexo\n# or\nnpm i --save-dev yuque-hexo\n```\n\n## Sync\n\n```\nyuque-hexo sync\n```\n\n## Clean\n\n```\nyuque-hexo clean\n```\n\n## Npm Scripts\n\n```json\n{\n  \"sync\": \"yuque-hexo sync\",\n  \"clean:yuque\": \"yuque-hexo clean\"\n}\n```\n\n## Debug\n\n```\nDEBUG=yuque-hexo.* yuque-hexo sync\n```\n\n## Best practice\n- [语雀云端写作Hexo+Github Actions+COS持续集成](https://www.yuque.com/1874w/1874.cool/roeayv)\n- [Hexo 博客终极玩法：云端写作，自动部署](https://www.yuque.com/u46795/blog/dlloc7)\n- [Hexo：语雀云端写作 Github Actions 持续集成](https://www.zhwei.cn/hexo-github-actions-yuque/)\n\n\u003e 另外 x-cold 本人提供了一个触发 Travis CI 构建的 HTTP API 接口，详情请查看[文档](https://github.com/x-cold/aliyun-function/tree/master/travis_ci) (请勿恶意使用)\n\n# Notice\n\n- 语雀同步过来的文章会生成两部分文件；\n\n  - yuque.json: 从语雀 API 拉取的数据\n  - source/\\_posts/yuque/\\*.md: 生成的 md 文件\n\n- 支持配置 front-matter, 语雀编辑器编写示例如下:\n\n  - 语雀编辑器示例，可参考[原文](https://www.yuque.com/u46795/blog/dlloc7)\n\n  ```markdown\n  tags: [hexo, node]\n  categories: [fe]\n  cover: https://cdn.nlark.com/yuque/0/2019/jpeg/155457/1546857679810-d82e3d46-e960-419c-a715-0a82c48a2fd6.jpeg#align=left\u0026display=inline\u0026height=225\u0026name=image.jpeg\u0026originHeight=225\u0026originWidth=225\u0026size=6267\u0026width=225\n\n  ---\n\n  some description\n\n  \u003c!-- more --\u003e\n\n  more detail\n  ```\n\n- - 如果遇到上传到语雀的图片无法加载的问题， 可以考虑开启imgCdn配置或者参考这个处理方式[yuque-hexo插件语雀图片防盗链限制的解决方案](https://1874.cool/osar7h/)或者参考这个处理方式 [#41](https://github.com/x-cold/yuque-hexo/issues/41)\n\n# Example\n\n- yuque to hexo: [x-cold/blog](https://github.com/x-cold/blog/blob/master/package.json)\n- yuque to github repo: [txd-team/monthly](https://github.com/txd-team/monthly/blob/master/package.json)\n- [yuque-hexo配置示例](https://github.com/LetTTGACO/yuque-hexo-example)\n\n# Changelog\n\n### v1.9.5\n- 修复腾讯云图床/Github图床上传问题\n- 图片上传失败时，取消停止进程\n- 新增图片上传时的并发数concurrency，使用Github图床时，并发问题严重，建议设置为1\n\n### v1.9.4\n- 🔥 新增GitHub图床和又拍云图床\n\n### v1.9.2\n- 修复上传图片到图床时可能由于用户代理缺失导致403问题\n\n### v1.9.1\n- 修复不使用图床配置时报错的问题\n\n### v1.9.0\n- 🔥 支持腾讯云/阿里云/七牛云图床链接替换语雀链接\n\n### v1.8.0\n- 🔥 支持自定义的适配器 adapter，具体查看 [配置示例](https://github.com/x-cold/yuque-hexo/tree/master/test/custom-adapter-project)\n\n### v1.7.0\n\n- 🔥 支持配置 lastGeneratePath，同步文章后会记录一个时间戳，下一次同步文档时不再清空全部文档，只同步修改时间大于这个时间戳的文档\n- 🔥 支持语雀提示区块语法\n- 🐸 修复 front-matter 中 “:” 等特殊字符会导致文章无法正常生成\n- 🐸 由于 [prettier 不再支持 Node 8](https://github.com/prettier/eslint-config-prettier/issues/140)，markdown 格式化仅在 node 版本 \u003e= 10 生效\n- 🐸 现在必须配置 YUQUE_TOKEN 工具才能正常工作\n\n### v1.6.5\n\n- 🔥 支持过滤 public 文章\n- 🔥 生成的 markdown 自动格式化\n- 🔥 移除去除语雀的锚点\n\n### v1.6.4\n\n- 🐸 修复多行 \u003cbr /\u003e 的[问题](https://github.com/x-cold/yuque-hexo/pull/59)\n\n### v1.6.3\n\n- 🔥 支持嵌套的 categories 解析 #56\n- 🐸 使用 [filenamify](https://github.com/sindresorhus/filenamify) 修复因为特殊字符的标题，生成非法的文件名导致的程序错误\n\n### v1.6.2\n\n- 🔥 使用 slug 自定义 [urlname](https://github.com/x-cold/yuque-hexo/pull/37)\n\n### v1.6.1\n\n- 🐸 修复 tags 格式化[问题](https://github.com/x-cold/yuque-hexo/issues/31)\n\n### v1.6.0\n\n- 🐸 修复 descrption 导致的 front-matter 解析错误[问题](https://github.com/x-cold/yuque-hexo/issues/27#issuecomment-490138318)\n- 🔥 支持私有仓库同步\n- 🔥 使用语雀官方的 SDK，支持 YUQUE_TOKEN，可以解除 API 调用次数限制\n\n### v1.5.0\n\n- 支持自定义 front-matter\n\n### v1.4.3\n\n- 支持过滤未发布文章 `onlyPublished`\n\n### v1.4.2\n\n- 支持纯 markdown 导出\n- 支持请求并发数量参数 `concurrency`\n\n### v1.4.0\n\n- 升级项目架构，增强扩展性，支持自定义 adpter\n\n### v1.3.1\n\n- 修复 front-matter 处理格式问题\n\n### v1.2.1\n\n- 修复 windows 环境下命令行报错的问题\n- 支持自定义文件夹和博客文件命名\n\n### v1.1.1\n\n- 支持 hexo-front-matter，可以在文章中编辑 tags / date 等属性\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-cold%2Fyuque-hexo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fx-cold%2Fyuque-hexo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-cold%2Fyuque-hexo/lists"}