Admin API and screens: dashboard and setup checklist, template and style, pages and blocks, ministries, leadership, media library with the storage limit, publish and history. Pending changes with who and when, discard one, one Publish, restore any version (each version keeps the working copy's rows, never sent to visitors). Preview on the site's own addresses with a bar (widths, back, publish); shared preview links for 7 days or until revoked. Roles checked, same-origin changes only. Publish refreshes the public pages at once (WEBSITE_CONTENT_CACHE_SECONDS). E2E on a production build: the admin's flows and axe on every screen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
2.1 KiB
TypeScript
53 lines
2.1 KiB
TypeScript
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<Metadata> {
|
|
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 (
|
|
<html
|
|
lang="en-ZA"
|
|
{...brandAttributes(c.style)}
|
|
data-template={template}
|
|
data-spacing={s?.spacing ?? "airy"}
|
|
data-buttons={s?.buttons ?? "solid"}
|
|
data-images={s?.images ?? "natural"}
|
|
data-section-colour={s?.sectionColour ?? "light"}
|
|
>
|
|
<head>
|
|
<style>{vars.replace(/[<>]/g, "")}</style>
|
|
</head>
|
|
<body>
|
|
{bar && <PreviewBar preview={bar} />}
|
|
{children}
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|