Improve content blocks: new types, formatting, and a better editor

Blocks (migration 032): video (click to play, sharing the featured
cards' player), button and callout types; quotes get an attribution
and images alt text separate from the caption. Paragraphs, callouts,
quotes and list items take **bold**, *italic*, [text](url), line
breaks and blank-line paragraphs, parsed into elements (never HTML)
with only safe link schemes. A list item's detail no longer uses an
em-dash.

Editor: each block type shows only its fields, with a named type and
a description, and every open block previews itself with the site's
renderer. Any repeater row can now be duplicated or have a new row
inserted below it; nested collections take `when`, and help text can
depend on the row.

src/seed-showcase.js writes a local test post using every block type
and option. It refuses the production database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-27 16:50:21 -05:00
parent c62dc84add
commit c5f12c769f
13 changed files with 723 additions and 169 deletions

View file

@ -10,10 +10,9 @@
record links to the record's own page (hrefs.ts builds it)
link links to its URL, a new tab when it leaves the site
video a still with a play button; pressing it swaps in the
player, so the page loads no iframes until then. The
still is the card's image, else YouTube's thumbnail,
else a plain panel.
video VideoPlayer: a still with a play button that swaps in
the player when pressed. The still is the card's
image, else YouTube's thumbnail, else a plain panel.
A photo fills the picture area; a logo sits inside it on a soft
panel instead, since cropping a logo to 16:9 cuts it off.
@ -22,13 +21,11 @@
import { useState } from 'react'
import HomeLink from '../pages/sections/home/HomeLink.tsx'
import VideoPlayer from './VideoPlayer.tsx'
import { refHref } from '../lib/hrefs.ts'
import { logoForKind } from '../lib/media.ts'
import { playingSource, videoSource, videoThumbnail } from '../lib/embeds.ts'
import type { FeaturedCard } from '../lib/useFrontPage.ts'
const ACCENT = '#138ba0'
/* Image kinds that are photographs, drawn edge to edge. Anything
else is a logo, drawn whole. */
const PHOTO_KINDS = new Set(['event-background', 'featured', 'person'])
@ -71,68 +68,8 @@ function Picture({ card }: { card: FeaturedCard }) {
}
function VideoPicture({ card }: { card: FeaturedCard }) {
const [playing, setPlaying] = useState(false)
const source = videoSource(card.url)
if (playing && source) {
const live = playingSource(source)
return live.kind === 'file' ? (
<video src={live.src} controls autoPlay playsInline className="aspect-video w-full bg-black" />
) : (
<iframe
src={live.src}
title={card.title || 'Video'}
allow="autoplay; encrypted-media; picture-in-picture; fullscreen"
allowFullScreen
className="aspect-video w-full border-0 bg-black"
/>
)
}
const own = card.image ? logoForKind(card.image.kind, card.image.file) : null
const still = own ?? videoThumbnail(card.url)
const face = (
<>
{still ? (
<img src={still} alt="" loading="lazy" className="aspect-video w-full object-cover" />
) : (
<div className="aspect-video w-full bg-gradient-to-br from-[#073d4a] to-[#04262e]" />
)}
<span
aria-hidden="true"
className="absolute inset-0 flex items-center justify-center bg-black/10 transition-colors group-hover:bg-black/25"
>
<span className="flex h-16 w-16 items-center justify-center rounded-full bg-white/90 shadow-lg transition-transform group-hover:scale-110">
<svg viewBox="0 0 24 24" className="ml-1 h-7 w-7" fill={ACCENT}>
<path d="M8 5v14l11-7z" />
</svg>
</span>
</span>
</>
)
// A link that can't be played here still goes somewhere.
if (!source) {
return card.url ? (
<HomeLink url={card.url} className="group relative block">
{face}
</HomeLink>
) : (
<div className="relative">{face}</div>
)
}
return (
<button
type="button"
onClick={() => setPlaying(true)}
aria-label={`Play ${card.title || 'video'}`}
className="group relative block w-full"
>
{face}
</button>
)
return <VideoPlayer url={card.url} still={own} title={card.title} />
}
function Card({ card }: { card: FeaturedCard }) {