diff --git a/apps/core/src/components/share-page-not-found-error.tsx b/apps/core/src/components/share-page-not-found-error.tsx new file mode 100644 index 000000000..064a62c25 --- /dev/null +++ b/apps/core/src/components/share-page-not-found-error.tsx @@ -0,0 +1,35 @@ +import { Empty } from '@affine/component'; +import { Logo1Icon } from '@blocksuite/icons'; + +export const SharePageNotFoundError = () => { + return ( +
+ + + + +
+ ); +}; diff --git a/apps/core/src/pages/share/detail-page.tsx b/apps/core/src/pages/share/detail-page.tsx index 54cb5a5d1..e135a55a4 100644 --- a/apps/core/src/pages/share/detail-page.tsx +++ b/apps/core/src/pages/share/detail-page.tsx @@ -9,11 +9,17 @@ import { noop } from 'foxact/noop'; import type { ReactElement } from 'react'; import { useCallback } from 'react'; import type { LoaderFunction } from 'react-router-dom'; -import { redirect, useLoaderData } from 'react-router-dom'; +import { + isRouteErrorResponse, + redirect, + useLoaderData, + useRouteError, +} from 'react-router-dom'; import { applyUpdate } from 'yjs'; import { PageDetailEditor } from '../../adapters/shared'; import { AppContainer } from '../../components/affine/app-container'; +import { SharePageNotFoundError } from '../../components/share-page-not-found-error'; function assertArrayBuffer(value: unknown): asserts value is ArrayBuffer { if (!(value instanceof ArrayBuffer)) { @@ -71,3 +77,14 @@ export const Component = (): ReactElement => { ); }; + +export function ErrorBoundary() { + const error = useRouteError(); + return isRouteErrorResponse(error) ? ( +

+ {error.status} {error.statusText} +

+ ) : ( + + ); +}