Community Plugin
View plugin on GitHubgatsby-source-yuque
Source plugin for pulling data into Gatsby from 语雀 API.
Install
npm install --save gatsby-source-yuque
How to use
// In your gatsby-config.js
plugins: [
{
resolve: 'gatsby-source-yuque',
options: {
login: 'raincal',
repo: 'blog',
mdNameFormat: 'title'
}
}
]Options
| Name | Default | Description |
|---|---|---|
baseUrl |
https://www.yuque.com/api/v2/ |
base url |
login |
user/team unique name | |
repo |
repo name | |
mdNameFormat |
title |
title or slug |
timeout |
10000 |
timeout specifies the number of milliseconds before the request times out |
concurrency |
5 |
Parallel downloads of article bodies |
minIntervalMs |
0 |
Minimum delay (ms) between successive body downloads |
dailyBudget |
Infinity |
Max number of article bodies to download per run (graceful stop when hit) |
maxRetries |
3 |
Retry count for HTTP 429 / 5xx responses |
backoffBaseMs |
60000 |
Base backoff for 429 when Retry-After header is missing |
stopOnRateLimit |
true |
If true, treat terminal 429 as graceful stop (cache preserved) |
onRateLimit |
(waitMs, attempt) => void — called before each 429 retry sleep |
|
onArticleFetched |
async (article, index, total) => void — per-article hook (good for incremental cache flushing) |
|
onBudgetExhausted |
() => void — called once when dailyBudget is reached |
Rate-limit & budget handling
Starting from 3.1.0, the underlying Downloader:
- Processes articles newest-first (by
updated_atdescending) so the most valuable content is captured first under constraint. - Automatically retries
429/5xxresponses with exponential backoff, honoringRetry-Afterwhen present. - Preserves partial progress: when a run is aborted by a final
429ordailyBudgetexhaustion, the cache is still flushed viawriteCache(oryuquePath). - Exposes
onArticleFetchedso callers can persist progress after every successful body download.
getArticles() remains backward compatible; new call shapes are additive:
await client.getArticles(); // legacy: single page
await client.getArticles({offset: 0, limit: 100}); // explicit paging
await client.getArticles({fetchAll: true, limit: 100}); // auto-paginateQuery for all nodes
{
allYuqueDoc {
edges {
node {
title
slug
cover
description
created_at
childMarkdownRemark {
html
}
}
}
}
}