自定义404等待时间

This commit is contained in:
tangly1024.com
2024-02-08 14:49:14 +08:00
parent 2a584362c3
commit 5ed4893743
15 changed files with 224 additions and 22 deletions

View File

@@ -147,6 +147,22 @@ const LayoutPostList = props => {
*/
const LayoutSlug = props => {
const { post, lock, validPassword } = props
const router = useRouter()
useEffect(() => {
// 404
if (!post) {
setTimeout(() => {
if (isBrowser) {
const article = document.getElementById('notion-article')
if (!article) {
router.push('/404').then(() => {
console.warn('找不到页面', router.asPath)
})
}
}
}, siteConfig('POST_WAITING_TIME_FOR_404') * 1000)
}
}, [post])
return (
<>
{lock