A fourth hero mode beside brand, photos and livestream: a recorded video next to the words, under a "Featured video · <title>" badge. Unlike the livestream it never autoplays: an embed waits for play, and a file shows the browser's own player with preload="metadata". video_url takes a YouTube, Vimeo or Facebook link (turned into an embed, as the livestream's is) or a video file: a filename in public/front-page/, a /path, or an https URL ending in .mp4, .webm, .m4v, .mov or .ogv. Anything else that can't be framed still gets a "Watch the video" button. Files follow the embeds' https-only rule. Its own video_url and video_title columns rather than the livestream's, so both can be set up ahead of time and the mode switches between them. Migration 024 rebuilds front_page for the wider hero_mode CHECK; its children, keys and touch trigger survive. embeds.ts gains an autoplay switch shared by both modes, and videoSource() to tell a file from an embed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
3.5 KiB
TypeScript
85 lines
3.5 KiB
TypeScript
/* ═══════════════════════════════════════════════════════════════
|
|
MEDIA PATHS
|
|
|
|
Every image field in the API is a bare filename — "where the
|
|
images live is the component's business", as history.js puts it.
|
|
This is that business, in one file, so moving a directory is one
|
|
edit rather than a grep.
|
|
|
|
⚠ Only two of these directories are confirmed by the admin help
|
|
text: people/ and event-logos/. The other three are a guess at
|
|
your convention. Check public/ and fix them here — nothing else
|
|
references the paths.
|
|
|
|
A value that already looks like a path or a URL is returned
|
|
untouched, so a hand-written entry can point anywhere.
|
|
═══════════════════════════════════════════════════════════════ */
|
|
|
|
const ABSOLUTE = /^(https?:|\/|data:)/
|
|
|
|
function inDir(dir: string) {
|
|
return (file?: string | null): string | null => {
|
|
if (!file) return null
|
|
if (ABSOLUTE.test(file)) return file
|
|
return `${dir}/${file}`
|
|
}
|
|
}
|
|
|
|
export const personPhoto = inDir('/people') // confirmed
|
|
export const eventLogo = inDir('/event-logos') // confirmed
|
|
export const orgLogo = inDir('/org-logos') // ⚠ guess
|
|
export const teamLogo = inDir('/team-logos') // ⚠ guess
|
|
export const awardLogo = inDir('/award-logos') // ⚠ guess
|
|
|
|
/* front_page_slides.media — the home page hero's photos. New with
|
|
the Front page editor, which names the directory in its help. */
|
|
export const heroPhoto = inDir('/front-page')
|
|
|
|
/* front_page.video_url when it names a file rather than a link:
|
|
same directory as the photos. */
|
|
export const heroVideo = inDir('/front-page')
|
|
|
|
/* content_blocks.media, which can be an image on any owner's page,
|
|
so it can't share a per-entity directory. */
|
|
export const blockMedia = inDir('/media') // ⚠ guess
|
|
|
|
/* ── By record kind ────────────────────────────────────────────
|
|
The timeline sends `logo: { file, kind }` rather than a path,
|
|
because v_timeline COALESCEs across five tables and only the
|
|
ref_kind says which one the filename came from.
|
|
|
|
⚠ Three of these directories are the guesses above. Your current
|
|
timelineRefs.ts already has the real ones — timeline logos render
|
|
today — so copy them into the map above and delete this note.
|
|
───────────────────────────────────────────────────────────── */
|
|
|
|
const BY_KIND: Record<string, (file?: string | null) => string | null> = {
|
|
event: eventLogo,
|
|
organization: orgLogo,
|
|
team: teamLogo,
|
|
award: awardLogo,
|
|
person: personPhoto,
|
|
}
|
|
|
|
export function logoForKind(
|
|
kind?: string | null,
|
|
file?: string | null,
|
|
): string | null {
|
|
if (!file) return null
|
|
// An unrecognised kind still renders: a filename with no home
|
|
// directory is a bug, but a broken <img> says so louder than a
|
|
// silently absent one.
|
|
return (BY_KIND[kind ?? ''] ?? blockMedia)(file)
|
|
}
|
|
|
|
/* Initials for a photo that is missing or fails to load. Same
|
|
two-word rule PeopleTiles uses. */
|
|
export function initials(name = ''): string {
|
|
return name
|
|
.trim()
|
|
.split(/\s+/)
|
|
.slice(0, 2)
|
|
.map((word) => word[0] || '')
|
|
.join('')
|
|
.toUpperCase()
|
|
}
|