Hexo同步语雀文章

https://github.com/x-cold/yuque-hexo/

1、前提

  1. 事先拥有一个 hexo 项目,在package.json配置相关信息,详见 例子。
  2. node版本需要在8.x以上。

2、配置

 package.json
 {
 "name": "your hexo project",
 "yuqueConfig": {
 "baseUrl": "
 https://www.yuque.com/api/v2
 ",
 "login": "yinzhi",
 "repo": "blog",
"mdNameFormat": "title",
"postPath": "source/_posts/yuque"
}
}

“postPath”: 存放从语雀下载的 Markdown 文件的文件夹,除了 Hexo ,理论上可以支持其他支持 Front-matter 的 Markdown 静态博客

3、安装

npm i -g yuque-hexo
npm i --save-dev yuque-hexo

4、同步语雀文章

yuque-hexo sync

5、清楚hexo文章

yuque-hexo clean

6、Npm 脚本

{
"dev": "npm run sync && hexo s",
"sync": "yuque-hexo sync",
"clean:yuque": "yuque-hexo clean"
}

7、Debug

DEBUG=yuque-hexo.* yuque-hexo sync

8、提示


语雀同步过来的文章会生成两部分文件;

yuque.json: 从语雀 API 拉取的数据
source/_posts/yuque/*.md: 生成的 md 文件

9、例子

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "hexo": {
    "version": "3.8.0"
  },
  "scripts": {
    "clean": "hexo clean",
    "clean:yuque": "DEBUG=yuque-hexo.* yuque-hexo clean",
    "deploy": "hexo deploy",
    "publish": "npm run clean && npm run deploy",
    "dev": "hexo s",
    "sync": "DEBUG=yuque-hexo.* yuque-hexo sync",
    "reset": "npm run clean:yuque && npm run sync"
  },
  "dependencies": {
    "hexo": "^3.7.0",
    "hexo-generator-archive": "^0.1.5",
    "hexo-generator-category": "^0.1.3",
    "hexo-generator-index": "^0.2.1",
    "hexo-generator-searchdb": "^1.0.8",
    "hexo-generator-tag": "^0.2.0",
    "hexo-renderer-ejs": "^0.3.1",
    "hexo-renderer-marked": "^0.3.2",
    "hexo-renderer-stylus": "^0.3.3",
    "hexo-server": "^0.3.1",
    "yuque-hexo": "^1.3.0"
  },
  "yuqueConfig": {
    "baseUrl": "https://www.yuque.com/api/v2",
    "login": "chf",
    "repo": "note",
    "mdNameFormat": "slug",
    "postPath": "source/_posts/yuque"
  }
}
点赞 0

Saiyintai

软件测试工程师

暂无评论

相关推荐

Nginx代理apache2折腾笔记

apache2上面有php服务器已经配置好的。只是想用Nginx代理apache2. Nginx上有Tomat服务器,代理后就相当于有PHP服务器,JSP …

微信扫一扫,分享到朋友圈

Hexo同步语雀文章