diff --git a/components/SideBar.js b/components/SideBar.js
index 562525a4..8838b651 100644
--- a/components/SideBar.js
+++ b/components/SideBar.js
@@ -9,8 +9,8 @@ const SideBar = ({ tags, currentTag, post, posts }) => {
// 按时间排序
if (posts) {
posts = posts.sort((a, b) => {
- const dateA = new Date(a?.date?.start_date || a.createdTime)
- const dateB = new Date(b?.date?.start_date || b.createdTime)
+ const dateA = new Date(a?.lastEditedTime || a.createdTime)
+ const dateB = new Date(b?.lastEditedTime || b.createdTime)
return dateB - dateA
}).slice(0, 5)
}
@@ -31,17 +31,17 @@ const SideBar = ({ tags, currentTag, post, posts }) => {
{posts.map(post => {
return (
-
+
-
{post.title}
+
{post.title}
)
diff --git a/lib/notion/getAllPosts.js b/lib/notion/getAllPosts.js
index 3deff3cd..02aaab2a 100644
--- a/lib/notion/getAllPosts.js
+++ b/lib/notion/getAllPosts.js
@@ -48,10 +48,12 @@ async function getPostsFromNotionAPI ({ from }) {
for (let i = 0; i < pageIds.length; i++) {
const id = pageIds[i]
const properties = (await getPageProperties(id, block, schema)) || null
- // Add fullwidth, createdtime to properties
properties.createdTime = new Date(
block[id].value?.created_time
).toString()
+ properties.lastEditedTime = new Date(
+ block[id].value?.last_edited_time
+ ).toString()
properties.fullWidth = block[id].value?.format?.page_full_width ?? false
properties.page_cover = getPostCover(id, block, pageRecordMap) ?? getContentFirstImage(id, block, pageRecordMap)
properties.content = block[id].value?.content ?? []
diff --git a/lib/notion/getPostBlocks.js b/lib/notion/getPostBlocks.js
index c9cbfa50..e032a329 100644
--- a/lib/notion/getPostBlocks.js
+++ b/lib/notion/getPostBlocks.js
@@ -1,6 +1,7 @@
import BLOG from '@/blog.config'
import { NotionAPI } from 'notion-client'
import { getDataFromCache, setDataToCache } from '@/lib/cache/cache_manager'
+import { useRouter } from 'next/router'
export async function getPostBlocks (id, from) {
let pageBlock = await getDataFromCache('page_block_' + id)