mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-28 15:10:04 +00:00
fix date
This commit is contained in:
@@ -20,23 +20,23 @@ import { mapImgUrl, compressImage } from './mapImage'
|
||||
* @returns
|
||||
*
|
||||
*/
|
||||
export async function getGlobalNotionData({
|
||||
export async function getGlobalData({
|
||||
pageId = BLOG.NOTION_PAGE_ID,
|
||||
from
|
||||
}) {
|
||||
// 获取Notion数据
|
||||
const notionPageData = deepClone(await getNotionPageData({ pageId, from }))
|
||||
notionPageData.allNavPages = getNavPages({ allPages: notionPageData.allPages })
|
||||
delete notionPageData.block
|
||||
delete notionPageData.schema
|
||||
delete notionPageData.rawMetadata
|
||||
delete notionPageData.pageIds
|
||||
delete notionPageData.viewIds
|
||||
delete notionPageData.collection
|
||||
delete notionPageData.collectionQuery
|
||||
delete notionPageData.collectionId
|
||||
delete notionPageData.collectionView
|
||||
return notionPageData
|
||||
// 从notion获取
|
||||
const db = deepClone(await getNotionPageData({ pageId, from }))
|
||||
// 不返回的敏感数据
|
||||
delete db.block
|
||||
delete db.schema
|
||||
delete db.rawMetadata
|
||||
delete db.pageIds
|
||||
delete db.viewIds
|
||||
delete db.collection
|
||||
delete db.collectionQuery
|
||||
delete db.collectionId
|
||||
delete db.collectionView
|
||||
return db
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,8 +48,8 @@ function getLatestPosts({ allPages, from, latestPostCount }) {
|
||||
const allPosts = allPages?.filter(page => page.type === 'Post' && page.status === 'Published')
|
||||
|
||||
const latestPosts = Object.create(allPosts).sort((a, b) => {
|
||||
const dateA = new Date(a?.lastEditedTime || a?.sortDate)
|
||||
const dateB = new Date(b?.lastEditedTime || b?.sortDate)
|
||||
const dateA = new Date(a?.lastEditedTime || a?.publishDate)
|
||||
const dateB = new Date(b?.lastEditedTime || b?.publishDate)
|
||||
return dateB - dateA
|
||||
})
|
||||
return latestPosts.slice(0, latestPostCount)
|
||||
@@ -69,12 +69,12 @@ export async function getNotionPageData({ pageId, from }) {
|
||||
console.log('[缓存]:', `from:${from}`, `root-page-id:${pageId}`)
|
||||
return data
|
||||
}
|
||||
const pageRecordMap = await getDataBaseInfoByNotionAPI({ pageId, from })
|
||||
const db = await getDataBaseInfoByNotionAPI({ pageId, from })
|
||||
// 存入缓存
|
||||
if (pageRecordMap) {
|
||||
await setDataToCache(cacheKey, pageRecordMap)
|
||||
if (db) {
|
||||
await setDataToCache(cacheKey, db)
|
||||
}
|
||||
return pageRecordMap
|
||||
return db
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,7 +298,7 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
|
||||
// Sort by date
|
||||
if (BLOG.POSTS_SORT_BY === 'date') {
|
||||
allPages.sort((a, b) => {
|
||||
return b?.sortDate - a?.sortDate
|
||||
return b?.publishDate - a?.publishDate
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user