From c82089bb15dce8e1a302b0296b8166e7df9acb9a Mon Sep 17 00:00:00 2001 From: Hieuhuy Pham Date: Sun, 12 Jan 2025 23:58:23 -0500 Subject: [PATCH] metadata generation nightmare we gotta fix later --- .../[bookId]/chapters/[chapterId]/page.tsx | 27 +++++-------------- src/app/books/[bookId]/page.tsx | 13 ++++----- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/app/books/[bookId]/chapters/[chapterId]/page.tsx b/src/app/books/[bookId]/chapters/[chapterId]/page.tsx index 6dbaf62..a032e44 100644 --- a/src/app/books/[bookId]/chapters/[chapterId]/page.tsx +++ b/src/app/books/[bookId]/chapters/[chapterId]/page.tsx @@ -2,9 +2,13 @@ import React from "react"; import NavigationButtons from "@/components/NavigationButtons"; import { Book, Chapter } from "@/lib/types"; import { fetchBookById } from "@/lib/api"; -import Head from "next/head"; export type paramsType = Promise<{ bookId: string; chapterId: string }>; +export const metadata = { + title: 'Null Translation Group', + description: 'This is the chapter page default description', +}; + // Dynamic page component export default async function ChapterPage(props: { params: paramsType}) { const { bookId, chapterId } = await props.params; @@ -15,17 +19,12 @@ export default async function ChapterPage(props: { params: paramsType}) { } catch (error) { console.error(error); + return ( - <> - - Chapter not found - -

Chapter not found !

' }}>
- ) } @@ -37,31 +36,19 @@ export default async function ChapterPage(props: { params: paramsType}) { if(current_chapter === null){ return ( - <> - - Chapter not found - -

Chapter not found !

' }}>
- ) } - + return ( - <> - - {book.title} - Chapter {current_chapter?.number} - -
- ); } \ No newline at end of file diff --git a/src/app/books/[bookId]/page.tsx b/src/app/books/[bookId]/page.tsx index cef1702..e542e06 100644 --- a/src/app/books/[bookId]/page.tsx +++ b/src/app/books/[bookId]/page.tsx @@ -3,14 +3,16 @@ import { Book } from "@/lib/types"; import { formatDateToMonthDayYear } from "@/lib/utils"; import ChapterDropdown from "@/components/ChapterDropdown"; import { Ad } from "@/lib/types"; -import Head from "next/head"; export type paramsType = Promise<{ bookId: string}>; +export const metadata = { + title: 'Null Translation Group', + description: 'Null Translatin Group book', +}; export default async function BookPage(props: { params: paramsType }) { const { bookId } = await props.params; - let book: Book; try { book = await fetchBookById(bookId); @@ -26,12 +28,8 @@ export default async function BookPage(props: { params: paramsType }) { const { title, author, description, chapters, cover } = book; const cover_media = cover?.at(0); const recentChapters = chapters.length > 6 ? chapters.slice(chapters.length - 6, chapters.length) : chapters; + return ( - <> - - {title} - -
))}
- ); }