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

@ -279,11 +279,15 @@ export const BLOCK_TYPES = [
["video", "Video", "A YouTube, Vimeo or Facebook video, or a video file, played in place."],
["schedule", "Schedule", "Entries in one tab per day, each folding out for more. The text is an optional intro."],
["table", "Table", "A grid of text, eg. a comparison chart: one row per line, cells split by |, the first row the header."],
["cards", "Link cards", "Cards with a picture, title and description, each a link, like a link shared in a chat. Paste a link and press Fetch preview."],
["divider", "Divider", "A thin line between parts."],
];
/* An item field that only a schedule's entries have. */
export const SCHEDULE_ENTRY = { scope: "parent", path: "type", value: "schedule" };
/* Item fields for a link card, and for every other kind of item. */
export const CARD_ITEM = { scope: "parent", path: "type", value: "cards" };
export const NOT_CARD_ITEM = { scope: "parent", path: "type", value: ["list", "links", "schedule"] };
export const blockTypeLabel = (type) => BLOCK_TYPES.find(([value]) => value === type)?.[1] ?? type;
@ -384,7 +388,7 @@ export const blocksChild = {
key: "items",
label: "Items",
addLabel: "Add item",
when: { path: "type", value: ["list", "links", "schedule"] },
when: { path: "type", value: ["list", "links", "schedule", "cards"] },
title: (row) => [row.day, row.time, row.text].filter(Boolean).join(" · ") || "New item",
blank: { text: "" },
fields: [
@ -395,7 +399,17 @@ export const blocksChild = {
when: SCHEDULE_ENTRY,
},
{ path: "time", label: "Time", help: "eg. 7:00pm, or 9:00 to 10:30am", when: SCHEDULE_ENTRY },
{ path: "text", label: "Text", required: true, help: "Schedules: the entry's title" },
// A card: the link first, so Fetch preview can fill the rest.
{
path: "url",
label: "Link",
widget: "linkPreview",
previewFills: { title: "text", blurb: "detail", image: "media" },
full: true,
help: "A page on this site (eg. /retreats) or anywhere else. Fetch preview fills the title, description and picture.",
when: CARD_ITEM,
},
{ path: "text", label: "Text", required: true, help: "Schedules: the entry's title. Cards: the card's title" },
{
path: "location",
label: "Location",
@ -411,8 +425,18 @@ export const blocksChild = {
help: "Who hosts or speaks: shown with their photo, linked to their page",
when: SCHEDULE_ENTRY,
},
{ path: "detail", label: "Detail", help: "A line under the text. Lists: shown after the text" },
{ path: "url", label: "URL", help: "Blank for plain text. Link buttons need one." },
{ path: "detail", label: "Detail", help: "A line under the text. Lists: shown after the text", when: NOT_CARD_ITEM },
{ path: "detail", label: "Description", widget: "textarea", full: true, when: CARD_ITEM },
{ path: "url", label: "URL", help: "Blank for plain text. Link buttons need one.", when: NOT_CARD_ITEM },
{
path: "media",
label: "Picture",
widget: "image",
resolve: mediaUrl,
full: true,
help: "Optional. Default: none, the card is text only.",
when: CARD_ITEM,
},
{
path: "description",
label: "More",

View file

@ -36,6 +36,7 @@ export type ContentBlock = {
| 'callout'
| 'schedule'
| 'table'
| 'cards'
text?: string | null
media?: string | null
href?: string | null