mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 15:09:22 +00:00
封装getLatestPosts方法
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user