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:
parent
c62dc84add
commit
c5f12c769f
13 changed files with 723 additions and 169 deletions
93
src/components/VideoPlayer.tsx
Normal file
93
src/components/VideoPlayer.tsx
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
VIDEO PLAYER: click to play
|
||||
|
||||
A still with a play button; pressing it swaps in the player, so a
|
||||
page loads no iframes until someone asks for one. Used by the
|
||||
featured cards and the video content block.
|
||||
|
||||
The still is the caller's image, else YouTube's own thumbnail,
|
||||
else a plain dark panel. A link that embeds.ts can't turn into a
|
||||
player (not https, or not a host it knows how to frame) still
|
||||
goes somewhere: the still becomes a link to it.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useState } from 'react'
|
||||
|
||||
import HomeLink from '../pages/sections/home/HomeLink.tsx'
|
||||
import { playingSource, videoSource, videoThumbnail } from '../lib/embeds.ts'
|
||||
|
||||
const ACCENT = '#138ba0'
|
||||
|
||||
export default function VideoPlayer({
|
||||
url,
|
||||
still,
|
||||
title,
|
||||
className = '',
|
||||
}: {
|
||||
url?: string | null
|
||||
/** An image URL to show before it plays. */
|
||||
still?: string | null
|
||||
title?: string | null
|
||||
className?: string
|
||||
}) {
|
||||
const [playing, setPlaying] = useState(false)
|
||||
const source = videoSource(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 ${className}`} />
|
||||
) : (
|
||||
<iframe
|
||||
src={live.src}
|
||||
title={title || 'Video'}
|
||||
allow="autoplay; encrypted-media; picture-in-picture; fullscreen"
|
||||
allowFullScreen
|
||||
className={`aspect-video w-full border-0 bg-black ${className}`}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const image = still ?? videoThumbnail(url)
|
||||
|
||||
const face = (
|
||||
<>
|
||||
{image ? (
|
||||
<img src={image} alt="" loading="lazy" className={`aspect-video w-full object-cover ${className}`} />
|
||||
) : (
|
||||
<div className={`aspect-video w-full bg-gradient-to-br from-[#073d4a] to-[#04262e] ${className}`} />
|
||||
)}
|
||||
<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>
|
||||
</>
|
||||
)
|
||||
|
||||
if (!source) {
|
||||
return url ? (
|
||||
<HomeLink url={url} className="group relative block">
|
||||
{face}
|
||||
</HomeLink>
|
||||
) : (
|
||||
<div className="relative">{face}</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setPlaying(true)}
|
||||
aria-label={`Play ${title || 'video'}`}
|
||||
className="group relative block w-full"
|
||||
>
|
||||
{face}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue