mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-31 23:16:54 +00:00
将LINK,NEXT_REVALIDATE_SECOND配置提升到NOTION_CONFIG中
This commit is contained in:
@@ -46,7 +46,11 @@ export async function getStaticProps({ params: { category }, locale }) {
|
||||
|
||||
return {
|
||||
props,
|
||||
revalidate: parseInt(BLOG.NEXT_REVALIDATE_SECOND)
|
||||
revalidate: siteConfig(
|
||||
'REVALIDATE_SECOND',
|
||||
BLOG.NEXT_REVALIDATE_SECOND,
|
||||
props.NOTION_CONFIG
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,10 @@ import { useRouter } from 'next/router'
|
||||
|
||||
export default function Category(props) {
|
||||
// 根据页面路径加载不同Layout文件
|
||||
const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() })
|
||||
const Layout = getLayoutByTheme({
|
||||
theme: siteConfig('THEME'),
|
||||
router: useRouter()
|
||||
})
|
||||
|
||||
return <Layout {...props} />
|
||||
}
|
||||
@@ -28,7 +31,10 @@ export async function getStaticProps({ params: { category, page } }) {
|
||||
// 处理文章页数
|
||||
props.postCount = props.posts.length
|
||||
// 处理分页
|
||||
props.posts = props.posts.slice(siteConfig('POSTS_PER_PAGE') * (page - 1), siteConfig('POSTS_PER_PAGE') * page)
|
||||
props.posts = props.posts.slice(
|
||||
siteConfig('POSTS_PER_PAGE') * (page - 1),
|
||||
siteConfig('POSTS_PER_PAGE') * page
|
||||
)
|
||||
|
||||
delete props.allPages
|
||||
props.page = page
|
||||
@@ -37,7 +43,11 @@ export async function getStaticProps({ params: { category, page } }) {
|
||||
|
||||
return {
|
||||
props,
|
||||
revalidate: parseInt(BLOG.NEXT_REVALIDATE_SECOND)
|
||||
revalidate: siteConfig(
|
||||
'REVALIDATE_SECOND',
|
||||
BLOG.NEXT_REVALIDATE_SECOND,
|
||||
props.NOTION_CONFIG
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +60,9 @@ export async function getStaticPaths() {
|
||||
// 过滤状态类型
|
||||
const categoryPosts = allPages
|
||||
?.filter(page => page.type === 'Post' && page.status === 'Published')
|
||||
.filter(post => post && post.category && post.category.includes(category.name))
|
||||
.filter(
|
||||
post => post && post.category && post.category.includes(category.name)
|
||||
)
|
||||
// 处理文章页数
|
||||
const postCount = categoryPosts.length
|
||||
const totalPages = Math.ceil(postCount / siteConfig('POSTS_PER_PAGE'))
|
||||
|
||||
@@ -24,6 +24,10 @@ export async function getStaticProps({ locale }) {
|
||||
delete props.allPages
|
||||
return {
|
||||
props,
|
||||
revalidate: parseInt(BLOG.NEXT_REVALIDATE_SECOND)
|
||||
revalidate: siteConfig(
|
||||
'REVALIDATE_SECOND',
|
||||
BLOG.NEXT_REVALIDATE_SECOND,
|
||||
props.NOTION_CONFIG
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user