mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-02 07:26:45 +00:00
最后更新时间
This commit is contained in:
@@ -2,6 +2,7 @@ import BLOG from '@/blog.config'
|
||||
import getAllPageIds from './getAllPageIds'
|
||||
import getPageProperties from './getPageProperties'
|
||||
import { defaultMapImageUrl } from 'react-notion-x'
|
||||
import formatDate from '@/lib/formatDate'
|
||||
import { getNotionPageData } from '@/lib/notion/getNotionData'
|
||||
import { delCacheData } from '@/lib/cache/cache_manager'
|
||||
|
||||
@@ -12,7 +13,7 @@ import { delCacheData } from '@/lib/cache/cache_manager'
|
||||
* @param pageType 页面类型数组 ['Post','Page']
|
||||
* @returns {Promise<*[]>}
|
||||
*/
|
||||
export async function getAllPosts ({ notionPageData, from, pageType }) {
|
||||
export async function getAllPosts({ notionPageData, from, pageType }) {
|
||||
if (!notionPageData) {
|
||||
notionPageData = await getNotionPageData({ from })
|
||||
}
|
||||
@@ -31,8 +32,8 @@ export async function getAllPosts ({ notionPageData, from, pageType }) {
|
||||
const id = pageIds[i]
|
||||
const properties = (await getPageProperties(id, pageBlock, schema)) || null
|
||||
properties.slug = properties.slug ?? properties.id
|
||||
properties.createdTime = new Date(pageBlock[id].value?.created_time).toString() // FIXME 似乎没有created_time 字段了
|
||||
properties.lastEditedTime = new Date(pageBlock[id].value?.last_edited_time).toString() // FIXME 似乎没有created_time 字段了
|
||||
properties.createdTime = formatDate(new Date(pageBlock[id].value?.created_time).toString(), BLOG.LANG)
|
||||
properties.lastEditedTime = formatDate(new Date(pageBlock[id].value?.last_edited_time).toString(), BLOG.LANG)
|
||||
properties.fullWidth = pageBlock[id].value?.format?.page_full_width ?? false
|
||||
properties.page_cover = getPostCover(id, pageBlock) ?? null
|
||||
properties.content = pageBlock[id].value?.content ?? []
|
||||
@@ -65,7 +66,7 @@ export async function getAllPosts ({ notionPageData, from, pageType }) {
|
||||
}
|
||||
|
||||
// 从Block获取封面图;优先取PageCover,否则取内容图片
|
||||
function getPostCover (id, block) {
|
||||
function getPostCover(id, block) {
|
||||
const pageCover = block[id].value?.format?.page_cover
|
||||
if (pageCover) {
|
||||
if (pageCover.startsWith('/')) return 'https://www.notion.so' + pageCover
|
||||
@@ -78,7 +79,7 @@ function getPostCover (id, block) {
|
||||
* @param {*} param0
|
||||
* @returns
|
||||
*/
|
||||
export async function getAllPostCount ({ notionPageData, from }) {
|
||||
export async function getAllPostCount({ notionPageData, from }) {
|
||||
if (!notionPageData) {
|
||||
notionPageData = await getNotionPageData({ from })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user