Events 2.4.0 frontend, deploy and docs: Linked products, linked events, seo

- Site settings → Linked products (Connect, Show events from, Publish my
  events), help, command palette.
- Events from linked products on /events, the home and campus pages, and
  /events/linked/<product>/<id> (markdown with HTML off, canonical to the
  origin, no JSON-LD, not in the sitemap).
- Event page JSON-LD from @crosscode/seo; lib/eventSchema.ts removed.
- Readiness check for linked products' sync; e2e spec with a fake
  Church Website (not run yet: needs the e2e Postgres).
- crosscode: install and build the shared packages Events uses first
  (an older tag still builds as before); scripts/tests/events.bats.
- Release notes, changelogs, handovers, hub-protocol.md, and the plan's
  "Changes while building".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 12:58:50 +02:00
co-authored by Claude Opus 5.5
parent 8a930d07c6
commit 716d47242a
28 changed files with 929 additions and 130 deletions
@@ -4,6 +4,8 @@ import { notFound } from "next/navigation";
import { Navbar } from "@/components/layout/Navbar";
import { Footer } from "@/components/layout/Footer";
import { EventCard } from "@/components/events/EventCard";
import { LinkedEventCard } from "@/components/events/LinkedEventCard";
import { fetchLinkedEvents, mergeByStart } from "@/lib/linkedEvents";
import { ApiImage } from "@/components/shared/ApiImage";
import { apiFetchListForPrerender, ApiError } from "@/lib/api";
import { mapsSearchUrl } from "@/lib/maps";
@@ -42,13 +44,17 @@ export default async function CampusPage({ params }: { params: Promise<{ slug: s
const campus = await loadCampus(slug);
if (!campus) notFound();
const events = await apiFetchListForPrerender<Event>(`/api/v2/event-listing?campus=${encodeURIComponent(campus.slug)}`, { nextOptions: { next: { revalidate } } });
const [events, linked] = await Promise.all([
apiFetchListForPrerender<Event>(`/api/v2/event-listing?campus=${encodeURIComponent(campus.slug)}`, { nextOptions: { next: { revalidate } } }),
fetchLinkedEvents(campus.slug),
]);
// A server component renders once per request (or revalidation): this is that render's time.
// eslint-disable-next-line react-hooks/purity
const now = Date.now();
const upcoming = (events || [])
.filter(e => e.cashupStatus !== "closed" && new Date(e.endDate || e.startDate).getTime() > now)
.sort((a, b) => new Date(a.nextSession?.startsAt || a.startDate).getTime() - new Date(b.nextSession?.startsAt || b.startDate).getTime());
const items = mergeByStart(upcoming, linked, e => e.nextSession?.startsAt || e.startDate);
return (
<div className="min-h-screen flex flex-col">
@@ -79,14 +85,16 @@ export default async function CampusPage({ params }: { params: Promise<{ slug: s
<h2 className="text-xl font-semibold text-gray-900 mb-1">Upcoming events</h2>
<p className="text-sm text-gray-500 mb-6">Events at {campus.name}, and church-wide events for every campus.</p>
{upcoming.length === 0 ? (
{items.length === 0 ? (
<div className="text-center py-16 border rounded-xl bg-gray-50">
<CalendarX className="w-8 h-8 text-gray-300 mx-auto mb-2" />
<p className="text-gray-500 text-sm">No upcoming events at {campus.name} right now — check back soon.</p>
</div>
) : (
<div className="grid gap-6 md:grid-cols-3 sm:grid-cols-2">
{upcoming.map(event => <EventCard key={event.id} event={event} />)}
{items.map(item => item.kind === "own"
? <EventCard key={item.event.id} event={item.event} />
: <LinkedEventCard key={item.event.key} item={item.event} />)}
</div>
)}
</main>
@@ -8,7 +8,7 @@ import { ApiError, resolveToApiOrigin } from "@/lib/api";
import { apiV2Raw, apiV2Data } from "@/lib/apiV2";
import { useSiteSettings } from "@/contexts/SiteSettingsContext";
import { useDismissingState } from "@/hooks/useDismissingState";
import { Building2, Palette, Bell, Mail, Scale, MessageCircle, CreditCard, DatabaseBackup, Timer, KeyRound, MapPinned, type LucideIcon, Webhook, Sparkles } from "lucide-react";
import { Building2, Palette, Bell, Mail, Scale, MessageCircle, CreditCard, DatabaseBackup, Timer, KeyRound, MapPinned, type LucideIcon, Webhook, Sparkles, Link2 } from "lucide-react";
import { ColorPickerField } from "@/components/admin/ColorPickerField";
import { BrandingPreviewPanel } from "@/components/admin/BrandingPreviewPanel";
import { BackupsTab } from "@/components/admin/BackupsTab";
@@ -17,6 +17,7 @@ import { PaymentsTab } from "@/components/admin/PaymentsTab";
import { LicenceTab } from "@/components/admin/LicenceTab";
import { WebhooksTab } from "@/components/admin/WebhooksTab";
import { AiTab } from "@/components/admin/AiTab";
import { LinkedProductsTab } from "@/components/admin/LinkedProductsTab";
import { CampusesTab } from "@/components/admin/CampusesTab";
import { extractDominantColors } from "@/lib/extractColors";
import { mapsSearchUrl } from "@/lib/maps";
@@ -25,7 +26,7 @@ import { BackLink } from "@/components/shared/BackLink";
import { uploadImage } from "@/lib/eventSetup";
import { useExternalEffect } from "@/lib/hooks";
type TabId = "organisation" | "campuses" | "branding" | "notifications" | "email" | "legal" | "whatsapp" | "payments" | "webhooks" | "backups" | "jobs" | "licence" | "ai";
type TabId = "organisation" | "campuses" | "branding" | "notifications" | "email" | "legal" | "whatsapp" | "payments" | "webhooks" | "linked" | "backups" | "jobs" | "licence" | "ai";
const TABS: { id: TabId; label: string; icon: LucideIcon }[] = [
{ id: "organisation", label: "Organisation", icon: Building2 },
@@ -37,6 +38,7 @@ const TABS: { id: TabId; label: string; icon: LucideIcon }[] = [
{ id: "whatsapp", label: "WhatsApp", icon: MessageCircle },
{ id: "payments", label: "Payments", icon: CreditCard },
{ id: "webhooks", label: "Webhooks", icon: Webhook },
{ id: "linked", label: "Linked products", icon: Link2 },
{ id: "backups", label: "Backups", icon: DatabaseBackup },
{ id: "jobs", label: "Background jobs", icon: Timer },
{ id: "licence", label: "Licence", icon: KeyRound },
@@ -718,6 +720,7 @@ function SiteSettingsPageInner() {
{/* ── Backups ───────────────────────────────────────────────────────── */}
{activeTab === "backups" && <BackupsTab active={activeTab === "backups"} />}
{activeTab === "webhooks" && <WebhooksTab active={activeTab === "webhooks"} />}
{activeTab === "linked" && <LinkedProductsTab active={activeTab === "linked"} />}
{activeTab === "jobs" && <JobsTab active={activeTab === "jobs"} />}
{activeTab === "licence" && <LicenceTab active={activeTab === "licence"} />}
{activeTab === "ai" && <AiTab active={activeTab === "ai"} />}
@@ -54,6 +54,9 @@ type Event = {
attendanceMode?: "whole" | "pick";
sessions?: EventSession[];
registrationClosesAt?: string;
// 2.4.0: the event as crosscode.event/1, what its schema.org JSON-LD is built from (@crosscode/seo).
crosscodeEvent?: CrosscodeEvent | null;
priceRangeCents?: { lowCents: number; highCents: number } | null;
lateJoin?: LateJoinInfo | null;
series?: EventSeriesRef | null;
nextInSeries?: NextInSeries | null;
@@ -69,7 +72,8 @@ import { isPickOption, latePrice, registrationClosesAt, scheduleSummary } from "
import { SessionSchedule } from "@/components/events/SessionSchedule";
import { appUrl, appName } from "@/lib/siteConfig";
import { getServerSettings } from "@/lib/serverSettings";
import { eventJsonLd, jsonLdString } from "@/lib/eventSchema";
import { eventJsonLd, jsonLdString } from "@crosscode/seo";
import type { CrosscodeEvent } from "@crosscode/contracts";
// Tiered low-stock threshold: larger events use a smaller percentage.
// Math.round avoids Math.ceil inflating the threshold (e.g. ceil(1.5)=2 made
@@ -188,16 +192,21 @@ export default async function EventDetailPage({ params }: { params: Promise<{ id
const settings = await getServerSettings();
const siteUrl = appUrl.replace(/\/$/, "");
const jsonLd = eventJsonLd(event, {
pageUrl: `${siteUrl}/events/${event.id}`,
imageUrl: event.picture ? resolveToApiOrigin(event.picture) : null,
organizerName: settings.org_name || appName,
siteUrl,
});
// schema.org Event (Google's event results), from the same crosscode.event/1 the feed publishes.
// The description goes in as the plain text it is (the feed's copy is escaped for markdown).
const jsonLd = event.crosscodeEvent
? eventJsonLd({ ...event.crosscodeEvent, description: event.description || null }, {
pageUrl: `${siteUrl}/events/${event.id}`,
organizer: { name: settings.org_name || appName, url: siteUrl },
priceRange: event.priceRangeCents ?? undefined,
offerUrl: `${siteUrl}/register/${event.id}`,
validFrom: event.goLiveAt || null,
})
: null;
return (
<div className="min-h-screen flex flex-col">
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: jsonLdString(jsonLd) }} />
{jsonLd && <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: jsonLdString(jsonLd) }} />}
<Navbar />
<main className="flex-1 py-8 px-4 max-w-6xl mx-auto w-full">
<FunnelTracker eventId={event.id} stage="view" />
@@ -0,0 +1,121 @@
import { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import ReactMarkdown from "react-markdown";
import { ArrowLeft, Calendar, ExternalLink, MapPin, Video } from "lucide-react";
import { Navbar } from "@/components/layout/Navbar";
import { Footer } from "@/components/layout/Footer";
import { ApiImage } from "@/components/shared/ApiImage";
import { ApiError } from "@/lib/api";
import { apiV2Data } from "@/lib/apiV2";
import { formatDateTimeRange } from "@/lib/date";
import { fromLabel, type LinkedEvent } from "@/lib/linkedEvents";
export const revalidate = 60;
type Linked = LinkedEvent & { lastSyncedAt: string | null };
type Params = { params: Promise<{ product: string; id: string }> };
async function load(product: string, id: string): Promise<Linked | null> {
if (product !== "website" && product !== "app") return null;
try {
return (await apiV2Data("get", "/linked-events/{product}/{id}", { params: { product, id }, nextOptions: { next: { revalidate } } })) as unknown as Linked;
} catch (e) {
if (e instanceof ApiError && (e.status === 404 || e.status === 400)) return null;
throw e;
}
}
/** The description's first paragraph as plain text, for the meta description. */
const plain = (md: string | null) => (md || "").split(/\n\s*\n/)[0]!.replace(/\\([\\`*_[\]<>|~#+.!()-])/g, "$1").replace(/[*_`]/g, "").trim().slice(0, 200);
export async function generateMetadata({ params }: Params): Promise<Metadata> {
const { product, id } = await params;
const item = await load(product, id);
if (!item) return {};
const e = item.event;
const description = e.summary || plain(e.description) || `${e.title} — ${formatDateTimeRange(e.startsAt, e.endsAt)}`;
return {
title: e.title,
description,
// A copy: search engines are pointed at the event's own page, so they see one event, not two
// (ROADMAP-v3 §11, "Imported events"). It isn't in this site's sitemap either.
alternates: { canonical: e.origin.url },
openGraph: { title: e.title, description, type: "website", url: e.origin.url, ...(e.imageUrl ? { images: [{ url: e.imageUrl }] } : {}) },
twitter: { card: "summary_large_image", title: e.title, description, ...(e.imageUrl ? { images: [e.imageUrl] } : {}) },
};
}
/**
* An event from another of the church's products (2.4.0): shown read-only, with the way to take
* part at the product it comes from. No schema.org JSON-LD here; its own page carries it.
*/
export default async function LinkedEventPage({ params }: Params) {
const { product, id } = await params;
const item = await load(product, id);
if (!item) notFound();
const e = item.event;
const r = e.registration;
const live = e.sessions.filter(s => !s.cancelled);
return (
<div className="min-h-screen flex flex-col">
<Navbar />
<main className="flex-1 py-8 px-4 max-w-4xl mx-auto w-full">
<Link href="/events" className="inline-flex items-center gap-1 text-sm text-gray-500 hover:text-gray-700 mb-4">
<ArrowLeft className="w-4 h-4" /> All events
</Link>
{e.imageUrl && <ApiImage src={e.imageUrl} alt={e.title} className="w-full max-h-96 object-cover rounded-2xl mb-6" />}
<p className="text-xs font-medium uppercase tracking-wide text-brand-700">{fromLabel(item)}</p>
<h1 className="text-3xl font-bold text-gray-900 mt-1">{e.title}</h1>
{e.status === "cancelled" && <p className="mt-2 inline-block rounded-full bg-red-50 px-3 py-1 text-sm font-medium text-red-700">Cancelled</p>}
<div className="mt-4 space-y-2 text-gray-700">
<p className="flex items-center gap-2"><Calendar className="w-4 h-4 shrink-0 text-gray-400" /> {formatDateTimeRange(e.startsAt, e.endsAt)}</p>
{(e.location?.name || e.location?.address) && (
<p className="flex items-center gap-2"><MapPin className="w-4 h-4 shrink-0 text-gray-400" /> {[e.location?.name, e.location?.address].filter(Boolean).join(", ")}</p>
)}
{e.location?.onlineUrl && (
<p className="flex items-center gap-2"><Video className="w-4 h-4 shrink-0 text-gray-400" /> <a href={e.location.onlineUrl} rel="noopener nofollow" className="text-brand-700 underline">Join online</a></p>
)}
{e.campus && <p className="text-sm text-gray-500">{e.campus.name}</p>}
</div>
{live.length > 1 && (
<div className="mt-6">
<h2 className="font-semibold text-gray-900 mb-2">Dates</h2>
<ul className="space-y-1 text-sm text-gray-700">
{live.map(s => <li key={s.id}>{s.label ? `${s.label}: ` : ""}{formatDateTimeRange(s.startsAt, s.endsAt)}{s.location ? ` · ${s.location}` : ""}</li>)}
</ul>
</div>
)}
{e.description && (
<div className="prose prose-sm max-w-none mt-6 text-gray-700">
{/* Markdown with HTML switched off (crosscode.event/1): raw HTML is dropped, links open as plain links. */}
<ReactMarkdown skipHtml components={{ a: ({ href, children }) => <a href={href} rel="noopener nofollow ugc" className="text-brand-700 underline">{children}</a> }}>
{e.description}
</ReactMarkdown>
</div>
)}
<div className="mt-8 rounded-xl border p-4 bg-gray-50">
{(r.mode === "origin" || r.mode === "external") && r.url ? (
<a href={r.url} rel="noopener" className="inline-flex items-center gap-2 rounded-lg bg-brand-600 px-5 py-2.5 text-white font-medium hover:bg-brand-700">
Register <ExternalLink className="w-4 h-4" aria-hidden />
</a>
) : r.mode === "contact" ? (
<p className="text-sm text-gray-700">No booking here: see the details above for how to take part.</p>
) : (
<p className="text-sm text-gray-700">No booking needed.</p>
)}
<p className="mt-3 text-sm text-gray-600">
This event is run through the {item.productName}.{" "}
<a href={e.origin.url} rel="noopener" className="text-brand-700 underline">See it there</a> for the latest details.
</p>
</div>
</main>
<Footer />
</div>
);
}
+7 -3
View File
@@ -3,6 +3,7 @@ import { Navbar } from "@/components/layout/Navbar";
import { Footer } from "@/components/layout/Footer";
import { EventsGrid } from "@/components/events/EventsGrid";
import { apiFetchListForPrerender } from "@/lib/api";
import { fetchLinkedEvents } from "@/lib/linkedEvents";
import { Calendar } from "lucide-react";
export const revalidate = 60;
@@ -32,7 +33,10 @@ type Event = {
};
export default async function EventsPage() {
const events = await apiFetchListForPrerender<Event>("/api/v2/event-listing", { nextOptions: { next: { revalidate: 60 } } });
const [events, linked] = await Promise.all([
apiFetchListForPrerender<Event>("/api/v2/event-listing", { nextOptions: { next: { revalidate: 60 } } }),
fetchLinkedEvents(),
]);
// A server component renders once per request (or revalidation): this is that render's time.
// eslint-disable-next-line react-hooks/purity
const now = Date.now();
@@ -53,10 +57,10 @@ export default async function EventsPage() {
</div>
<div>
<h1 className="text-2xl sm:text-3xl font-bold text-gray-900">All Events</h1>
<p className="text-sm text-gray-500">{sorted.length} upcoming event{sorted.length === 1 ? "" : "s"}</p>
<p className="text-sm text-gray-500">{sorted.length + linked.length} upcoming event{sorted.length + linked.length === 1 ? "" : "s"}</p>
</div>
</div>
<EventsGrid events={sorted} />
<EventsGrid events={sorted} linked={linked} />
</main>
<Footer />
</div>
+12 -7
View File
@@ -1,5 +1,7 @@
import Link from "next/link";
import { EventCard } from "@/components/events/EventCard";
import { LinkedEventCard } from "@/components/events/LinkedEventCard";
import { fetchLinkedEvents, mergeByStart } from "@/lib/linkedEvents";
import { Navbar } from "@/components/layout/Navbar";
import { Footer } from "@/components/layout/Footer";
import { JoinUsButton } from "@/components/home/JoinUsButton";
@@ -48,9 +50,10 @@ async function getOrgName(): Promise<string> {
}
export default async function HomePage() {
const [events, displayName] = await Promise.all([
const [events, displayName, linked] = await Promise.all([
apiFetchListForPrerender<Event>("/api/v2/event-listing", { nextOptions: { next: { revalidate: 60 } } }),
getOrgName(),
fetchLinkedEvents(),
]);
// A server component renders once per request (or revalidation): this is that render's time.
// eslint-disable-next-line react-hooks/purity
@@ -60,6 +63,8 @@ export default async function HomePage() {
return !isNaN(t) && t > now;
});
const sorted = [...upcoming].sort((a, b) => new Date(a.nextSession?.startsAt || a.startDate).getTime() - new Date(b.nextSession?.startsAt || b.startDate).getTime());
// With events from the church's other products (Linked products), by date.
const items = mergeByStart(sorted, linked, e => e.nextSession?.startsAt || e.startDate);
return (
<div className="min-h-screen flex flex-col">
@@ -72,10 +77,10 @@ export default async function HomePage() {
<div className="absolute -bottom-24 -left-24 w-96 h-96 rounded-full bg-brand-100/40 blur-3xl" />
</div>
<div className="relative max-w-2xl mx-auto px-4">
{sorted.length > 0 && (
{items.length > 0 && (
<div className="inline-flex items-center gap-1.5 text-xs font-medium px-3 py-1.5 rounded-full bg-white border border-brand-200 text-brand-700 shadow-sm mb-5">
<CalendarCheck className="w-3.5 h-3.5" />
{sorted.length} upcoming event{sorted.length === 1 ? "" : "s"}
{items.length} upcoming event{items.length === 1 ? "" : "s"}
</div>
)}
<h1 className="text-4xl sm:text-5xl font-bold mb-4 text-gray-900">Welcome to {displayName}</h1>
@@ -98,16 +103,16 @@ export default async function HomePage() {
<ArrowRight className="w-3.5 h-3.5" />
</Link>
</div>
{sorted.length === 0 ? (
{items.length === 0 ? (
<div className="text-center py-12 border rounded-xl bg-gray-50">
<CalendarCheck className="w-8 h-8 text-gray-300 mx-auto mb-2" />
<p className="text-gray-500 text-sm">No upcoming events right now — check back soon.</p>
</div>
) : (
<div className="grid gap-6 md:grid-cols-3 sm:grid-cols-2">
{sorted.slice(0, 3).map(event => (
<EventCard key={event.id} event={event} />
))}
{items.slice(0, 3).map(item => item.kind === "own"
? <EventCard key={item.event.id} event={item.event} />
: <LinkedEventCard key={item.event.key} item={item.event} />)}
</div>
)}
<div className="text-center mt-8 sm:hidden">