import type { Metadata } from "next"; import { notFound } from "next/navigation"; import messages from "../../../../messages/en/index"; import { getPublicPublishedRuleById } from "../../../../lib/server/publishedRules"; import { parsePublishedDocumentForCommunityRuleDisplay } from "../../../../lib/create/publishedDocumentToDisplaySections"; import CommunityRule from "../../../components/type/CommunityRule"; import HeaderLockup from "../../../components/type/HeaderLockup"; interface PageProps { params: Promise<{ id: string }>; } export async function generateMetadata({ params, }: PageProps): Promise { const { id } = await params; const rule = await getPublicPublishedRuleById(id); if (!rule) { return { title: messages.pages.ruleDetail.notFoundTitle, description: "The requested CommunityRule could not be found.", }; } const description = typeof rule.summary === "string" && rule.summary.trim().length > 0 ? rule.summary : undefined; return { title: rule.title, description, openGraph: { title: rule.title, description, type: "article", url: `https://communityrule.com/rules/${rule.id}`, siteName: "CommunityRule", }, twitter: { card: "summary_large_image", title: rule.title, description, }, }; } export default async function PublicRuleDetailPage({ params }: PageProps) { const { id } = await params; const rule = await getPublicPublishedRuleById(id); if (!rule) { notFound(); } const sections = parsePublishedDocumentForCommunityRuleDisplay(rule.document); const description = typeof rule.summary === "string" && rule.summary.trim().length > 0 ? rule.summary : undefined; return (
); }