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:
parent
29202f2eb1
commit
d6477b6d30
7 changed files with 187 additions and 11 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue