ijjk / notion-blog

A Next.js site using new SSG support with a Notion backed blog
https://notion-blog.vercel.app
MIT License
3.7k stars 536 forks source link

fix: set pagination limit to 30 and query all pagniated results #67

Closed JinhaiZ closed 3 years ago

JinhaiZ commented 3 years ago

Notion paginates the result from loadPageChunk API request. With pagination, the results are divided into "chunks" of data contains rougly 100 blocks (or less, can be specified in the limit attribute of the request).

Currently, notion-blog only process the first "chunk" of the results, when the page contains more than 100 blocks of data, the rest of them is ignored.

In order to get the full result, we need examine the cursor object from the response, if it contains a non-empty array of stack, we should use it for the next loadPageChunk API request.

Additionally, set the limit to 30 as there is no need to fetch 100 blocks of data at one time.

vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/jj4/notion-blog/9AaqYBpEMHkRXrofW52p1nrJs9Jk
✅ Preview: https://notion-blog-git-fork-c0dingnote-main-jj4.vercel.app