From 80fc0e29e8fdf6eb9f2b2701d3efbe2bf5e07c7f Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Sat, 24 Jun 2023 12:06:03 +0800 Subject: [PATCH] =?UTF-8?q?gitbook=E9=A6=96=E9=A1=B5=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/[...slug].js | 26 ++++++++-------- themes/gitbook/LayoutBase.js | 13 ++++---- themes/gitbook/LayoutIndex.js | 31 +++++++++++++++++--- themes/gitbook/LayoutSlug.js | 16 ++++------ themes/gitbook/components/JumpToTopButton.js | 4 +-- themes/gitbook/components/MenuBarMobile.js | 10 +++---- themes/gitbook/components/TopNavBar.js | 10 +++---- themes/gitbook/config_gitbook.js | 15 ++++++++++ themes/gitbook/config_medium.js | 24 --------------- themes/gitbook/index.js | 4 +-- 10 files changed, 84 insertions(+), 69 deletions(-) create mode 100644 themes/gitbook/config_gitbook.js delete mode 100644 themes/gitbook/config_medium.js 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) => {
{/* 左侧推拉抽屉 */} -