feat(website): the admin, with drafts, preview, publish and restore

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>
This commit is contained in:
2026-11-25 12:30:29 +02:00
co-authored by Claude Opus 5.5
parent 3caa1d1e1a
commit 84c5b0c08e
44 changed files with 2404 additions and 65 deletions
+15 -2
View File
@@ -1,25 +1,35 @@
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 };
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"
@@ -33,7 +43,10 @@ export default async function RootLayout({ children }: { children: React.ReactNo
<head>
<style>{vars.replace(/[<>]/g, "")}</style>
</head>
<body>{children}</body>
<body>
{bar && <PreviewBar preview={bar} />}
{children}
</body>
</html>
);
}