import type { Metadata } from "next"; import { notFound, permanentRedirect } from "next/navigation"; import { connection } from "next/server"; import { GuideShell } from "@/components/public/guide-shell"; import { loadPublicPage } from "@/lib/content/loaders"; type RouteParams = Promise<{ character: string; page: string }>; export async function generateMetadata({ params }: { params: RouteParams }): Promise { await connection(); const { character, page } = await params; const result = await loadPublicPage(character, page); if (result.type !== "page") return { title: "ไม่พบคู่มือ" }; return { title: `${result.snapshot.page.title} — ${result.snapshot.character.nameTh}`, description: result.snapshot.character.description ?? undefined, }; } export default async function GuidePage({ params }: { params: RouteParams }) { await connection(); const { character, page } = await params; const result = await loadPublicPage(character, page); if (result.type === "redirect") permanentRedirect(result.location); if (result.type === "not-found") notFound(); return ; }