diff --git a/lib/notion/getAllPosts.js b/lib/notion/getAllPosts.js index 21c8a4daa..f084a7ef4 100644 --- a/lib/notion/getAllPosts.js +++ b/lib/notion/getAllPosts.js @@ -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)