From a33ea9af5f667f77be7b49b3d96eb935e027814b Mon Sep 17 00:00:00 2001 From: Ashhhleyyy Date: Mon, 1 Aug 2022 17:40:05 +0100 Subject: [PATCH] fix(search): remove highlight page and make search links open the comic's source url --- pages/comic/[comic]/highlight/[page].tsx | 76 ------------------------ pages/comic/[comic]/search.tsx | 16 +---- 2 files changed, 1 insertion(+), 91 deletions(-) delete mode 100644 pages/comic/[comic]/highlight/[page].tsx diff --git a/pages/comic/[comic]/highlight/[page].tsx b/pages/comic/[comic]/highlight/[page].tsx deleted file mode 100644 index afbd390..0000000 --- a/pages/comic/[comic]/highlight/[page].tsx +++ /dev/null @@ -1,76 +0,0 @@ -import { Comic, ComicBubble, ComicPage } from '@prisma/client'; -import { GetServerSideProps } from 'next'; -import Head from 'next/head'; -import { ParsedUrlQuery } from 'querystring'; -import HighlightComic from '../../../../components/HighlightComic'; -import { prisma } from '../../../../src/db'; - -interface Params extends ParsedUrlQuery { - comic: string; - page: string; -} - -interface Props { - page: ComicPage & { - bubbles: ComicBubble[]; - comic: Comic; - }; - highlightedBubbles: number[] | null; -} - -export default function Search(props: Props) { - return ( -
- - - {props.page.title} - {props.page.comic.title} - - - -
- ); -} - -export const getServerSideProps: GetServerSideProps = async ({ - params, - query, -}) => { - const { comic: comicId, page: id } = params!; - const pageId = parseInt(id); - if (isNaN(pageId)) return { notFound: true }; - - const page = await prisma?.comicPage.findFirst({ - where: { - comic: { - slug: comicId, - }, - id: pageId, - }, - include: { - bubbles: true, - comic: true, - }, - }); - - if (!page) return { notFound: true }; - - const highlightedBubbles = ( - Array.isArray(query.highlightedBubbles) - ? query.highlightedBubbles - : query.highlightedBubbles - ? [query.highlightedBubbles] - : undefined - ) - ?.map((bubble) => parseInt(bubble)) - ?.filter((bubble) => !isNaN(bubble)); - - return { - props: { - page, - highlightedBubbles: highlightedBubbles ?? null, - }, - }; -}; diff --git a/pages/comic/[comic]/search.tsx b/pages/comic/[comic]/search.tsx index 7c93f80..5a34ef6 100644 --- a/pages/comic/[comic]/search.tsx +++ b/pages/comic/[comic]/search.tsx @@ -101,21 +101,7 @@ export default function Search(props: Props) {

{ e.preventDefault();