import type { Metadata } from "next"; import { notFound, redirect } from "next/navigation"; import { loadContent } from "@/site/load"; import { churchLd, pageMetadata } from "@/site/meta"; import { PageView } from "@/site/PageView"; import { Shell } from "@/site/Shell"; type Props = { params: Promise<{ slug: string }> }; async function find(slug: string) { const c = await loadContent(); if (c.mode !== "published") return { c, page: null }; return { c, page: c.snapshot.pages.find((p) => p.kind !== "home" && p.slug === slug) ?? null }; } export async function generateMetadata({ params }: Props): Promise { const { c, page } = await find((await params).slug); return c.mode === "published" && page ? pageMetadata(c, page) : { robots: { index: false } }; } export default async function SitePage({ params }: Props) { const { slug } = await params; const { c, page } = await find(slug); // Before the first publish every address shows Coming soon, on the home page. if (c.mode !== "published") redirect("/"); if (!page) notFound(); const ld = page.kind === "contact" ? churchLd(c, page.path) : null; return ( {ld &&