mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-06 15:10:29 +00:00
站点信息读取Notion数据
This commit is contained in:
@@ -6,33 +6,29 @@ import * as ThemeMap from '@/themes'
|
||||
export default function Category (props) {
|
||||
const { theme } = useGlobal()
|
||||
const ThemeComponents = ThemeMap[theme]
|
||||
return <ThemeComponents.LayoutCategory {...props} />
|
||||
const { siteInfo, posts } = props
|
||||
const { locale } = useGlobal()
|
||||
if (!posts) {
|
||||
return <ThemeComponents.Layout404 {...props}/>
|
||||
}
|
||||
const meta = {
|
||||
title: `${props.category} | ${locale.COMMON.CATEGORY} | ${siteInfo?.title || ''}`,
|
||||
description: siteInfo?.description,
|
||||
type: 'website'
|
||||
}
|
||||
return <ThemeComponents.LayoutCategory {...props} meta={meta} />
|
||||
}
|
||||
|
||||
export async function getStaticProps ({ params }) {
|
||||
export async function getStaticProps ({ params: { category } }) {
|
||||
const from = 'category-props'
|
||||
const category = params.category
|
||||
const {
|
||||
allPosts,
|
||||
categories,
|
||||
tags,
|
||||
postCount,
|
||||
latestPosts,
|
||||
customNav
|
||||
} = await getGlobalNotionData({ from })
|
||||
const filteredPosts = allPosts.filter(
|
||||
let props = await getGlobalNotionData({ from })
|
||||
const posts = props.allPosts.filter(
|
||||
post => post && post.category && post.category.includes(category)
|
||||
)
|
||||
props = { ...props, posts, category }
|
||||
|
||||
return {
|
||||
props: {
|
||||
tags,
|
||||
posts: filteredPosts,
|
||||
category,
|
||||
categories,
|
||||
postCount,
|
||||
latestPosts,
|
||||
customNav
|
||||
},
|
||||
props,
|
||||
revalidate: 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,22 +6,20 @@ import * as ThemeMap from '@/themes'
|
||||
export default function Category (props) {
|
||||
const { theme } = useGlobal()
|
||||
const ThemeComponents = ThemeMap[theme]
|
||||
return <ThemeComponents.LayoutCategoryIndex {...props}/>
|
||||
const { locale } = useGlobal()
|
||||
const { siteInfo } = props
|
||||
const meta = {
|
||||
title: `${locale.COMMON.CATEGORY} | ${siteInfo.title}`,
|
||||
description: siteInfo.description,
|
||||
type: 'website'
|
||||
}
|
||||
return <ThemeComponents.LayoutCategoryIndex {...props} meta={meta}/>
|
||||
}
|
||||
|
||||
export async function getStaticProps () {
|
||||
const from = 'category-index-props'
|
||||
const { allPosts, categories, tags, postCount, latestPosts, customNav } = await getGlobalNotionData({ from, categoryCount: 0 })
|
||||
|
||||
const props = await getGlobalNotionData({ from: 'category-index-props', categoryCount: 0 })
|
||||
return {
|
||||
props: {
|
||||
tags,
|
||||
allPosts,
|
||||
categories,
|
||||
postCount,
|
||||
latestPosts,
|
||||
customNav
|
||||
},
|
||||
props,
|
||||
revalidate: 1
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user