nomadro/app/community/book/read/[slug]/page.tsx
eric 9928c5185b Mount nav/book/community as native App Router routes in one Next process.
Replace reverse-proxy/iframe approach with @ebook/@community/@navmini imports under /nav /book /community so localhost:3000 serves all three products directly.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 03:49:16 -05:00

32 lines
930 B
TypeScript

import { notFound, redirect } from "next/navigation";
import { getChapter, getChapterSlugs } from "@community/lib/ebook/book.server";
import { buildChapterMetadata } from "@community/lib/ebook/metadata";
import { getLocale } from "@community/lib/ebook/i18n/server";
import { ebookPath } from "@community/lib/ebook/paths";
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(`${ebookPath("/read")}#${slug}`);
}