diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js
index 80444cdb..683754b1 100644
--- a/lib/notion/getNotionData.js
+++ b/lib/notion/getNotionData.js
@@ -27,11 +27,15 @@ export async function getGlobalNotionData({
// 获取Notion数据
const notionPageData = deepClone(await getNotionPageData({ pageId, from }))
delete notionPageData.block
- delete notionPageData.collection
- delete notionPageData.collectionQuery
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
}
@@ -192,12 +196,10 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) {
const collectionQuery = pageRecordMap.collection_query
const collectionView = pageRecordMap.collection_view
const schema = collection?.schema
- const tagOptions = getTagOptions(schema)
- const categoryOptions = getCategoryOptions(schema)
+
const viewIds = rawMetadata?.view_ids
const collectionData = []
const pageIds = getAllPageIds(collectionQuery, collectionId, collectionView, viewIds)
- const siteInfo = getBlogInfo({ collection, block })
if (pageIds?.length === 0) {
console.error('获取到的文章列表为空,请检查notion模板', collectionQuery, collection, collectionView, viewIds, pageRecordMap)
}
@@ -207,15 +209,12 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) {
if (!value) {
continue
}
- const properties = (await getPageProperties(id, block, schema, null, tagOptions, siteInfo)) || null
+ const properties = (await getPageProperties(id, block, schema, null, getTagOptions(schema))) || null
if (properties) {
collectionData.push(properties)
}
}
- // 获取page作为自定义菜单
- const customNav = getCustomNav({ allPages: collectionData.filter(post => post.type === 'Page' && post.status === 'Published') })
-
// 文章计数
let postCount = 0
const allPages = collectionData.filter(post => {
@@ -238,8 +237,10 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) {
})
}
- const categories = getAllCategories({ allPages, categoryOptions, sliceCount: BLOG.PREVIEW_CATEGORY_COUNT })
- const tags = getAllTags({ allPages, sliceCount: BLOG.PREVIEW_TAG_COUNT, tagOptions })
+ const categoryOptions = getAllCategories({ allPages, categoryOptions: getCategoryOptions(schema), sliceCount: BLOG.PREVIEW_CATEGORY_COUNT })
+ const tagOptions = getAllTags({ allPages, sliceCount: BLOG.PREVIEW_TAG_COUNT, tagOptions: getTagOptions(schema) })
+ const siteInfo = getBlogInfo({ collection, block })
+ const customNav = getCustomNav({ allPages: collectionData.filter(post => post.type === 'Page' && post.status === 'Published') })
const latestPosts = getLatestPosts({ allPages, from, latestPostCount: 5 })
return {
@@ -258,8 +259,6 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) {
customNav,
postCount,
pageIds,
- categories,
- tags,
latestPosts
}
}
diff --git a/lib/notion/getPageProperties.js b/lib/notion/getPageProperties.js
index 6079ce51..b498fd82 100644
--- a/lib/notion/getPageProperties.js
+++ b/lib/notion/getPageProperties.js
@@ -6,7 +6,7 @@ import { defaultMapImageUrl } from 'react-notion-x'
// import { createHash } from 'crypto'
import md5 from 'js-md5'
-export default async function getPageProperties(id, block, schema, authToken, tagOptions, siteInfo) {
+export default async function getPageProperties(id, block, schema, authToken, tagOptions) {
const rawProperties = Object.entries(block?.[id]?.value?.properties || [])
const excludeProperties = ['date', 'select', 'multi_select', 'person']
const value = block[id]?.value
@@ -89,7 +89,7 @@ export default async function getPageProperties(id, block, schema, authToken, ta
properties.lastEditedTime = formatDate(new Date(value?.last_edited_time).toString(), BLOG.LANG)
properties.fullWidth = value.format?.page_full_width ?? false
properties.pageIcon = getImageUrl(block[id].value?.format?.page_icon, block[id].value) ?? ''
- properties.page_cover = getImageUrl(block[id].value?.format?.page_cover, block[id].value) ?? siteInfo?.pageCover
+ properties.page_cover = getImageUrl(block[id].value?.format?.page_cover, block[id].value) ?? ''
properties.content = value.content ?? []
properties.password = properties.password
? md5(properties.slug + properties.password)
diff --git a/themes/fukasawa/components/BlogCard.js b/themes/fukasawa/components/BlogCard.js
index 1c42923f..328176ce 100644
--- a/themes/fukasawa/components/BlogCard.js
+++ b/themes/fukasawa/components/BlogCard.js
@@ -4,8 +4,14 @@ import React from 'react'
import CONFIG_FUKA from '../config_fuka'
import Card from './Card'
-const BlogCard = ({ post, showSummary }) => {
+const BlogCard = ({ post, showSummary, siteInfo }) => {
const showPreview = CONFIG_FUKA.POST_LIST_PREVIEW && post.blockMap
+ // matery 主题默认强制显示图片
+ if (post && !post.page_cover) {
+ post.page_cover = siteInfo?.pageCover
+ }
+ const showPageCover = CONFIG_FUKA.POST_LIST_COVER && post?.page_cover
+
return (
{/*