Add a featured event as a hero option

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 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-27 20:58:37 -05:00
parent 29202f2eb1
commit d6477b6d30
7 changed files with 187 additions and 11 deletions

View file

@ -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"),

View file

@ -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;

View file

@ -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,