Regions: featured cards in the region list and on the region's page (migration 072)

A region owns featured cards like the front page does, set in its
editor (shown when Kind is region). They show in its row of the
region list when opened, and in a Featured section on its page.
featured_cards takes an 'organization' owner kind; the table is
rebuilt, and a region's cards go when it does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aidan Dona 2026-10-07 16:56:14 -05:00
parent 07be48d770
commit 2977168af5
9 changed files with 181 additions and 17 deletions

View file

@ -2,7 +2,8 @@
FEATURED CARDS
A grid of cards that point somewhere: the front page's featured
band now, the Community blog's posts next. The data comes from
band, the Community blog's posts, a region's own cards (in the
region list and on its page). The data comes from
loadFeaturedCards in server/src/shape.js, already resolved, so
this only draws.
@ -85,9 +86,9 @@ function VideoPicture({ card }: { card: FeaturedCard }) {
const RULE = 'border-brand'
function Card({ card, large, level }: { card: FeaturedCard; large: boolean; level: 3 | 4 }) {
function Card({ card, large, level }: { card: FeaturedCard; large: boolean; level: 3 | 4 | 5 }) {
const href = hrefFor(card)
const Title = level === 4 ? 'h4' : 'h3'
const Title = `h${level}` as const
const text = (
<div className={`flex flex-1 flex-col ${large ? 'p-8 md:p-10' : 'p-7'}`}>
@ -137,10 +138,10 @@ function Card({ card, large, level }: { card: FeaturedCard; large: boolean; leve
)
}
type FeaturedCardsProps = { cards: FeaturedCard[]; level?: 3 | 4 }
type FeaturedCardsProps = { cards: FeaturedCard[]; level?: 3 | 4 | 5 }
function ReadingCards({ cards, level = 3 }: FeaturedCardsProps) {
const Title = level === 4 ? 'h4' : 'h3'
const Title = `h${level}` as const
return (
<>
{cards.map((card, index) => {

View file

@ -1,5 +1,5 @@
import { mediaUrl } from "../media.ts";
import { PLACE_FIELDS, PUBLISH_FIELDS, timelineGroup, timelineDetailGroup, linksChild, blocksChild, tagsChild } from "./shared.ts";
import { PLACE_FIELDS, PUBLISH_FIELDS, timelineGroup, timelineDetailGroup, linksChild, blocksChild, tagsChild, featuredCardsChild } from "./shared.ts";
/* ── Organizations ───────────────────────────────────────────── */
@ -90,6 +90,11 @@ export const organizations = {
children: [
tagsChild,
{
...featuredCardsChild,
when: { path: "kind", value: "region" },
note: "Shown in this region's row of the region list (when it's opened) and on its page, in this order.",
},
{
key: "region_areas",
label: "Map areas",

View file

@ -12,6 +12,7 @@
*/
import type { BlogPostSummary } from './useBlog.ts'
import type { FeaturedCard } from './useFrontPage.ts'
import { detailPath } from './hrefs.ts'
import { useRecord, type Resource } from './useRecord.ts'
import type { EventType } from './eventTypes.ts'
@ -257,6 +258,8 @@ export type OrganizationRecord = {
map_note?: string | null
areas?: RegionArea[]
groups?: Array<{ id: string; name: string; location_label?: string | null; logo?: string | null }>
/** A region's own featured cards, in order. */
featured?: FeaturedCard[]
region_id?: string | null
region_name?: string | null
region_color?: string | null

View file

@ -20,6 +20,7 @@ import { Link, Navigate, useLocation, useParams } from 'react-router-dom'
import PageShell from '../components/PageShell.tsx'
import PageState from '../components/PageState.tsx'
import ContentBlocks from '../components/ContentBlocks.tsx'
import FeaturedCards from '../components/FeaturedCards.tsx'
import OrgTeams, { hasTeams } from '../components/OrgTeams.tsx'
import OrgContact from '../components/OrgContact.tsx'
import Tags from '../components/Tags.tsx'
@ -94,6 +95,21 @@ export default function OrganizationDetail() {
},
]
// A region's own featured cards, the same ones its row in the
// region list shows.
if (org.kind === 'region' && (org.details.featured?.length ?? 0) > 0) {
sections.push({
id: 'featured',
title: 'Featured',
accent,
content: (
<div className="max-w-6xl mx-auto px-6">
<FeaturedCards cards={org.details.featured ?? []} />
</div>
),
})
}
if (hasTeams(org)) {
sections.push({
id: 'leadership',

View file

@ -2,6 +2,7 @@ import { ArrowUpRight, CaretRight } from '@phosphor-icons/react';
import { useId, useState } from "react";
import { Link } from "react-router-dom";
import ArrowLink from "../../components/ArrowLink.tsx";
import FeaturedCards from "../../components/FeaturedCards.tsx";
import { mediaUrl } from "../../lib/media.ts";
import Logo from "../../components/Logo.tsx";
import PlatformIcon from "../../components/PlatformIcon.tsx";
@ -38,9 +39,9 @@ import { useReadingMode } from '../../lib/readingMode.ts'
groupBy={org => org.details?.scope}
/>
Kind-specific extras (the areas a region covers, its map note)
come from `details` and render only when present, so a partner
row simply doesn't have them.
Kind-specific extras (the areas a region covers, its map note,
its featured cards) come from `details` and render only when
present, so a partner row simply doesn't have them.
═══════════════════════════════════════════════════════════════ */
const MUTED = "var(--color-muted)";
@ -100,9 +101,12 @@ function OrgRow({ org, pageLabel, siteLabel, titled }) {
exactly once rather than in both places. */
const summary = org.tagline;
// A region's own featured cards, last in the panel.
const featured = org.details?.featured ?? [];
// Something has to be behind the chevron or opening it does nothing.
const hasPanel =
org.description?.length > 0 || areas || note || org.links?.length > 0;
org.description?.length > 0 || areas || note || org.links?.length > 0 || featured.length > 0;
return (
<div className="py-3" style={{ borderTop: `1px solid ${RULE}` }}>
@ -214,6 +218,12 @@ function OrgRow({ org, pageLabel, siteLabel, titled }) {
))}
</div>
)}
{featured.length > 0 && (
<div className="pt-2">
<FeaturedCards cards={featured} level={titled ? 5 : 4} />
</div>
)}
</div>
</div>
</div>