diff --git a/package.json b/package.json
index 840740c9..c35e4166 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "coryd.dev",
- "version": "5.8.0",
+ "version": "5.9.0",
"description": "The source for my personal site. Built using 11ty and hosted on Netlify.",
"type": "module",
"scripts": {
diff --git a/src/_data/links.js b/src/_data/links.js
index ec8b2afb..fb2e622d 100644
--- a/src/_data/links.js
+++ b/src/_data/links.js
@@ -2,7 +2,6 @@ import EleventyFetch from '@11ty/eleventy-fetch'
export default async function () {
const API_TOKEN_READWISE = process.env.API_TOKEN_READWISE
- const url = 'https://readwise.io/api/v3/list?location=archive'
const formatLinkData = (links) => links.map((link) => {
return {
title: link['title'],
@@ -15,17 +14,28 @@ export default async function () {
description: `${link['summary']}
`,
}
})
+ const fullData = [];
+ let nextPageCursor = null;
+ let requestCount = 0;
- const res = EleventyFetch(url, {
- duration: '1h',
- type: 'json',
- fetchOptions: {
- headers: {
- Authorization: `Token ${API_TOKEN_READWISE}`,
+ while (true) {
+ const queryParams = new URLSearchParams()
+ if (nextPageCursor) queryParams.append('pageCursor', nextPageCursor)
+ const res = EleventyFetch(`https://readwise.io/api/v3/list?location=archive&${queryParams.toString()}`, {
+ duration: '1h',
+ type: 'json',
+ fetchOptions: {
+ headers: {
+ Authorization: `Token ${API_TOKEN_READWISE}`,
+ },
},
- },
- }).catch()
- const data = await res
- return formatLinkData(data['results']).filter((link) => link.tags.includes('share'))
+ }).catch()
+ const data = await res
+ fullData.push(...data['results']);
+ nextPageCursor = data['nextPageCursor']
+ requestCount++;
+ if (!nextPageCursor || requestCount === 20) break;
+ }
+ return formatLinkData(fullData).filter((link) => link.tags.includes('share'))
}