diff --git a/lib/notion/getAllPageIds.js b/lib/notion/getAllPageIds.js index b4428df7..6d606d9a 100644 --- a/lib/notion/getAllPageIds.js +++ b/lib/notion/getAllPageIds.js @@ -13,7 +13,8 @@ export default function getAllPageIds (collectionQuery, collectionId, collection } } } catch (error) { - + console.error('Error fetching page IDs:', error); + return []; } // 否则按照数据库原始排序 diff --git a/themes/example/index.js b/themes/example/index.js index 412366e1..4834039b 100644 --- a/themes/example/index.js +++ b/themes/example/index.js @@ -199,7 +199,29 @@ const LayoutSlug = props => { * @returns */ const Layout404 = props => { - return <>404 Not found. + const router = useRouter() + useEffect(() => { + // 延时3秒如果加载失败就返回首页 + setTimeout(() => { + const article = isBrowser && document.getElementById('article-wrapper') + if (!article) { + router.push('/').then(() => { + // console.log('找不到页面', router.asPath) + }) + } + }, 3000) + }, []) + + return <> +
+
+

404

+
+

页面无法加载,即将返回首页

+
+
+
+ } /** diff --git a/themes/fukasawa/index.js b/themes/fukasawa/index.js index d184f1f9..5553167c 100644 --- a/themes/fukasawa/index.js +++ b/themes/fukasawa/index.js @@ -214,7 +214,29 @@ const LayoutArchive = props => { * @returns */ const Layout404 = props => { - return <>404 + const router = useRouter() + useEffect(() => { + // 延时3秒如果加载失败就返回首页 + setTimeout(() => { + const article = isBrowser && document.getElementById('article-wrapper') + if (!article) { + router.push('/').then(() => { + // console.log('找不到页面', router.asPath) + }) + } + }, 3000) + }, []) + + return <> +
+
+

404

+
+

页面无法加载,即将返回首页

+
+
+
+ } /** diff --git a/themes/game/index.js b/themes/game/index.js index 04bc192c..cd46246a 100644 --- a/themes/game/index.js +++ b/themes/game/index.js @@ -30,6 +30,7 @@ import SideBarContent from './components/SideBarContent' import SideBarDrawer from './components/SideBarDrawer' import CONFIG from './config' import { Style } from './style' +import { useRouter } from 'next/router' // const AlgoliaSearchModal = dynamic(() => import('@/components/AlgoliaSearchModal'), { ssr: false }) @@ -352,7 +353,29 @@ const LayoutSlug = props => { * @returns */ const Layout404 = props => { - return <>404 Not found. + const router = useRouter() + useEffect(() => { + // 延时3秒如果加载失败就返回首页 + setTimeout(() => { + const article = isBrowser && document.getElementById('article-wrapper') + if (!article) { + router.push('/').then(() => { + // console.log('找不到页面', router.asPath) + }) + } + }, 3000) + }, []) + + return <> +
+
+

404

+
+

页面无法加载,即将返回首页

+
+
+
+ } /** diff --git a/themes/gitbook/index.js b/themes/gitbook/index.js index dbe65ff9..2da36965 100644 --- a/themes/gitbook/index.js +++ b/themes/gitbook/index.js @@ -432,14 +432,34 @@ const LayoutArchive = props => { } /** - * 404 + * 404 页面 + * @param {*} props + * @returns */ const Layout404 = props => { - return ( -
- 404 Not found. -
- ) + const router = useRouter() + useEffect(() => { + // 延时3秒如果加载失败就返回首页 + setTimeout(() => { + const article = isBrowser && document.getElementById('article-wrapper') + if (!article) { + router.push('/').then(() => { + // console.log('找不到页面', router.asPath) + }) + } + }, 3000) + }, []) + + return <> +
+
+

404

+
+

页面无法加载,即将返回首页

+
+
+
+ } /** diff --git a/themes/medium/index.js b/themes/medium/index.js index 798f4879..799a29b6 100644 --- a/themes/medium/index.js +++ b/themes/medium/index.js @@ -331,10 +331,31 @@ const LayoutArchive = props => { * @returns */ const Layout404 = props => { + const router = useRouter() + useEffect(() => { + // 延时3秒如果加载失败就返回首页 + setTimeout(() => { + const article = + typeof document !== 'undefined' && + document.getElementById('notion-article') + if (!article) { + router.push('/').then(() => { + // console.log('找不到页面', router.asPath) + }) + } + }, 3000) + }) return ( <> -
- 404 Not found. +
+
+

+ 404 +

+
+

页面未找到

+
+
) diff --git a/themes/nav/index.js b/themes/nav/index.js index 691c369a..f2316aed 100755 --- a/themes/nav/index.js +++ b/themes/nav/index.js @@ -363,15 +363,33 @@ const LayoutArchive = props => { /** * 404 + * @param {*} props + * @returns */ const Layout404 = props => { - return ( - <> -
- 404 Not found. -
+ const router = useRouter() + useEffect(() => { + // 延时3秒如果加载失败就返回首页 + setTimeout(() => { + const article = isBrowser && document.getElementById('article-wrapper') + if (!article) { + router.push('/').then(() => { + // console.log('找不到页面', router.asPath) + }) + } + }, 3000) + }, []) + + return <> +
+
+

404

+
+

页面无法加载,即将返回首页

+
+
+
- ) } /** diff --git a/themes/nobelium/index.js b/themes/nobelium/index.js index 47f2f205..4455dd96 100644 --- a/themes/nobelium/index.js +++ b/themes/nobelium/index.js @@ -267,7 +267,29 @@ const LayoutSlug = props => { * @returns */ const Layout404 = props => { - return <>404 Not found. + const router = useRouter() + useEffect(() => { + // 延时3秒如果加载失败就返回首页 + setTimeout(() => { + const article = isBrowser && document.getElementById('article-wrapper') + if (!article) { + router.push('/').then(() => { + // console.log('找不到页面', router.asPath) + }) + } + }, 3000) + }, []) + + return <> +
+
+

404

+
+

页面无法加载,即将返回首页

+
+
+
+ } /** diff --git a/themes/plog/index.js b/themes/plog/index.js index 88f4054b..3c9c7d62 100644 --- a/themes/plog/index.js +++ b/themes/plog/index.js @@ -222,7 +222,29 @@ const LayoutSlug = props => { * @returns */ const Layout404 = props => { - return <>404 Not found. + const router = useRouter() + useEffect(() => { + // 延时3秒如果加载失败就返回首页 + setTimeout(() => { + const article = isBrowser && document.getElementById('article-wrapper') + if (!article) { + router.push('/').then(() => { + // console.log('找不到页面', router.asPath) + }) + } + }, 3000) + }, []) + + return <> +
+
+

404

+
+

页面无法加载,即将返回首页

+
+
+
+ } /** diff --git a/themes/starter/components/MessageForm.js b/themes/starter/components/MessageForm.js index 718cfcd1..47d8af09 100644 --- a/themes/starter/components/MessageForm.js +++ b/themes/starter/components/MessageForm.js @@ -23,26 +23,6 @@ export const MessageForm = () => { })) } - // useEffect(() => { - // const form = formRef.current - // const handleSubmit = (e) => { - // e.preventDefault() - // submitComments(formData).then(response => { - // console.log('Subscription succeeded:', response) - // // 在此处添加成功订阅后的操作 - // setSuccess(true) - // }) - // .catch(error => { - // console.error('Subscription failed:', error) - // // 在此处添加订阅失败后的操作 - // }) - // } - // form?.addEventListener('submit', handleSubmit) - // return () => { - // form?.removeEventListener('submit', handleSubmit) - // } - // }, [submitComments]) - return ( <>