diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js index 4873cf9c..7b4aebbe 100644 --- a/lib/notion/getNotionData.js +++ b/lib/notion/getNotionData.js @@ -37,7 +37,17 @@ export async function getGlobalNotionData ({ const customNav = await getCustomNav({ notionPageData }) const categories = await getAllCategories(allPosts) const tags = await getAllTags({ allPosts, tagOptions, sliceCount: tagsCount }) - // 深拷贝 + const latestPosts = await getLatestPosts({ notionPageData, from, latestPostCount }) + return { allPosts, latestPosts, categories, postCount, customNav, tags } +} + +/** + * 获取最新文章 + * @param {*}} param0 + * @returns + */ +async function getLatestPosts ({ notionPageData, from, latestPostCount }) { + const allPosts = await getAllPosts({ notionPageData, from, pageType: ['Post'] }) let latestPosts = Object.create(allPosts) // 时间排序 latestPosts.sort((a, b) => { @@ -48,14 +58,7 @@ export async function getGlobalNotionData ({ // 只取前五 latestPosts = latestPosts.slice(0, latestPostCount) - return { - allPosts, - latestPosts, - categories, - postCount, - customNav, - tags - } + return latestPosts } /**