feat(guides) : add safer publishing and discovery
This commit is contained in:
@@ -84,6 +84,9 @@ export default async function StructuredEditorPage({
|
||||
</h1>
|
||||
<EditorPresence guideId={guide.id} section={sectionTitle} />
|
||||
</div>
|
||||
<Button className="ml-auto" variant="outline" render={<Link href={`/admin/${guide.characterKey}/preview/${page}`} target="_blank" />} nativeButton={false}>
|
||||
Preview
|
||||
</Button>
|
||||
</header>
|
||||
<GuideSectionNav
|
||||
guideId={guide.id}
|
||||
|
||||
@@ -51,7 +51,10 @@ export default async function GuideOverviewPage({ params }: { params: Promise<{
|
||||
<h1 className="font-heading text-3xl font-semibold">{guide.name}</h1>
|
||||
<EditorPresence guideId={guide.id} section="Overview" />
|
||||
</div>
|
||||
<GuideVisibilityControl guideId={guide.id} guideName={guide.name} isPublic={guide.isPublic} />
|
||||
<GuideVisibilityControl guideId={guide.id} guideName={guide.name} isPublic={guide.isPublic} version={guide.version} />
|
||||
<Button variant="outline" render={<Link href={`/admin/${guide.characterKey}/preview`} target="_blank" />} nativeButton={false}>
|
||||
Preview
|
||||
</Button>
|
||||
</header>
|
||||
<GuideSectionNav guideId={guide.id} characterKey={guide.characterKey} current="overview" extras={extras} />
|
||||
<GuideOverviewForm key={guide.version} guide={guide} />
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
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("/admin/login");
|
||||
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 <StructuredGuideShell guide={guide} section={section} preview />;
|
||||
}
|
||||
Reference in New Issue
Block a user