Add a Featured Content section to the front page
Front page → Featured cards (migration 030) holds cards of three kinds: a record on the site, whose title, picture and link fill in from the record; a link, with a Fetch preview button that reads the page's title, description and preview image into the media library; and a video, drawn as a thumbnail that loads the player when pressed. A 'featured' section draws them. The cards are shared: featured_cards is owned polymorphically and FeaturedCards.tsx draws them, ready for the Community blog. Deleting a record removes its cards; an unpublished record's card is hidden. The preview fetch only goes to public http(s) addresses on standard ports, pinned to the vetted IP, with each redirect checked again. Along the way: repeater fields can show by another field's value (a hidden one is cleared), a CHECK named as a sentence is shown as the error, and the timeline's record list is now record_refs for both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
960c854611
commit
d4f65d93b4
17 changed files with 1140 additions and 50 deletions
|
|
@ -22,6 +22,7 @@ import {
|
|||
blockMedia,
|
||||
eventBackground,
|
||||
eventLogo,
|
||||
featuredImage,
|
||||
heroPhoto,
|
||||
orgLogo,
|
||||
personPhoto,
|
||||
|
|
@ -148,6 +149,76 @@ const timelineDetailGroup = (noun) => ({
|
|||
fields: timelineExtensionFields(noun),
|
||||
});
|
||||
|
||||
/* Featured cards (030_featured_cards.sql), a front page collection
|
||||
now and the Community blog's next, so it's written once. Fields
|
||||
show by kind; switching kind clears the ones that stop applying
|
||||
(see `when` in fields.tsx). */
|
||||
const FEATURED_KINDS = [
|
||||
["record", "A page on this site (event, org, person…)"],
|
||||
["link", "A link (article, post, any URL)"],
|
||||
["video", "A video (YouTube, Vimeo, Facebook)"],
|
||||
];
|
||||
|
||||
const featuredCardsChild = {
|
||||
key: "featured_cards",
|
||||
label: "Featured cards",
|
||||
note: "Shown by the Featured Content section, in this order.",
|
||||
addLabel: "Add card",
|
||||
title: (row, options) =>
|
||||
row.title ||
|
||||
options?.record_refs?.find((o) => o.kind === row.ref_kind && o.id === row.ref_id)?.label ||
|
||||
row.url ||
|
||||
"New card",
|
||||
blank: { kind: "", ref_kind: "", ref_id: "", url: "", title: "" },
|
||||
fields: [
|
||||
{
|
||||
path: "kind",
|
||||
label: "Card type",
|
||||
widget: "select",
|
||||
options: FEATURED_KINDS,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
path: "ref_kind",
|
||||
label: "Record type",
|
||||
widget: "select",
|
||||
options: ["event", "organization", "person", "team", "award"],
|
||||
required: true,
|
||||
when: { path: "kind", value: "record" },
|
||||
},
|
||||
{
|
||||
path: "ref_id",
|
||||
label: "Record",
|
||||
widget: "select",
|
||||
optionsFrom: "record_refs",
|
||||
filterBy: (option, row) => option.kind === row.ref_kind,
|
||||
required: true,
|
||||
when: { path: "kind", value: "record" },
|
||||
help: "Its title, picture and link fill the card. Anything typed below overrides them.",
|
||||
},
|
||||
{
|
||||
path: "url",
|
||||
label: "URL",
|
||||
widget: "linkPreview",
|
||||
previewWhen: { path: "kind", value: "link" },
|
||||
required: true,
|
||||
full: true,
|
||||
when: { path: "kind", value: ["link", "video"] },
|
||||
},
|
||||
{ path: "eyebrow", label: "Label", help: "Small text above the title, eg. Article, Watch" },
|
||||
{ path: "title", label: "Title" },
|
||||
{ path: "blurb", label: "Blurb", widget: "textarea", full: true },
|
||||
{
|
||||
path: "image",
|
||||
label: "Image",
|
||||
widget: "image",
|
||||
resolve: featuredImage,
|
||||
full: true,
|
||||
help: "Default: the record's own picture, or for a YouTube video, its thumbnail.",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/* The two collections every entity carries. */
|
||||
const linksChild = {
|
||||
key: "links",
|
||||
|
|
@ -915,7 +986,7 @@ const timeline = {
|
|||
path: "ref_id",
|
||||
label: "Record",
|
||||
widget: "select",
|
||||
optionsFrom: "timeline_refs",
|
||||
optionsFrom: "record_refs",
|
||||
blankLabel: "Default: none",
|
||||
// One flat list of every referenceable row, narrowed to the
|
||||
// kind chosen above. Five dropdowns of which four are always
|
||||
|
|
@ -1015,6 +1086,7 @@ const FRONT_PAGE_SECTIONS = [
|
|||
["stats", "Stats"],
|
||||
["timeline", "Featured Timeline"],
|
||||
["connect", "Connect Nav"],
|
||||
["featured", "Featured Content"],
|
||||
];
|
||||
|
||||
const STAT_SOURCES = [
|
||||
|
|
@ -1196,6 +1268,7 @@ const frontPage = {
|
|||
{ path: "note", label: "Note", full: true },
|
||||
],
|
||||
},
|
||||
featuredCardsChild,
|
||||
{
|
||||
key: "paths",
|
||||
label: "Connect Nav",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue