将LINK,NEXT_REVALIDATE_SECOND配置提升到NOTION_CONFIG中

This commit is contained in:
tangly1024.com
2024-04-11 18:05:32 +08:00
parent 69ff9ecb60
commit 6ce9def3fa
20 changed files with 160 additions and 57 deletions

View File

@@ -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
)
}
}

View File

@@ -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'))

View File

@@ -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
)
}
}