diff --git a/pages/[...slug].js b/pages/[...slug].js index a39e81d6..511ca761 100644 --- a/pages/[...slug].js +++ b/pages/[...slug].js @@ -8,6 +8,7 @@ import { getNotion } from '@/lib/notion/getNotion' import { getPageTableOfContents } from '@/lib/notion/getPageTableOfContents' import { getLayoutByTheme } from '@/themes/theme' import md5 from 'js-md5' +import { isBrowser } from '@/lib/utils' /** * 根据notion的slug访问页面 @@ -37,18 +38,18 @@ const Slug = props => { // 文章加载 useEffect(() => { // 404 - // if (!post) { - // setTimeout(() => { - // if (isBrowser()) { - // const article = document.getElementById('notion-article') - // if (!article) { - // router.push('/404').then(() => { - // console.warn('找不到页面', router.asPath) - // }) - // } - // } - // }, 8 * 1000) // 404时长 8秒 - // } + if (!post) { + setTimeout(() => { + if (isBrowser()) { + const article = document.getElementById('notion-article') + if (!article) { + router.push('/404').then(() => { + console.warn('找不到页面', router.asPath) + }) + } + } + }, 5 * 1000) // 404时长 8秒 + } // 文章加密 if (post?.password && post?.password !== '') { @@ -121,6 +122,7 @@ export async function getStaticProps({ params: { slug } }) { // 无法获取文章 if (!props?.post) { + props.post = null return { props, revalidate: parseInt(BLOG.NEXT_REVALIDATE_SECOND) } } diff --git a/themes/gitbook/LayoutBase.js b/themes/gitbook/LayoutBase.js index 457fcdc6..0d169314 100644 --- a/themes/gitbook/LayoutBase.js +++ b/themes/gitbook/LayoutBase.js @@ -3,7 +3,7 @@ import { useState, createContext, useContext, useEffect } from 'react' import Footer from './components/Footer' import InfoCard from './components/InfoCard' import RevolverMaps from './components/RevolverMaps' -import CONFIG_MEDIUM from './config_medium' +import CONFIG_GITBOOK from './config_gitbook' import TopNavBar from './components/TopNavBar' import SearchInput from './components/SearchInput' import BottomMenuBar from './components/BottomMenuBar' @@ -14,6 +14,7 @@ import BlogPostListScroll from './components/BlogPostListScroll' import ArticleInfo from './components/ArticleInfo' import Catalog from './components/Catalog' import { useRouter } from 'next/router' +import Announcement from './components/Announcement' const ThemeGlobalMedium = createContext() /** @@ -50,7 +51,7 @@ const LayoutBase = (props) => {
{/* 左侧推拉抽屉 */} -