import type { Metadata } from "next"; import { headers } from "next/headers"; import "@crosscode/ui/fonts.css"; import "./globals.css"; import { brandAttributes } from "@crosscode/ui"; import { loadContent } from "@/site/load"; import { PreviewBar } from "@/site/PreviewBar"; export async function generateMetadata(): Promise { const c = await loadContent(); const name = c.church?.name ?? "Church Website"; return { title: { default: name, template: `%s · ${name}` }, icons: c.church?.branding.iconUrl ? { icon: c.church.branding.iconUrl } : undefined, // A preview is never indexed (§4). ...(c.mode === "published" && c.preview ? { robots: { index: false, follow: false } } : {}), }; } /** * Every page: the church's fonts and corners (shared brand style), the template and the style * settings as attributes (globals.css), and its colours, made safe by the backend, as variables. * While previewing, the site's pages get the preview bar above them. */ export default async function RootLayout({ children }: { children: React.ReactNode }) { const c = await loadContent(); const path = (await headers()).get("x-ccw-path") ?? "/"; const p = c.palette; const template = c.mode === "published" ? c.snapshot.design.template : c.template; const s = c.mode === "published" ? c.snapshot.design.style : null; const vars = `:root{--brand:${p.brand};--brand-dark:${p.brandDark};--on-brand:${p.onBrand};--brand-text:${p.brandText};--brand-tint:${p.brandTint};--accent:${p.accent};--on-accent:${p.onAccent}}`; const bar = c.mode === "published" && c.preview && !path.startsWith("/admin") && !path.startsWith("/preview") ? c.preview : null; return ( {bar && } {children} ); }