nomadro/app/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

31 lines
833 B
TypeScript

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}`);
}