diff --git a/src/app/site/[site]/not-found.tsx b/src/app/site/[site]/not-found.tsx index dbbc0cf9..0a7954c6 100644 --- a/src/app/site/[site]/not-found.tsx +++ b/src/app/site/[site]/not-found.tsx @@ -1,4 +1,4 @@ -import { PageContent } from "~/components/common/PageContent" +import { Image } from "~/components/ui/Image" import { SITE_URL } from "~/lib/env" import { useTranslation } from "~/lib/i18n" @@ -13,16 +13,20 @@ export default async function NotFound() { {t("404 - Whoops, this page is gone.")} - +
+ +
) diff --git a/src/lib/server-side-props.ts b/src/lib/server-side-props.ts deleted file mode 100644 index eedec027..00000000 --- a/src/lib/server-side-props.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { GetServerSidePropsContext, GetServerSidePropsResult } from "next" - -class Redirect extends Error { - constructor(public url: string) { - super("") - } -} - -class NotFound extends Error {} - -export const redirect = (url: string) => new Redirect(url) - -export const notFound = (message?: string) => new NotFound(message) - -export const isNotFoundError = (error: unknown) => error instanceof NotFound - -export const serverSidePropsHandler = < - TProps extends { [key: string]: any } = { [key: string]: any }, ->( - fn: ( - ctx: GetServerSidePropsContext, - ) => Promise<{ props: TProps } | Redirect | NotFound>, -) => { - return async ( - ctx: GetServerSidePropsContext, - ): Promise> => { - try { - const result = await fn(ctx) - if (result instanceof Redirect) { - return { - redirect: { - destination: result.url, - permanent: false, - }, - } - } - if (result instanceof NotFound) { - return { - notFound: true, - } - } - return result - } catch (error: any) { - console.log("serverSidePropsHandler error", error) - const actualError = error.cause || error - if (actualError instanceof Redirect) { - return { - redirect: { - destination: actualError.url, - permanent: false, - }, - } - } - if (actualError instanceof NotFound) { - return { - notFound: true, - } - } - ctx.res.statusCode = 500 - return { - props: { - // @ts-expect-error - error: error.message, - }, - } - } - } -} diff --git a/src/models/page.model.ts b/src/models/page.model.ts index 8e8569f3..5c5f208a 100644 --- a/src/models/page.model.ts +++ b/src/models/page.model.ts @@ -12,7 +12,6 @@ import { GeneralAccount } from "@crossbell/connect-kit" import { indexer } from "@crossbell/indexer" import { expandCrossbellNote } from "~/lib/expand-unit" -import { notFound } from "~/lib/server-side-props" import { checkSlugReservedWords } from "~/lib/slug-reserved-words" import { getKeys, getStorage } from "~/lib/storage" import { ExpandedNote, PageVisibilityEnum } from "~/lib/types" @@ -449,10 +448,6 @@ export async function getPage(input: { } } - if (!expandedNote && !mustLocal) { - throw notFound(`page ${input.slug} not found`) - } - return expandedNote } @@ -496,9 +491,7 @@ export async function checkLike({ characterId: number noteId: number }) { - if (!account.characterId) { - throw notFound(`character not found`) - } else { + if (account.characterId) { return indexer.link.getMany(account.characterId, { linkType: "like", toCharacterId: characterId,