import { notFound, redirect } from "next/navigation"; import { connection } from "next/server"; import { StructuredGuideShell } from "@/components/public/structured-guide"; import { getAdminSession } from "@/lib/auth/server"; import { publicGuideSections } from "@/lib/guides/public-sections"; import { getAdminGuideContent, getGuideEditorHeader } from "@/lib/guides/queries"; export const instant = false; export default async function GuidePreviewPage({ params, }: { params: Promise<{ character: string; page?: string[] }>; }) { await connection(); if (!(await getAdminSession())) redirect("/auth/login?next=%2Fadmin"); const { character, page } = await params; if (page && page.length > 1) notFound(); const header = await getGuideEditorHeader(character); if (!header) notFound(); const guide = await getAdminGuideContent(header.slug); if (!guide) notFound(); const section = page?.[0]; if (section && !publicGuideSections(guide).some((item) => item.slug === section)) notFound(); return ; }