yiekheng 26b620de2f Add reading-progress resume + multi-genre support
Reading progress
- New ReadingProgressButton client component that reads/writes
  localStorage key "sunnymh:last-read:{slug}"
- PageReader writes the currently-visible chapter as the user scrolls
  through continuous chapters
- Manga detail CTA now reads: "开始阅读" on first visit, or
  "继续阅读 · #{N} {title}" when a prior chapter is stored (with
  spacing and truncation for long titles)

Multiple genres
- lib/genres.ts with parseGenres() and collectGenres() helpers to
  split "冒险, 恋爱, 魔幻" into a list and aggregate across a collection
- Manga detail renders one pill per genre
- GenreTabs filters via parseGenres(...).includes(activeGenre) so a
  multi-genre manga appears under each of its genres
- Home / Genre pages compute the tab list from collectGenres(signedManga)
- Card captions (GenreTabs + TrendingCarousel) show "冒险 · 恋爱 · 魔幻"
  with truncation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 10:27:28 +08:00

29 lines
766 B
TypeScript

import { prisma } from "@/lib/db";
import { signCoverUrls } from "@/lib/r2";
import { collectGenres } from "@/lib/genres";
import { GenreTabs } from "@/components/GenreTabs";
import type { Metadata } from "next";
export const dynamic = "force-dynamic";
export const metadata: Metadata = {
title: "Genres",
};
export default async function GenrePage() {
const manga = await prisma.manga.findMany({
where: { status: "PUBLISHED" },
orderBy: { title: "asc" },
include: { _count: { select: { chapters: true } } },
});
const signedManga = await signCoverUrls(manga);
const genres = collectGenres(signedManga);
return (
<div className="max-w-6xl mx-auto px-4 py-5">
<GenreTabs manga={signedManga} genres={genres} />
</div>
);
}