diff --git a/src/app/books/[bookId]/page.tsx b/src/app/books/[bookId]/page.tsx index e542e06..52a61e1 100644 --- a/src/app/books/[bookId]/page.tsx +++ b/src/app/books/[bookId]/page.tsx @@ -1,5 +1,5 @@ import { fetchBookById } from "@/lib/api"; -import { Book } from "@/lib/types"; +import { Book, Chapter } from "@/lib/types"; import { formatDateToMonthDayYear } from "@/lib/utils"; import ChapterDropdown from "@/components/ChapterDropdown"; import { Ad } from "@/lib/types"; @@ -26,8 +26,10 @@ export default async function BookPage(props: { params: paramsType }) { } const { title, author, description, chapters, cover } = book; + const sorted_chapters:Chapter[] = chapters.sort((a, b) => a.number - b.number); + const cover_media = cover?.at(0); - const recentChapters = chapters.length > 6 ? chapters.slice(chapters.length - 6, chapters.length) : chapters; + const recentChapters = sorted_chapters.length > 6 ? sorted_chapters.slice(sorted_chapters.length - 6, sorted_chapters.length) : sorted_chapters; return (