Skip to content

Commit

Permalink
100개 이상의 글을 가져오지 못하는 문제
Browse files Browse the repository at this point in the history
  • Loading branch information
hyuunnn committed Apr 7, 2024
1 parent 187c147 commit d40b706
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/notion/getAllPosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,21 @@ export async function getAllPosts ({ includePages = false }) {
} else {
// Construct Data
const pageIds = getAllPageIds(collectionQuery)
const wholeBlocks = await (await api.getBlocks(pageIds)).recordMap.block

const data = []
for (let i = 0; i < pageIds.length; i++) {
const id = pageIds[i]
const properties = (await getPageProperties(id, block, schema)) || null
const properties = (await getPageProperties(id, wholeBlocks, schema)) || null
if (!wholeBlocks[id]) continue

// Add fullwidth to properties
properties.fullWidth = block[id].value?.format?.page_full_width ?? false
properties.fullWidth = wholeBlocks[id].value?.format?.page_full_width ?? false
// Convert date (with timezone) to unix milliseconds timestamp
properties.date = (
properties.date?.start_date
? dayjs.tz(properties.date?.start_date)
: dayjs(block[id].value?.created_time)
: dayjs(wholeBlocks[id].value?.created_time)
).valueOf()

data.push(properties)
Expand Down

0 comments on commit d40b706

Please sign in to comment.