yiekheng 33087cc5b3 Make list pages fully dynamic; cache only at query level
Docker production build runs without DATABASE_URL, so any page Next
tries to prerender at build (force-static / revalidate without a
dynamic segment) fails on the Prisma call. Homepage, genre page, and
sitemap previously had page-level revalidate, forcing prerender. Add
force-dynamic to each and move the revalidation inside an
unstable_cache wrapper around the Prisma query — result still cached
5m / 1h at runtime, but build no longer touches the DB.

Detail page (/manga/[slug]) keeps page-level revalidate since its
dynamic segment without generateStaticParams was never prerendered at
build anyway.

Update CLAUDE.md caching section to reflect the new strategy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 20:56:26 +08:00

35 lines
838 B
TypeScript

import { unstable_cache } from "next/cache";
import { prisma } from "@/lib/db";
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",
};
const getGenreManga = unstable_cache(
async () =>
prisma.manga.findMany({
where: { status: "PUBLISHED" },
orderBy: { title: "asc" },
include: { _count: { select: { chapters: true } } },
}),
["genre-manga-list"],
{ revalidate: 300 }
);
export default async function GenrePage() {
const manga = await getGenreManga();
const genres = collectGenres(manga);
return (
<div className="max-w-6xl mx-auto px-4 py-5">
<GenreTabs manga={manga} genres={genres} />
</div>
);
}