npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@binnnn/yuque-hexo

v1.9.1

Published

A downloader for articles from yuque

Downloads

7

Readme

yuque-hexo

NPM version build status Test coverage David deps npm download

A downloader for articles from yuque(语雀知识库同步工具)

Usage

Premise

建议使用 Node.js >= 12

事先拥有一个 hexo 项目,并在 package.json 中配置相关信息,可参考 例子

Config

配置 YUQUE_TOKEN

出于对知识库安全性的调整,使用第三方 API 访问知识库,需要传入环境变量 YUQUE_TOKEN,在语雀上点击 个人头像 -> 设置 -> Token 即可获取。传入 YUQUE_TOKEN 到 yuque-hexo 的进程有两种方式:

  • 设置全局的环境变量 YUQUE_TOKEN
  • 命令执行时传入环境变量
    • mac / linux: YUQUE_TOKEN=xxx yuque-hexo sync
    • windows: set YUQUE_TOKEN=xxx && yuque-hexo sync

配置 图床TOKEN(可选)

语雀的url存在防盗链的问题,直接部署可能导致图片无法加载。 如果需要语雀URL上传到图床中并替换原链接,就需要配置上传密钥。

访问图床的密钥管理获取密钥,然后传入密钥到yuque-hexo

  • 腾讯云API密钥管理

  • 阿里云API密钥管理

  • 七牛云API密钥管理

  • 在设置YUQUE_TOKEN的基础上配置SECRET_ID和SECRET_KEY

  • 命令执行时传入环境变量

    • mac / linux: YUQUE_TOKEN=xxx SECRET_ID=xxx SECRET_KEY=xxx yuque-hexo sync
    • windows: set YUQUE_TOKEN=xxx SECRET_ID=xxx SECRET_KEY=xxx && yuque-hexo sync

配置知识库

package.json

{
  "name": "your hexo project",
  "yuqueConfig": {
    "postPath": "source/_posts/yuque",
    "cachePath": "yuque.json",
    "mdNameFormat": "title",
    "adapter": "hexo",
    "concurrency": 5,
    "baseUrl": "https://www.yuque.com/api/v2",
    "login": "yinzhi",
    "repo": "blog",
    "onlyPublished": false,
    "onlyPublic": false,
    "lastGeneratePath": "lastGeneratePath.log",
    "imgCdn": {
      "enabled": false,
      "imageBed": "qiniu",
      "host": "",
      "bucket": "",
      "region": "",
      "prefixKey": ""
    }
  }
}

| 参数名 | 含义 | 默认值 | | ------------- | ------------------------------------ | -------------------- | | postPath | 文档同步后生成的路径 | source/_posts/yuque | | cachePath | 文档下载缓存文件 | yuque.json | | lastGeneratePath | 上一次同步结束的时间戳的文件 | | | mdNameFormat | 文件名命名方式 (title / slug) | title | | adapter | 文档生成格式 (hexo/markdown) | hexo | | concurrency | 下载文章并发数 | 5 | | baseUrl | 语雀 API 地址 | - | | login | 语雀 login (group), 也称为个人路径 | - | | repo | 语雀仓库短名称,也称为语雀知识库路径 | - | | onlyPublished | 只展示已经发布的文章 | false | | onlyPublic | 只展示公开文章 | false | | imgCdn | 语雀图片转CDN配置 | |

slug 是语雀的永久链接名,一般是几个随机字母。

imgCdn 语雀图片转图床配置说明

注意:开启后会将匹配到的所有的图片都上传到图床

| 参数名 | 含义 | 默认值 | | ------------- | ------------------------------------ | -------------------- | | enabled | 是否开启 | false | | imageBed | 选择将图片上传的图床,目前支持腾讯云(cos)、阿里云(oss)和七牛云(qiniu),默认使用七牛云 | 'qiniu' | | host | 使用七牛云图床时,需要指定CDN域名前缀 | bucket | 图床的bucket名称 | - | | region | 图床的的region | - | | prefixKey | 文件前缀 | - |

host 说明

由于七牛云默认使用CND进行图片外链访问(默认提供30天的临时域名或者添加自定义CDN域名),所以需要指定访问的域名前缀 例如:'host': http://image.1874.cool,域名后面不需要加斜杠

bucket和region说明

获取腾讯云的bucket和region,示例:{ bucket: "blog", region: "ap-guangzhou" }

获取阿里云的bucket和region,示例:{ bucket: "blog", region: "oss-cn-shenzhen" }

获取七牛云的bucket(空间)和region(机房),示例:{ bucket: "blog", region: "Zone_z2" }

七牛云机房取值: 华东(Zone_z0)华北(Zone_z0)华南(Zone_z0)北美(Zone_z0)

prefixKey 说明

如果需要将图片上传到bucket的根目录,那么prefixKey不用配置。

如果想上传到指定目录blog/image下,则需要配置prefixKey为"prefixKey": "blog/image"。

目录名前后都不需要加斜杠

Install

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

Sync

yuque-hexo sync

Clean

yuque-hexo clean

Npm Scripts

{
  "sync": "yuque-hexo sync",
  "clean:yuque": "yuque-hexo clean"
}

Debug

DEBUG=yuque-hexo.* yuque-hexo sync

Best practice

另外 x-cold 本人提供了一个触发 Travis CI 构建的 HTTP API 接口,详情请查看文档 (请勿恶意使用)

Notice

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

    • yuque.json: 从语雀 API 拉取的数据
    • source/_posts/yuque/*.md: 生成的 md 文件
  • 支持配置 front-matter, 语雀编辑器编写示例如下:

    • 语雀编辑器示例,可参考原文
    tags: [hexo, node]
    categories: [fe]
    cover: https://cdn.nlark.com/yuque/0/2019/jpeg/155457/1546857679810-d82e3d46-e960-419c-a715-0a82c48a2fd6.jpeg#align=left&display=inline&height=225&name=image.jpeg&originHeight=225&originWidth=225&size=6267&width=225
    
    ---
    
    some description
    
    <!-- more -->
    
    more detail

Example

Changelog

v1.9.1

  • 修复不使用图床配置时报错的问题

v1.9.0

  • 🔥 支持腾讯云/阿里云/七牛云图床链接替换语雀链接

v1.8.0

  • 🔥 支持自定义的适配器 adapter,具体查看 配置示例

v1.7.0

  • 🔥 支持配置 lastGeneratePath,同步文章后会记录一个时间戳,下一次同步文档时不再清空全部文档,只同步修改时间大于这个时间戳的文档
  • 🔥 支持语雀提示区块语法
  • 🐸 修复 front-matter 中 “:” 等特殊字符会导致文章无法正常生成
  • 🐸 由于 prettier 不再支持 Node 8,markdown 格式化仅在 node 版本 >= 10 生效
  • 🐸 现在必须配置 YUQUE_TOKEN 工具才能正常工作

v1.6.5

  • 🔥 支持过滤 public 文章
  • 🔥 生成的 markdown 自动格式化
  • 🔥 移除去除语雀的锚点

v1.6.4

v1.6.3

  • 🔥 支持嵌套的 categories 解析 #56
  • 🐸 使用 filenamify 修复因为特殊字符的标题,生成非法的文件名导致的程序错误

v1.6.2

v1.6.1

  • 🐸 修复 tags 格式化问题

v1.6.0

  • 🐸 修复 descrption 导致的 front-matter 解析错误问题
  • 🔥 支持私有仓库同步
  • 🔥 使用语雀官方的 SDK,支持 YUQUE_TOKEN,可以解除 API 调用次数限制

v1.5.0

  • 支持自定义 front-matter

v1.4.3

  • 支持过滤未发布文章 onlyPublished

v1.4.2

  • 支持纯 markdown 导出
  • 支持请求并发数量参数 concurrency

v1.4.0

  • 升级项目架构,增强扩展性,支持自定义 adpter

v1.3.1

  • 修复 front-matter 处理格式问题

v1.2.1

  • 修复 windows 环境下命令行报错的问题
  • 支持自定义文件夹和博客文件命名

v1.1.1

  • 支持 hexo-front-matter,可以在文章中编辑 tags / date 等属性