mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-23 15:09:46 +00:00
伪静态&刷新缓存时间
This commit is contained in:
@@ -95,8 +95,10 @@ export async function getStaticPaths() {
|
||||
}
|
||||
|
||||
export async function getStaticProps({ params: { slug } }) {
|
||||
// slug 是个数组
|
||||
const fullSlug = slug.join('/')
|
||||
let fullSlug = slug.join('/')
|
||||
if (BLOG.PSEUDO_STATIC) {
|
||||
fullSlug += '.html'
|
||||
}
|
||||
const from = `slug-props-${fullSlug}`
|
||||
const props = await getGlobalNotionData({ from })
|
||||
props.post = props.allPages.find((p) => {
|
||||
@@ -106,13 +108,13 @@ export async function getStaticProps({ params: { slug } }) {
|
||||
if (!props.post) {
|
||||
const pageId = slug.slice(-1)[0]
|
||||
if (pageId.length < 32) {
|
||||
return { props, revalidate: 1 }
|
||||
return { props, revalidate: BLOG.NEXT_REVALIDATE_SECOND }
|
||||
}
|
||||
const post = await getNotion(pageId)
|
||||
if (post) {
|
||||
props.post = post
|
||||
} else {
|
||||
return { props, revalidate: 1 }
|
||||
return { props, revalidate: BLOG.NEXT_REVALIDATE_SECOND }
|
||||
}
|
||||
} else {
|
||||
props.post.blockMap = await getPostBlocks(props.post.id, 'slug')
|
||||
@@ -130,7 +132,7 @@ export async function getStaticProps({ params: { slug } }) {
|
||||
delete props.allPages
|
||||
return {
|
||||
props,
|
||||
revalidate: 1
|
||||
revalidate: BLOG.NEXT_REVALIDATE_SECOND
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import React from 'react'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import * as ThemeMap from '@/themes'
|
||||
import BLOG from '@/blog.config'
|
||||
|
||||
const ArchiveIndex = props => {
|
||||
const { theme, locale } = useGlobal()
|
||||
@@ -26,7 +27,7 @@ export async function getStaticProps() {
|
||||
|
||||
return {
|
||||
props,
|
||||
revalidate: 1
|
||||
revalidate: BLOG.NEXT_REVALIDATE_SECOND
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ export async function getStaticProps({ params: { category } }) {
|
||||
|
||||
return {
|
||||
props,
|
||||
revalidate: 1
|
||||
revalidate: BLOG.NEXT_REVALIDATE_SECOND
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ export async function getStaticProps({ params: { category, page } }) {
|
||||
|
||||
return {
|
||||
props,
|
||||
revalidate: 1
|
||||
revalidate: BLOG.NEXT_REVALIDATE_SECOND
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import React from 'react'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import * as ThemeMap from '@/themes'
|
||||
import { getAllCategories } from '@/lib/notion/getAllCategories'
|
||||
import BLOG from '@/blog.config'
|
||||
|
||||
/**
|
||||
* 分类首页
|
||||
@@ -30,6 +31,6 @@ export async function getStaticProps() {
|
||||
delete props.categoryOptions
|
||||
return {
|
||||
props,
|
||||
revalidate: 1
|
||||
revalidate: BLOG.NEXT_REVALIDATE_SECOND
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ export async function getStaticProps() {
|
||||
meta,
|
||||
...props
|
||||
},
|
||||
revalidate: 5
|
||||
revalidate: BLOG.NEXT_REVALIDATE_SECOND
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ export async function getStaticProps({ params: { page } }) {
|
||||
|
||||
return {
|
||||
props,
|
||||
revalidate: 1
|
||||
revalidate: BLOG.NEXT_REVALIDATE_SECOND
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ export async function getStaticProps({ params: { keyword } }) {
|
||||
props.keyword = keyword
|
||||
return {
|
||||
props,
|
||||
revalidate: 1
|
||||
revalidate: BLOG.NEXT_REVALIDATE_SECOND
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export async function getStaticProps({ params: { keyword, page } }) {
|
||||
props.page = page
|
||||
return {
|
||||
props,
|
||||
revalidate: 1
|
||||
revalidate: BLOG.NEXT_REVALIDATE_SECOND
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { useRouter } from 'next/router'
|
||||
import * as ThemeMap from '@/themes'
|
||||
import BLOG from '@/blog.config'
|
||||
|
||||
const Search = props => {
|
||||
const { posts, siteInfo } = props
|
||||
@@ -58,7 +59,7 @@ export async function getStaticProps() {
|
||||
props.posts = allPosts
|
||||
return {
|
||||
props,
|
||||
revalidate: 1
|
||||
revalidate: BLOG.NEXT_REVALIDATE_SECOND
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export async function getStaticProps({ params: { tag, page } }) {
|
||||
delete props.allPages
|
||||
return {
|
||||
props,
|
||||
revalidate: 1
|
||||
revalidate: BLOG.NEXT_REVALIDATE_SECOND
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user