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>
31 lines
833 B
TypeScript
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}`);
|
|
}
|