import { fetchBookById } from "@/lib/api"; import { Book, Chapter } from "@/lib/types"; import { formatDateToMonthDayYear, markdownToHtml } from "@/lib/utils"; import ChapterDropdown from "@/components/ChapterDropdown"; import { Ad } from "@/lib/types"; export type paramsType = Promise<{ bookId: string}>; export const metadata = { title: 'Null Translation Group', description: 'Null Translation Group book description page', }; export default async function BookPage(props: { params: paramsType }) { const { bookId } = await props.params; let book: Book; try { book = await fetchBookById(bookId); } catch (error) { console.error(error); return (
Book does not exists, are you lost?
); } const {title, author, description, chapters, cover, translator_note, glossary} = book; const english_glossary = glossary?.english_english; const translator_note_html = await markdownToHtml(translator_note); const sorted_chapters:Chapter[] = chapters.sort((a, b) => a.number - b.number); const cover_media = cover?.at(0); const recentChapters = sorted_chapters.length > 6 ? sorted_chapters.slice(sorted_chapters.length - 6, sorted_chapters.length) : sorted_chapters; return (
{cover_media?.alternativeText

{title}

Join Our Patreon to read ahead!

Author: {author}

Translator: Null Translation Group

Description: {description}

Recent Chapters

All Chapters

{sorted_chapters.map((chapter) => (
  • Chapter {chapter.number}: {chapter.title}

    Release Date: {formatDateToMonthDayYear(new Date(chapter.release_datetime))}

  • ))} {glossary && (

    Glossary

      {Object.entries(english_glossary).map(([term, definition]) => (
    • {term}: {definition}
    • ))}
    )}
    ); }