38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { notFound } from "next/navigation";
|
|
|
|
import { GoogleAdsense } from "@/components/public/google-adsense";
|
|
import { publicSections, StructuredGuideShell } from "@/components/public/structured-guide";
|
|
import { getCachedPublicGuide } from "@/lib/cache/public";
|
|
import { siteUrl } from "@/lib/site-url";
|
|
|
|
type Params = Promise<{ character: string; page: string }>;
|
|
|
|
export const instant = false;
|
|
|
|
export async function generateMetadata({ params }: { params: Params }): Promise<Metadata> {
|
|
const { character, page } = await params;
|
|
const guide = await getCachedPublicGuide(character);
|
|
return guide
|
|
? {
|
|
title: `${guide.name}`,
|
|
description: guide.overview,
|
|
alternates: { canonical: `${siteUrl}/${encodeURIComponent(guide.slug)}/${encodeURIComponent(page)}` },
|
|
openGraph: { images: [guide.coverUrl] },
|
|
twitter: { images: [guide.coverUrl] },
|
|
}
|
|
: { title: "ไม่พบไกด์" };
|
|
}
|
|
|
|
export default async function GuideSectionPage({ params }: { params: Params }) {
|
|
const { character, page } = await params;
|
|
const guide = await getCachedPublicGuide(character);
|
|
if (!guide || !publicSections(guide).some((section) => section.slug === page)) notFound();
|
|
return (
|
|
<>
|
|
<GoogleAdsense />
|
|
<StructuredGuideShell guide={guide} section={page} />
|
|
</>
|
|
);
|
|
}
|