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>
129 lines
3.8 KiB
TypeScript
129 lines
3.8 KiB
TypeScript
/* ═══════════════════════════════════════════════════════════════
|
|
FRONT PAGE DATA
|
|
|
|
GET /front-page, as routes/home.js shapes it: the hero, the
|
|
visible sections in order, counted stats, paths with actions,
|
|
and the countdown's event. Edited in the admin under Front page.
|
|
|
|
No fallback content. If the request fails the page says so: a
|
|
plausible default home page would hide a broken server behind
|
|
something that looks fine.
|
|
═══════════════════════════════════════════════════════════════ */
|
|
|
|
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' | 'event'
|
|
|
|
/** The CHECK list on front_page_sections.section. */
|
|
export type FrontPageSectionKey =
|
|
| 'countdown'
|
|
| 'retreats'
|
|
| 'calendar'
|
|
| 'stats'
|
|
| 'timeline'
|
|
| 'connect'
|
|
| 'featured'
|
|
|
|
export type HeroButton = { label: string; url: string }
|
|
|
|
export type HeroSlide = {
|
|
media: string
|
|
alt?: string | null
|
|
caption?: string | null
|
|
link_url?: string | null
|
|
}
|
|
|
|
export type Hero = {
|
|
backdrop: HeroBackdrop
|
|
feature: HeroFeature
|
|
eyebrow?: string | null
|
|
headline: string
|
|
subhead?: string | null
|
|
primary: HeroButton | null
|
|
secondary: HeroButton | null
|
|
slide_seconds: number
|
|
slides: HeroSlide[]
|
|
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 = {
|
|
section: FrontPageSectionKey
|
|
/** Null → the section's own heading. */
|
|
title?: string | null
|
|
blurb?: string | null
|
|
}
|
|
|
|
export type FrontPageStat = {
|
|
label: string
|
|
/** Already counted or typed; never null, since the API drops those. */
|
|
value: string
|
|
suffix?: string | null
|
|
note?: string | null
|
|
}
|
|
|
|
export type PathAction = { label: string; description?: string | null; url: string }
|
|
|
|
export type FrontPagePath = {
|
|
label: string
|
|
icon?: string | null
|
|
blurb?: string | null
|
|
actions: PathAction[]
|
|
}
|
|
|
|
export type CountdownEvent = {
|
|
id: string
|
|
title: string
|
|
theme?: string | null
|
|
starts_on?: string | null
|
|
ends_on?: string | null
|
|
date_label?: string | null
|
|
location_label?: string | null
|
|
is_online: boolean
|
|
color?: string | null
|
|
event_logo?: string | null
|
|
series: EventSeries | null
|
|
}
|
|
|
|
/** One featured card, as loadFeaturedCards in shape.js shapes it.
|
|
* A record card's title and image are already its record's unless
|
|
* the card overrides them; `ref` is what its link is built from. */
|
|
export type FeaturedCard = {
|
|
kind: 'record' | 'link' | 'video'
|
|
ref: { kind: string; id: string; org_kind?: string | null } | null
|
|
url: string | null
|
|
eyebrow?: string | null
|
|
title?: string | null
|
|
blurb?: string | null
|
|
/** Resolve with logoForKind in media.ts. */
|
|
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[]
|
|
stats: FrontPageStat[]
|
|
paths: FrontPagePath[]
|
|
featured: FeaturedCard[]
|
|
countdown: CountdownEvent | null
|
|
}
|
|
|
|
export const useFrontPage = (): Resource<FrontPage> =>
|
|
useRecord<FrontPage>('/front-page', 'front_page')
|