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>
32 lines
930 B
TypeScript
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}`);
|
|
}
|