Add link card blocks to post bodies

A "cards" content block: each item is a card with a picture, title and
description that links somewhere, like a link shared in a chat. Fetch
preview fills the card from the link. Migration 044 (not deployed yet)
now allows both table and cards.

Also fixes hidden-field clearing when two fields share a path, and adds
table and card blocks to the showcase post.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-29 15:40:24 -05:00
parent 5dceeb5860
commit 4e9b4e3329
8 changed files with 123 additions and 18 deletions

View file

@ -438,6 +438,7 @@ export function LinkPreviewInput({
locked,
className,
showButton,
fills = { title: "title", blurb: "blurb", image: "image" },
onChange,
onPatch,
}: {
@ -449,6 +450,9 @@ export function LinkPreviewInput({
showButton: boolean;
onChange: (value: string) => void;
onPatch?: (patch: Record<string, any>) => void;
/** Which of the row's fields the preview fills (a list item's are
* text, detail and media). */
fills?: { title: string; blurb: string; image: string };
}) {
const { user } = useAuth();
const [busy, setBusy] = useState(false);
@ -461,9 +465,9 @@ export function LinkPreviewInput({
try {
const { preview } = await post("/admin/link-preview", { url: value });
const patch: Record<string, any> = {};
if (!row.title && preview.title) patch.title = preview.title;
if (!row.blurb && preview.description) patch.blurb = preview.description;
if (!row.image && preview.image) patch.image = preview.image.url;
if (!row[fills.title] && preview.title) patch[fills.title] = preview.title;
if (!row[fills.blurb] && preview.description) patch[fills.blurb] = preview.description;
if (!row[fills.image] && preview.image) patch[fills.image] = preview.image.url;
onPatch(patch);
const filled = Object.keys(patch).length;