import { notFound, redirect } from 'next/navigation'; import { getChapter, getChapterSlugs } from '@ebook/lib/book.server'; import { buildChapterMetadata } from '@ebook/lib/metadata'; import { getLocale } from '@ebook/lib/i18n/server'; export function generateStaticParams() { return getChapterSlugs().map((slug) => ({ slug })); } export async function generateMetadata({ params, }: { params: Promise<{ slug: string }>; }) { const { slug } = await params; const locale = await getLocale(); return buildChapterMetadata(slug, locale); } export default async function ReadSlugRedirect({ params, }: { params: Promise<{ slug: string }>; }) { const { slug } = await params; const locale = await getLocale(); const chapter = getChapter(slug, locale); if (!chapter) notFound(); redirect(`/book/read#${slug}`); }