From d6477b6d306a3a4d6286015e9b8ded880e1c7da2 Mon Sep 17 00:00:00 2001
From: Zaldimmar
Date: Sun, 27 Sep 2026 20:58:37 -0500
Subject: [PATCH] Add a featured event as a hero option
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Front page → Feature gains "Featured event" (migration 033): the
event's card beside the headline, with its photo or colour, dates or
schedule, place, tagline, action buttons and a link to its page,
under a "Featured event" badge, over either backdrop.
Front page → Featured event pins one. Blank uses the countdown's
event, and a pinned event that's over or unpublished falls back to
it, so the hero and the countdown never disagree.
Co-Authored-By: Claude Opus 5.5
---
docs/updating-data-in-code.md | 4 +-
server/src/admin-schema.js | 3 +-
server/src/migrations/033_hero_event.sql | 34 ++++++++
server/src/routes/home.js | 32 +++++++-
src/lib/adminSchema.ts | 12 ++-
src/lib/useFrontPage.ts | 13 ++-
src/pages/sections/home/HeroStage.tsx | 100 +++++++++++++++++++++--
7 files changed, 187 insertions(+), 11 deletions(-)
create mode 100644 server/src/migrations/033_hero_event.sql
diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md
index e876f9f..f96f5b6 100644
--- a/docs/updating-data-in-code.md
+++ b/docs/updating-data-in-code.md
@@ -181,7 +181,7 @@ also in `admin-schema.js` and a CHECK):
| Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping |
| Front page → Countdown → Only this type | retreat, class, workshop, meeting, other | **yes** | `server/src/routes/home.js` (picks the countdown event). The same values as Events → Type, so adding a type widens both CHECKs. |
| Front page → Background | brand, photos | **yes** | `HeroStage.tsx` |
-| Front page → Feature | none, livestream, video | **yes** | `HeroStage.tsx` |
+| Front page → Feature | none, livestream, video, event | **yes** | `HeroStage.tsx`; the event is picked in `server/src/routes/home.js` |
| Front page → Sections → Section | countdown, retreats, calendar, stats, timeline, connect, featured | **yes**, `FRONT_PAGE_SECTIONS` | `SECTIONS` in `src/pages/Home.tsx`; see [below](#front-page-section-names) |
| Front page → Stats → Number Source | manual, years_since, regions, … | **yes**, `STAT_SOURCES` | `STAT_QUERIES` in `server/src/routes/home.js`; see [below](#front-page-stat-sources) |
| Front page → Featured cards → Card type (Community blog section → Pinned community posts offers link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` |
@@ -204,7 +204,7 @@ code):
| Timeline → Record; Featured cards → Record | `record_refs` | every event, organization, award, person and team, narrowed by the type picked beside it |
| Affiliations → Team | `teams` | teams, filtered to the chosen organization |
| Person awards → Award | `awards` | awards, labelled "Award (Organization)" |
-| Person awards → Presented at; Front page → Count down to | `events` | events |
+| Person awards → Presented at; Front page → Count down to; Front page → Featured event | `events` | events |
| Timeline → Record | `timeline_refs` | all five kinds, filtered by "Points at" |
---
diff --git a/server/src/admin-schema.js b/server/src/admin-schema.js
index fafa531..e8a5ac1 100644
--- a/server/src/admin-schema.js
+++ b/server/src/admin-schema.js
@@ -710,7 +710,8 @@ const frontPage = {
columns: [
enumeration("hero_backdrop", ["brand", "photos"]),
- enumeration("hero_feature", ["none", "livestream", "video"]),
+ enumeration("hero_feature", ["none", "livestream", "video", "event"]),
+ text("hero_event_id"),
text("eyebrow"),
text("headline"),
text("subhead"),
diff --git a/server/src/migrations/033_hero_event.sql b/server/src/migrations/033_hero_event.sql
new file mode 100644
index 0000000..ae50122
--- /dev/null
+++ b/server/src/migrations/033_hero_event.sql
@@ -0,0 +1,34 @@
+-- ═══════════════════════════════════════════════════════════════
+-- 033 HERO: A FEATURED EVENT
+--
+-- A fourth hero feature, 'event': an event's card beside the
+-- headline, over whichever backdrop is chosen.
+--
+-- hero_event_id the event to feature. Null means the event the
+-- countdown shows (its pin, or the next one that
+-- hasn't ended, narrowed by its scope and type),
+-- so the hero and the countdown can't disagree.
+-- A pinned event that is over, unpublished or
+-- deleted falls back the same way; ON DELETE SET
+-- NULL does the last one.
+--
+-- hero_feature's CHECK gains 'event'. A CHECK can't be altered in
+-- place, so the column is replaced the way 025 did it: a new column
+-- with the new CHECK, the values copied across, the old one dropped
+-- and the new one renamed into its place. Nothing else names the
+-- column, so front_page itself needn't be rebuilt.
+--
+-- PRAGMA user_version; -- reads 32 before this file
+-- ═══════════════════════════════════════════════════════════════
+
+ALTER TABLE front_page ADD COLUMN hero_feature_new TEXT NOT NULL DEFAULT 'none'
+ CHECK (hero_feature_new IN ('none', 'livestream', 'video', 'event'));
+
+UPDATE front_page SET hero_feature_new = hero_feature;
+
+ALTER TABLE front_page DROP COLUMN hero_feature;
+
+ALTER TABLE front_page RENAME COLUMN hero_feature_new TO hero_feature;
+
+ALTER TABLE front_page ADD COLUMN hero_event_id TEXT
+ REFERENCES events (id) ON DELETE SET NULL;
diff --git a/server/src/routes/home.js b/server/src/routes/home.js
index d09a465..bd5824d 100644
--- a/server/src/routes/home.js
+++ b/server/src/routes/home.js
@@ -34,6 +34,12 @@
means any. They don't apply to a pinned event: the admin chose
that one by name.
+ ── Hero event ──
+ With the 'event' feature, the hero draws the pinned hero_event_id
+ if it's still published and not over, else the countdown's event
+ (above), so the two never disagree. Its action links ride along
+ for the card's buttons.
+
── Featured ──
The featured band's cards, record cards filled in from their
records (loadFeaturedCards in shape.js, which the Community
@@ -42,7 +48,7 @@
import { Hono } from "hono";
-import { asBool, loadFeaturedCards, shapeSeries } from "../shape.js";
+import { asBool, loadFeaturedCards, loadLinks, shapeSeries, splitLinks } from "../shape.js";
const home = new Hono();
@@ -84,6 +90,20 @@ function statValue(db, row) {
return sql ? String(db.prepare(sql).get().n) : null;
}
+/* The countdown's fields plus what the hero's event card also draws:
+ its tagline, place, card background and buttons. */
+function shapeHeroEvent(db, row) {
+ if (!row) return null;
+ const { actions } = splitLinks(loadLinks(db, "event", [row.id]).get(row.id) ?? []);
+ return {
+ ...shapeCountdown(row),
+ tagline: row.tagline,
+ card_image: row.card_image,
+ org_logo: row.effective_org_logo,
+ links: actions,
+ };
+}
+
function shapeCountdown(row) {
if (!row) return null;
return {
@@ -179,6 +199,15 @@ home.get("/front-page", (c) => {
)
.get(...params);
+ const heroEvent =
+ page.hero_feature === "event"
+ ? (page.hero_event_id
+ ? db
+ .prepare(`SELECT * FROM v_events WHERE id = ? AND ${notOver}`)
+ .get(page.hero_event_id)
+ : null) ?? next
+ : null;
+
return json(c, {
front_page: {
hero: {
@@ -201,6 +230,7 @@ home.get("/front-page", (c) => {
video: page.video_url
? { url: page.video_url, title: page.video_title }
: null,
+ event: shapeHeroEvent(db, heroEvent),
},
sections,
stats,
diff --git a/src/lib/adminSchema.ts b/src/lib/adminSchema.ts
index f035adf..fe3d299 100644
--- a/src/lib/adminSchema.ts
+++ b/src/lib/adminSchema.ts
@@ -1218,6 +1218,7 @@ const frontPage = {
["none", "Nothing: No additional overlay"],
["livestream", "Livestream: the stream, with a LIVE badge"],
["video", "Featured video: click to play"],
+ ["event", "Featured event: an event's card"],
],
blankLabel: "Default: nothing",
help: "Switch to Livestream when you go live, and back when you're done",
@@ -1232,7 +1233,7 @@ const frontPage = {
],
},
{
- legend: "Photos, livestream and video",
+ legend: "Photos, livestream, video and event",
fields: [
{
path: "slide_seconds",
@@ -1256,6 +1257,15 @@ const frontPage = {
"/front-page/ or a link ending in .mp4 or .webm",
},
{ path: "video_title", label: "Video title", full: true, help: "Shown after \"Featured video\" above the headline" },
+ {
+ path: "hero_event_id",
+ label: "Featured event",
+ widget: "select",
+ optionsFrom: "events",
+ blankLabel: "Default: the countdown's event",
+ full: true,
+ help: "For the Featured event feature. A pinned event that's over falls back to the countdown's",
+ },
],
},
{
diff --git a/src/lib/useFrontPage.ts b/src/lib/useFrontPage.ts
index a1bba44..094137d 100644
--- a/src/lib/useFrontPage.ts
+++ b/src/lib/useFrontPage.ts
@@ -12,12 +12,13 @@
import { useRecord, type Resource } from './useRecord.ts'
import type { EventSeries } from './eventSeries.ts'
+import type { Link } from './useContent.ts'
/** What fills the hero's background. */
export type HeroBackdrop = 'brand' | 'photos'
/** What sits beside the words, over the backdrop. */
-export type HeroFeature = 'none' | 'livestream' | 'video'
+export type HeroFeature = 'none' | 'livestream' | 'video' | 'event'
/** The CHECK list on front_page_sections.section. */
export type FrontPageSectionKey =
@@ -51,6 +52,8 @@ export type Hero = {
livestream: { url: string; title?: string | null } | null
/** A link to embed or a video file; see videoSource in embeds.ts. */
video: { url: string; title?: string | null } | null
+ /** With the 'event' feature: the pinned event, else the countdown's. */
+ event: HeroEvent | null
}
export type FrontPageSection = {
@@ -105,6 +108,14 @@ export type FeaturedCard = {
image: { file: string; kind: string } | null
}
+/** The countdown's event plus what the hero's event card draws. */
+export type HeroEvent = CountdownEvent & {
+ tagline?: string | null
+ card_image?: string | null
+ org_logo?: string | null
+ links: Link[]
+}
+
export type FrontPage = {
hero: Hero
sections: FrontPageSection[]
diff --git a/src/pages/sections/home/HeroStage.tsx b/src/pages/sections/home/HeroStage.tsx
index 172f585..ff9467b 100644
--- a/src/pages/sections/home/HeroStage.tsx
+++ b/src/pages/sections/home/HeroStage.tsx
@@ -20,9 +20,13 @@
video a featured video under a "Featured video" badge.
Never autoplays: an embed waits for play, a file
shows the browser's player
+ event an event's card under a "Featured event" badge:
+ its photo, dates, place and buttons. The API picks
+ the event (pinned, else the countdown's)
A choice with nothing to show falls back: photos with no photos
- to brand, a feature with no link set to none. A link that can't
+ to brand, a feature with no link set (or no event to show) to
+ none. A link that can't
be framed still gets a "Watch live" or "Watch the video" button,
so switching a feature on is never a no-op.
@@ -33,11 +37,16 @@
import { useEffect, useState, type CSSProperties } from 'react'
+import { Link } from 'react-router-dom'
+
import HomeLink from './HomeLink.tsx'
import DoveMark from '../../../components/DoveMark.tsx'
+import PlatformIcon from '../../../components/PlatformIcon.tsx'
import { livestreamEmbedUrl, videoSource, type VideoSource } from '../../../lib/embeds.ts'
-import { heroPhoto } from '../../../lib/media.ts'
-import type { Hero, HeroBackdrop, HeroFeature, HeroSlide } from '../../../lib/useFrontPage.ts'
+import { eventBackground, heroPhoto } from '../../../lib/media.ts'
+import { eventHref } from '../../../lib/hrefs.ts'
+import { seriesLabel } from '../../../lib/eventSeries.ts'
+import type { Hero, HeroBackdrop, HeroEvent, HeroFeature, HeroSlide } from '../../../lib/useFrontPage.ts'
const DEEP = '#04262e'
@@ -54,9 +63,11 @@ export default function HeroStage({ hero }: { hero: Hero | null }) {
? 'livestream'
: hero?.feature === 'video' && hero.video
? 'video'
- : 'none'
+ : hero?.feature === 'event' && hero.event
+ ? 'event'
+ : 'none'
- // Both features share a layout: words left, player right.
+ // Every feature shares a layout: words left, feature right.
const beside = feature !== 'none'
return (
@@ -87,6 +98,12 @@ export default function HeroStage({ hero }: { hero: Hero | null }) {
)}
+
+ {feature === 'event' && hero?.event && (
+
▶
@@ -413,3 +435,71 @@ function VideoFrame({
)
}
+
+/* ── Featured event ──────────────────────────────────────────── */
+
+/* The event's own card for the hero: its background photo (or its
+ colour), then what, when and where, then its buttons and a way
+ to its page. The first action link is the filled button, since
+ it's usually Register. */
+function EventPanel({ event }: { event: HeroEvent }) {
+ const color = event.color || '#138ba0'
+ const photo = eventBackground(event.card_image)
+ const when = seriesLabel(event.series, event.starts_on) ?? event.date_label
+ const where = event.is_online && !event.location_label ? 'Online' : event.location_label
+
+ return (
+