feat(website): the four templates and the public site
Heritage, Bold, Community and Clean drawing all 26 section variants with their headers, homepage order and style settings; colours made safe (WCAG AA) by the backend; fonts and corners from the shared brand style. Publishing into numbered versions, the content API with live messages and events and the church profile from Accounts, uploads, every page kind, simple event pages, Coming soon, 404, sitemap, SEO basics and the church's JSON-LD. The demo church (npm run demo) and Playwright e2e: every template's pages pass axe and the SEO checks. website.sh builds packages/seo. Decision 17 (first Owner) recorded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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<Metadata> {
|
||||
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 (
|
||||
<Shell site={c} path={page.path}>
|
||||
{ld && <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: ld }} />}
|
||||
<PageView page={page} site={c} />
|
||||
</Shell>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { Metadata } from "next";
|
||||
import { notFound } from "next/navigation";
|
||||
import { loadPublished } from "@/site/load";
|
||||
import { fmtDate, fmtTime, Img } from "@/site/parts";
|
||||
import { siteBase } from "@/site/meta";
|
||||
import { Shell } from "@/site/Shell";
|
||||
|
||||
type Props = { params: Promise<{ slug: string }> };
|
||||
|
||||
async function find(slug: string) {
|
||||
const site = await loadPublished();
|
||||
const event = site?.events.find((e) => e.from === "website" && e.url === `/events/${slug}`) ?? null;
|
||||
return { site, event };
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
const { site, event } = await find((await params).slug);
|
||||
if (!site || !event) return { robots: { index: false } };
|
||||
return { metadataBase: siteBase(site), title: event.title, description: event.summary ?? undefined, alternates: { canonical: event.url } };
|
||||
}
|
||||
|
||||
/** A simple event made in the Website (§8). Cross Events' own events link to Cross Events instead. */
|
||||
export default async function EventPage({ params }: Props) {
|
||||
const { site, event } = await find((await params).slug);
|
||||
if (!site || !event) notFound();
|
||||
const zone = site.church?.timezone ?? "Africa/Johannesburg";
|
||||
const events = site.snapshot.pages.find((p) => p.kind === "events");
|
||||
return (
|
||||
<Shell site={site} path={event.url}>
|
||||
<article className="cc-section">
|
||||
<div className="cc-wrap grid gap-10 md:grid-cols-2">
|
||||
<Img image={event.image} priority />
|
||||
<div>
|
||||
<p className="cc-eyebrow">{fmtDate(event.startsAt, zone, { weekday: "long", day: "numeric", month: "long", year: "numeric" })}{!event.allDay && `, ${fmtTime(event.startsAt, zone)}`}</p>
|
||||
<h1 className="cc-h1 mt-2">{event.title}</h1>
|
||||
{event.location && <p className="cc-muted mt-3 text-lg">{event.location}</p>}
|
||||
{event.summary && <p className="cc-prose mt-6">{event.summary}</p>}
|
||||
{events && <a href={events.path} className="cc-link mt-8 inline-block font-semibold">All events</a>}
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</Shell>
|
||||
);
|
||||
}
|
||||
@@ -2,15 +2,44 @@
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
/* Defaults until the church profile's colour is set (layout.tsx overrides them per request). */
|
||||
/*
|
||||
* The four templates (WEBSITE-1.0-PLAN §3). The layout sets, on <html>:
|
||||
* data-template heritage | bold | community | clean
|
||||
* data-spacing airy | compact (style setting)
|
||||
* data-buttons solid | outline | pill (style setting)
|
||||
* data-images natural | mono | duotone
|
||||
* data-section-colour light | tinted | mixed
|
||||
* data-cc-fonts / data-cc-corners (the church's shared brand style, @crosscode/ui)
|
||||
* and the colours as CSS variables (--brand, --on-brand, --brand-text, --brand-tint, --accent, …).
|
||||
* Section components use the cc-* classes below; each template restyles them.
|
||||
*/
|
||||
|
||||
:root {
|
||||
--brand: 31 78 121;
|
||||
--brand-dark: 21 55 85;
|
||||
--brand-dark: 25 62 97;
|
||||
--on-brand: 255 255 255;
|
||||
--brand-text: 31 78 121;
|
||||
--brand-tint: 241 244 248;
|
||||
--accent: 87 113 148;
|
||||
--on-accent: 255 255 255;
|
||||
--cc-section-y: 5rem;
|
||||
--cc-wrap: 72rem;
|
||||
--cc-text: 42rem;
|
||||
}
|
||||
|
||||
[data-spacing="compact"] { --cc-section-y: 3rem; }
|
||||
@media (max-width: 640px) {
|
||||
:root { --cc-section-y: 3.5rem; }
|
||||
[data-spacing="compact"] { --cc-section-y: 2.25rem; }
|
||||
}
|
||||
|
||||
[data-template="heritage"] { --cc-wrap: 60rem; --cc-text: 40rem; }
|
||||
[data-template="bold"] { --cc-wrap: 80rem; --cc-text: 46rem; }
|
||||
[data-template="community"] { --cc-wrap: 72rem; --cc-text: 42rem; }
|
||||
[data-template="clean"] { --cc-wrap: 48rem; --cc-text: 40rem; }
|
||||
|
||||
body {
|
||||
@apply bg-white text-gray-900 antialiased;
|
||||
/* The church's font pairing (@crosscode/ui fonts.css); the template's default until it picks one. */
|
||||
font-family: var(--cc-font-body, ui-sans-serif, system-ui, sans-serif);
|
||||
}
|
||||
|
||||
@@ -18,3 +47,89 @@ h1, h2, h3 {
|
||||
font-family: var(--cc-font-heading, inherit);
|
||||
font-variation-settings: var(--cc-heading-variation, normal);
|
||||
}
|
||||
|
||||
@layer components {
|
||||
.cc-wrap { @apply mx-auto w-full px-4 sm:px-6; max-width: var(--cc-wrap); }
|
||||
.cc-text { @apply mx-auto w-full; max-width: var(--cc-text); }
|
||||
|
||||
.cc-section { padding-block: var(--cc-section-y); }
|
||||
/* Heritage: thin rules between sections, in one centred column. */
|
||||
[data-template="heritage"] .cc-section + .cc-section { border-top: 1px solid rgb(var(--brand-text) / 0.18); }
|
||||
/*
|
||||
* Section colour: tinted alternates the church colour as a soft background; mixed adds dark bands.
|
||||
* Never on a section that sets its own background (cc-own-bg: a banner, a photo, a dark band).
|
||||
*/
|
||||
[data-section-colour="tinted"] .cc-section:not(.cc-own-bg):nth-of-type(even) { background: rgb(var(--brand-tint)); }
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) { background: rgb(var(--brand-dark)); color: rgb(var(--on-brand)); }
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-card { background: rgb(255 255 255 / 0.06); border-color: rgb(255 255 255 / 0.2); color: inherit; }
|
||||
|
||||
/* Text on a dark background (Bold's cards and bands, a dark section): light, and still AA. */
|
||||
.cc-dark .cc-muted, [data-template="bold"] .cc-card .cc-muted,
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-muted { color: rgb(255 255 255 / 0.8); }
|
||||
.cc-dark .cc-link, .cc-dark .cc-eyebrow, [data-template="bold"] .cc-card .cc-link, [data-template="bold"] .cc-card .cc-eyebrow,
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-link,
|
||||
[data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-eyebrow { color: rgb(255 255 255); }
|
||||
|
||||
.cc-muted { color: rgb(75 85 99); }
|
||||
.cc-link { color: rgb(var(--brand-text)); @apply underline-offset-4 hover:underline; }
|
||||
.cc-eyebrow { @apply text-sm font-semibold uppercase tracking-widest; color: rgb(var(--brand-text)); }
|
||||
[data-template="heritage"] .cc-eyebrow { @apply font-normal tracking-[0.25em]; font-variant: small-caps; text-transform: none; }
|
||||
[data-template="community"] .cc-eyebrow { @apply normal-case tracking-normal; }
|
||||
|
||||
/* Headings: each template's voice. */
|
||||
.cc-h1 { @apply text-4xl leading-tight sm:text-5xl; }
|
||||
.cc-h2 { @apply text-3xl leading-tight sm:text-4xl; }
|
||||
.cc-h3 { @apply text-xl leading-snug; }
|
||||
[data-template="heritage"] .cc-h1, [data-template="heritage"] .cc-h2 { @apply font-normal tracking-wide; }
|
||||
[data-template="heritage"] .cc-h3 { @apply font-normal; }
|
||||
[data-template="bold"] .cc-h1 { @apply text-5xl font-bold uppercase leading-[0.95] sm:text-7xl; letter-spacing: -0.01em; }
|
||||
[data-template="bold"] .cc-h2 { @apply text-4xl font-bold uppercase leading-none sm:text-5xl; }
|
||||
[data-template="bold"] .cc-h3 { @apply font-bold uppercase; }
|
||||
[data-template="community"] .cc-h1, [data-template="community"] .cc-h2 { @apply font-extrabold; }
|
||||
[data-template="community"] .cc-h3 { @apply font-bold; }
|
||||
[data-template="clean"] .cc-h1 { @apply font-semibold sm:text-6xl; letter-spacing: -0.03em; }
|
||||
[data-template="clean"] .cc-h2 { @apply text-2xl font-semibold sm:text-3xl; letter-spacing: -0.02em; }
|
||||
[data-template="clean"] .cc-h3 { @apply font-semibold; }
|
||||
|
||||
/* Buttons: solid, outline or pill (style setting); corners from the church's brand style. */
|
||||
.cc-btn {
|
||||
@apply inline-flex items-center justify-center gap-2 px-6 py-3 text-base font-semibold no-underline transition-colors;
|
||||
border-radius: var(--cc-radius-button, 0.5rem);
|
||||
background: rgb(var(--brand)); color: rgb(var(--on-brand)); border: 2px solid rgb(var(--brand));
|
||||
}
|
||||
.cc-btn:hover { background: rgb(var(--brand-dark)); border-color: rgb(var(--brand-dark)); }
|
||||
.cc-btn:focus-visible { outline: 3px solid rgb(var(--accent)); outline-offset: 2px; }
|
||||
[data-buttons="outline"] .cc-btn { background: transparent; color: rgb(var(--brand-text)); border-color: currentColor; }
|
||||
[data-buttons="outline"] .cc-btn:hover { background: rgb(var(--brand)); color: rgb(var(--on-brand)); border-color: rgb(var(--brand)); }
|
||||
[data-buttons="pill"] .cc-btn { border-radius: 9999px; }
|
||||
[data-template="bold"] .cc-btn { @apply uppercase tracking-wider; }
|
||||
/* A button on a photo or a dark band: always light on dark. */
|
||||
.cc-on-dark .cc-btn, .cc-dark .cc-btn, [data-section-colour="mixed"] .cc-section:not(.cc-own-bg):nth-of-type(3n) .cc-btn {
|
||||
background: rgb(255 255 255); color: rgb(17 24 39); border-color: rgb(255 255 255);
|
||||
}
|
||||
|
||||
/* Cards. */
|
||||
.cc-card { @apply overflow-hidden bg-white; border-radius: var(--cc-radius, 0.5rem); }
|
||||
[data-template="heritage"] .cc-card { border: 1px solid rgb(var(--brand-text) / 0.2); }
|
||||
[data-template="bold"] .cc-card { @apply bg-gray-900 text-white; }
|
||||
[data-template="community"] .cc-card { @apply shadow-md; box-shadow: 0 10px 30px -12px rgb(var(--brand) / 0.35); }
|
||||
[data-template="clean"] .cc-card { border-bottom: 1px solid rgb(229 231 235); border-radius: 0; }
|
||||
|
||||
/* Images: natural, black and white, or duotone in the church colour (style setting). */
|
||||
.cc-img { @apply block h-full w-full object-cover; border-radius: var(--cc-radius-sm, 0); }
|
||||
.cc-frame { @apply relative overflow-hidden; border-radius: var(--cc-radius, 0); }
|
||||
[data-images="mono"] .cc-img { filter: grayscale(1) contrast(1.05); }
|
||||
[data-images="duotone"] .cc-img { filter: grayscale(1) contrast(1.1); mix-blend-mode: multiply; }
|
||||
[data-images="duotone"] .cc-frame { background: rgb(var(--brand)); }
|
||||
/* Heritage frames its images. */
|
||||
[data-template="heritage"] .cc-frame { padding: 0.5rem; background: white; border: 1px solid rgb(var(--brand-text) / 0.25); }
|
||||
[data-template="heritage"][data-images="duotone"] .cc-frame { background: rgb(var(--brand)); }
|
||||
|
||||
/* Prose for text the admins write (paragraphs only; no HTML is ever rendered). */
|
||||
.cc-prose p + p { margin-top: 1em; }
|
||||
.cc-prose { @apply text-lg leading-relaxed; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.cc-motion { display: none !important; }
|
||||
}
|
||||
|
||||
@@ -2,16 +2,37 @@ import type { Metadata } from "next";
|
||||
import "@crosscode/ui/fonts.css";
|
||||
import "./globals.css";
|
||||
import { brandAttributes } from "@crosscode/ui";
|
||||
import { loadContent } from "@/site/load";
|
||||
|
||||
// The church's name, colours, fonts and corners come from its profile in Accounts once the Website
|
||||
// is linked (docs/WEBSITE-1.0-PLAN.md §2); until then, plain defaults.
|
||||
export const metadata: Metadata = {
|
||||
title: { default: "Church Website", template: "%s" },
|
||||
};
|
||||
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 };
|
||||
}
|
||||
|
||||
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export default async function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
const c = await loadContent();
|
||||
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}}`;
|
||||
return (
|
||||
<html lang="en-ZA" {...brandAttributes(null)}>
|
||||
<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>{children}</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import Link from "next/link";
|
||||
import { loadPublished } from "@/site/load";
|
||||
import { Shell } from "@/site/Shell";
|
||||
|
||||
export default async function NotFound() {
|
||||
const site = await loadPublished();
|
||||
const body = (
|
||||
<section className="cc-section">
|
||||
<div className="cc-wrap text-center">
|
||||
<h1 className="cc-h1">Page not found</h1>
|
||||
<p className="cc-muted mt-4 text-lg">That page isn't here. It may have moved.</p>
|
||||
<Link href="/" className="cc-btn mt-8">Go to the home page</Link>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
return site ? <Shell site={site} path="/404">{body}</Shell> : <main>{body}</main>;
|
||||
}
|
||||
@@ -1,31 +1,33 @@
|
||||
import type { Metadata } from "next";
|
||||
import { loadStatus } from "@/lib/site";
|
||||
|
||||
// Rendered per request from the backend's status; the published site is cached once it exists (§1).
|
||||
export const dynamic = "force-dynamic";
|
||||
import { cookies } from "next/headers";
|
||||
import { ComingSoon } from "@/site/ComingSoon";
|
||||
import { loadContent } from "@/site/load";
|
||||
import { churchLd, pageMetadata } from "@/site/meta";
|
||||
import { Sections } from "@/site/sections";
|
||||
import { Shell } from "@/site/Shell";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const status = await loadStatus();
|
||||
// Coming soon is a real page (HTTP 200) but never indexed (§5, decision 14).
|
||||
return status.mode === "coming-soon" ? { title: "Coming soon", robots: { index: false, follow: true } } : { title: "Home" };
|
||||
const c = await loadContent();
|
||||
if (c.mode === "coming-soon") {
|
||||
// A real page (HTTP 200) that's never indexed (§5, decision 14).
|
||||
return { title: { absolute: c.church ? `${c.church.name}: coming soon` : "Coming soon" }, robots: { index: false, follow: true } };
|
||||
}
|
||||
const home = c.snapshot.pages.find((p) => p.kind === "home");
|
||||
return home ? pageMetadata(c, home) : {};
|
||||
}
|
||||
|
||||
export default async function Home() {
|
||||
const status = await loadStatus();
|
||||
if (status.mode === "coming-soon") {
|
||||
// The full Coming soon page (logo, service times, contact, links to Events) comes with the
|
||||
// church profile (§5).
|
||||
return (
|
||||
<main className="mx-auto flex min-h-screen max-w-xl flex-col items-center justify-center gap-4 px-4 text-center">
|
||||
<h1 className="text-3xl font-semibold text-brand">Coming soon</h1>
|
||||
<p className="text-gray-600">Our new website is on its way.</p>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
const c = await loadContent();
|
||||
if (c.mode === "coming-soon") return <ComingSoon c={c} signedInAdmin={(await cookies()).has("ccw_session")} />;
|
||||
const home = c.snapshot.pages.find((p) => p.kind === "home");
|
||||
const sections = home?.sections ?? [];
|
||||
const ld = churchLd(c, "/");
|
||||
return (
|
||||
<main className="mx-auto max-w-3xl px-4 py-16">
|
||||
<h1 className="text-3xl font-semibold">Welcome</h1>
|
||||
<p className="mt-2 text-gray-600">Published version {status.version}. The templates come next (§3).</p>
|
||||
</main>
|
||||
<Shell site={c} path="/">
|
||||
{ld && <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: ld }} />}
|
||||
{/* Exactly one <h1> (§11): the hero's, else the church's name. */}
|
||||
{sections[0]?.type !== "hero" && <h1 className="sr-only">{c.church?.name ?? "Home"}</h1>}
|
||||
<Sections site={c} sections={sections} />
|
||||
</Shell>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { MetadataRoute } from "next";
|
||||
import { loadContent } from "@/site/load";
|
||||
import { siteBase } from "@/site/meta";
|
||||
|
||||
/**
|
||||
* The published pages and the Website's own events (ROADMAP-v3 §11). Events copied from Cross
|
||||
* Events aren't listed: their canonical page is at the origin. Before the first publish: empty.
|
||||
*/
|
||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
const c = await loadContent();
|
||||
if (c.mode !== "published") return [];
|
||||
const base = siteBase(c);
|
||||
if (!base) return [];
|
||||
const at = (path: string) => new URL(path, base).toString();
|
||||
return [
|
||||
...c.snapshot.pages.map((p) => ({ url: at(p.path), changeFrequency: "weekly" as const, priority: p.kind === "home" ? 1 : 0.7 })),
|
||||
...c.events.filter((e) => e.from === "website" && e.url.startsWith("/")).map((e) => ({ url: at(e.url), changeFrequency: "weekly" as const, priority: 0.5 })),
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user