mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-17 15:09:31 +00:00
hotfix: sort by date
This commit is contained in:
@@ -45,9 +45,7 @@ export async function getAllPosts({ notionPageData, from, pageType }) {
|
||||
// Sort by date
|
||||
if (BLOG.POSTS_SORT_BY === 'date') {
|
||||
posts.sort((a, b) => {
|
||||
const dateA = new Date(a?.publishTime || a.createdTime)
|
||||
const dateB = new Date(b?.publishTime || b.createdTime)
|
||||
return dateB - dateA
|
||||
return b?.sortDate - a?.sortDate
|
||||
})
|
||||
}
|
||||
return posts
|
||||
|
||||
@@ -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?.createdTime || a?.publishTime)
|
||||
const dateB = new Date(b?.lastEditedTime || b?.createdTime || b?.publishTime)
|
||||
const dateA = new Date(a?.lastEditedTime || a?.sortDate)
|
||||
const dateB = new Date(b?.lastEditedTime || b?.sortDate)
|
||||
return dateB - dateA
|
||||
})
|
||||
return latestPosts.slice(0, latestPostCount)
|
||||
@@ -298,7 +298,7 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
|
||||
// Sort by date
|
||||
if (BLOG.POSTS_SORT_BY === 'date') {
|
||||
allPages.sort((a, b) => {
|
||||
return b.publishTime - a.publishTime
|
||||
return b?.sortDate - a?.sortDate
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ export default async function getPageProperties(id, block, schema, authToken, ta
|
||||
}
|
||||
}
|
||||
|
||||
properties.sortDate = value?.date?.start_date || value.created_time
|
||||
properties.createdTime = formatDate(new Date(value.created_time).toString(), BLOG.LANG)
|
||||
properties.publishTime = value?.date?.start_date ? formatDate(new Date(value?.date?.start_date).toString, BLOG.LANG) : properties.createdTime
|
||||
properties.lastEditedTime = formatDate(new Date(value?.last_edited_time).toString(), BLOG.LANG)
|
||||
|
||||
Reference in New Issue
Block a user