diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md
index 8fa6a36..9fa4888 100644
--- a/docs/updating-data-in-code.md
+++ b/docs/updating-data-in-code.md
@@ -181,9 +181,10 @@ also in `server/src/admin-schema/` and a CHECK):
| Links → Kind (on organizations, events, people, teams) | action, social, website, email | no | `splitLinks` in `server/src/shape.js` |
| Links → Platform | instagram, facebook, discord, youtube, tiktok, x, substack, spotify, linkedin | **yes**, `PLATFORMS` | `PlatformIcon.tsx` draws the icon on the button. **No CHECK and no `enumeration`**: the column is plain text, so adding one is an entry in `PLATFORMS` (`src/lib/platforms.ts`) and its icon in `src/components/PlatformIcon.tsx`, no migration. |
| Content blocks → Shown in (slot) | card, body | **yes** | `paragraphs()` in `server/src/shape.js` (card), `ContentBlocks.tsx` (body) |
-| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule, table, cards, people, map, events | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema/shared.ts`). |
+| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule, table, cards, people, map, events, organizations | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema/shared.ts`). |
| Content blocks → Schedule items → Type | (blank: normal entry), block, break, heading | **yes**, migration 086 | `SCHEDULE_KINDS` in `src/lib/adminSchema/shared.ts`; drawn by `ScheduleBlock.tsx` and `EventPresent.tsx` (which slides each kind gets; the presentation cuts the event's page into sections at its Heading blocks). A block's sub-items are `content_block_subitems`. A schedule's own tags (087) are `content_block_tags`, rows of the block typed in the admin (not a fixed list); entries name them by `tag_key`, made in the admin as the tag is added. A schedule's Venue (088) lends its locations (Data → Venues, `venue_locations`) to its entries' Map location, named by `location_key` the same way; an entry's Event (a workshop) fills what it leaves blank in `shape.js` (`attachEvents`). |
| Content blocks → List → Style | (blank: bold text, normal detail), plain (plain text, gray detail) | **yes**, migration 092 | The Style field in `src/lib/adminSchema/shared.ts`; drawn by the `list` case in `ContentBlocks.tsx`. |
+| Content blocks → Organizations → List | (blank: only the picked ones), partner, region, group, ministry | **yes**, migration 093 | The `org_kind` field in `src/lib/adminSchema/shared.ts`; the `organizations` case in `ContentBlocks.tsx` passes it as the kind to `OrgListCards` (`nested`); items picked by `org_id` replace it |
| Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` |
| Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` |
| Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping |
diff --git a/server/src/admin-schema/columns.js b/server/src/admin-schema/columns.js
index 6b37c79..16f989f 100644
--- a/server/src/admin-schema/columns.js
+++ b/server/src/admin-schema/columns.js
@@ -157,6 +157,8 @@ export const blocksChild = (ownerKind) => ({
// A venue's map, and event cards (088).
"map",
"events",
+ // Organization cards (093).
+ "organizations",
],
{ required: true },
),
@@ -177,6 +179,8 @@ export const blocksChild = (ownerKind) => ({
text("venue_id"),
// List blocks (092): null bold text, 'plain' the old look.
enumeration("list_style", ["plain"]),
+ // Organizations blocks (093): the kind listed when none are picked.
+ enumeration("org_kind", ["region", "group", "partner", "ministry"]),
],
children: [
{
@@ -212,6 +216,8 @@ export const blocksChild = (ownerKind) => ({
// A featured event's heading and subheading (090).
text("heading"),
text("subheading"),
+ // An organizations block's organization (093).
+ text("org_id"),
],
children: [
{
diff --git a/server/src/migrations/093_organizations_block.sql b/server/src/migrations/093_organizations_block.sql
new file mode 100644
index 0000000..b2d6b6e
--- /dev/null
+++ b/server/src/migrations/093_organizations_block.sql
@@ -0,0 +1,91 @@
+-- ═══════════════════════════════════════════════════════════════
+-- 093 ORGANIZATIONS BLOCK
+--
+-- An 'organizations' content block shows organizations as the
+-- Partners page's cards (OrgList-Card.tsx): the ones picked as its
+-- items, in their order (content_block_items.org_id), else every
+-- published, listed one of its kind (content_blocks.org_kind), by
+-- name.
+--
+-- content_blocks.type's CHECK can't change in place, so the table
+-- is rebuilt (as in 088), then its index and owner trigger made
+-- again.
+-- ═══════════════════════════════════════════════════════════════
+
+ALTER TABLE content_block_items ADD COLUMN org_id TEXT
+ REFERENCES organizations (id) ON DELETE SET NULL;
+
+CREATE TABLE content_blocks_new (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ owner_kind TEXT NOT NULL
+ CHECK (owner_kind IN ('organization', 'event', 'person', 'team', 'blog_post', 'page_section',
+ 'newsletter')),
+ owner_id TEXT NOT NULL,
+ slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body', 'both')),
+ sort_order INTEGER NOT NULL DEFAULT 0,
+
+ type TEXT NOT NULL
+ CHECK (type IN ('heading', 'subheading', 'paragraph',
+ 'list', 'links', 'quote', 'image', 'divider',
+ 'video', 'button', 'callout', 'schedule', 'table', 'cards',
+ 'people', 'tab', 'map', 'events', 'organizations')),
+ text TEXT,
+ media TEXT,
+ href TEXT,
+ alt TEXT,
+ cite TEXT,
+ team_id TEXT REFERENCES teams (id) ON DELETE SET NULL,
+ captions TEXT,
+ word_motion TEXT CHECK (word_motion IN ('slide', 'flip', 'fade', 'type', 'mirror')),
+ word_direction TEXT CHECK (word_direction IN ('top', 'bottom')),
+ word_seconds INTEGER CHECK (word_seconds BETWEEN 1 AND 20),
+ -- Map and schedule blocks: whose map, and whose locations.
+ venue_id TEXT REFERENCES venues (id) ON DELETE SET NULL,
+ -- List blocks (092): null bold text, 'plain' the old look.
+ list_style TEXT CHECK (list_style IN ('plain')),
+ -- Organizations blocks: the kind listed when none are picked.
+ org_kind TEXT CHECK (org_kind IN ('region', 'group', 'partner', 'ministry'))
+) STRICT;
+
+INSERT INTO content_blocks_new
+ (id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions,
+ word_motion, word_direction, word_seconds, venue_id, list_style)
+SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions,
+ word_motion, word_direction, word_seconds, venue_id, list_style
+ FROM content_blocks;
+
+PRAGMA legacy_alter_table = ON;
+DROP TABLE content_blocks;
+ALTER TABLE content_blocks_new RENAME TO content_blocks;
+PRAGMA legacy_alter_table = OFF;
+
+CREATE INDEX content_blocks_owner_idx
+ ON content_blocks (owner_kind, owner_id, slot, sort_order);
+
+CREATE TRIGGER content_blocks_owner_exists
+BEFORE INSERT ON content_blocks
+BEGIN
+ SELECT CASE
+ WHEN new.owner_kind = 'event'
+ AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such event')
+ WHEN new.owner_kind = 'organization'
+ AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such organization')
+ WHEN new.owner_kind = 'person'
+ AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such person')
+ WHEN new.owner_kind = 'team'
+ AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such team')
+ WHEN new.owner_kind = 'blog_post'
+ AND NOT EXISTS (SELECT 1 FROM blog_posts WHERE id = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such blog post')
+ WHEN new.owner_kind = 'page_section'
+ AND NOT EXISTS (SELECT 1 FROM page_sections WHERE CAST(id AS TEXT) = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such page section')
+ WHEN new.owner_kind = 'newsletter'
+ AND NOT EXISTS (SELECT 1 FROM newsletters WHERE CAST(id AS TEXT) = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such newsletter')
+ END;
+END;
diff --git a/server/src/shape.js b/server/src/shape.js
index 739e9b2..64f7c76 100644
--- a/server/src/shape.js
+++ b/server/src/shape.js
@@ -71,7 +71,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
const blockRows = db
.prepare(
`SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id, venue_id,
- word_motion, word_direction, word_seconds, list_style
+ word_motion, word_direction, word_seconds, list_style, org_kind
FROM content_blocks
WHERE owner_kind = ? AND slot IN (?, 'both') AND owner_id IN (${placeholders(ids.length)})
ORDER BY owner_id, sort_order`,
@@ -94,6 +94,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
team_id: row.team_id,
venue_id: row.venue_id,
list_style: row.list_style,
+ org_kind: row.org_kind,
// Its rotating words' motion (084), when it has its own.
words: row.word_motion || row.word_direction || row.word_seconds
? { motion: row.word_motion, direction: row.word_direction, seconds: row.word_seconds }
@@ -117,7 +118,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
const itemRows = db
.prepare(
- `SELECT i.id, i.block_id, i.day, i.kind, i.heading, i.subheading, ${ENTRY_FIELDS}
+ `SELECT i.id, i.block_id, i.day, i.kind, i.heading, i.subheading, i.org_id, ${ENTRY_FIELDS}
FROM content_block_items i
LEFT JOIN v_people_public p ON p.id = i.person_id AND p.is_published = 1
WHERE i.block_id IN (${placeholders(blockIds.length)})
@@ -135,6 +136,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
kind: row.kind ?? "entry",
heading: row.heading,
subheading: row.subheading,
+ org_id: row.org_id,
items: [],
};
itemsById.set(row.id, item);
diff --git a/src/components/ContentBlocks.tsx b/src/components/ContentBlocks.tsx
index c3f96de..57a11a7 100644
--- a/src/components/ContentBlocks.tsx
+++ b/src/components/ContentBlocks.tsx
@@ -71,6 +71,7 @@ import { SITE_NAME } from '../lib/site.ts'
import { useSmallImage } from '../lib/useSmallImage.ts'
import { useReadingMode } from '../lib/readingMode.ts'
import { WordMotion, Words } from './RotatingWords.tsx'
+import OrgListCards from '../pages/sections/OrgList-Card.tsx'
const BODY = 'var(--color-muted)'
@@ -595,6 +596,22 @@ function Block({
return
}
+ case 'organizations': {
+ // Picked ones in their order, else every listed one of its kind.
+ const ids = (block.items ?? []).map((item) => item.org_id).filter((id): id is string => Boolean(id))
+ if (ids.length === 0 && !block.org_kind) return null
+ return (
+
+ )
+ }
+
case 'people': {
const picked = (block.items ?? [])
.filter((item) => item.person)
diff --git a/src/lib/adminSchema/shared.ts b/src/lib/adminSchema/shared.ts
index 49e70b9..113332e 100644
--- a/src/lib/adminSchema/shared.ts
+++ b/src/lib/adminSchema/shared.ts
@@ -311,6 +311,7 @@ export const BLOCK_TYPES = [
["people", "People", "People tiles: a team's members, or people picked one by one as items (each with their title), or both."],
["map", "Map", "A venue's map with its locations marked and listed beside it (Data → Venues). A schedule on the same page with the same venue links its locations here."],
["events", "Events", "Event cards, eg. the workshops on offer: picture, type, date, title and card text, each linking to the event's page."],
+ ["organizations", "Organizations", "Organization cards, as on the Partners page: picked one by one as items, or every listed one of a kind."],
["divider", "Divider", "A thin line between parts."],
];
@@ -340,6 +341,8 @@ export const NOT_CARD_ITEM = { scope: "parent", path: "type", value: ["list", "l
export const PEOPLE_ITEM = { scope: "parent", path: "type", value: "people" };
/* An item that's an event card on an events block (088). */
export const EVENT_ITEM = { scope: "parent", path: "type", value: "events" };
+/* An item that's an organization on an organizations block (093). */
+export const ORG_ITEM = { scope: "parent", path: "type", value: "organizations" };
/* A venues option (the /admin/options query) as a Venue: its
locations arrive as JSON. */
@@ -529,6 +532,20 @@ export const blocksChild = {
when: { path: "type", value: TEXT_TYPES },
help: (row) => TEXT_HELP[row?.type],
},
+ {
+ path: "org_kind",
+ label: "List",
+ widget: "select",
+ options: [
+ ["partner", "Partners"],
+ ["region", "Regions"],
+ ["group", "Groups"],
+ ["ministry", "Ministries"],
+ ],
+ blankLabel: "Default: only the organizations picked below",
+ help: "Every published, listed one of this kind, by name. Organizations picked as items replace this list.",
+ when: { path: "type", value: "organizations" },
+ },
{
path: "list_style",
label: "Style",
@@ -637,7 +654,7 @@ export const blocksChild = {
key: "items",
label: "Items",
addLabel: "Add item",
- when: { path: "type", value: ["list", "links", "schedule", "cards", "people", "events"] },
+ when: { path: "type", value: ["list", "links", "schedule", "cards", "people", "events", "organizations"] },
title: (row) => [row.day, row.time || row.start_time, row.text].filter(Boolean).join(" · ") || "New item",
blank: { text: "" },
fields: [
@@ -687,12 +704,22 @@ export const blocksChild = {
help: "The event the card shows and links to. An unpublished one is left out.",
when: EVENT_ITEM,
},
+ {
+ path: "org_id",
+ label: "Organization",
+ widget: "select",
+ optionsFrom: "organizations",
+ fills: "text",
+ required: true,
+ help: "Shown as its card, in this order. An unpublished one is left out.",
+ when: ORG_ITEM,
+ },
eventField(SCHEDULE_ENTRY),
{
path: "text",
label: "Text",
required: true,
- help: "Schedules: the entry's title. Cards: the card's title. Events: the title shown, filled from the event. People: their title on the tile, eg. Speaker",
+ help: "Schedules: the entry's title. Cards: the card's title. Events: the title shown, filled from the event. People: their title on the tile, eg. Speaker. Organizations: filled from it, only the admin shows it",
},
placeField(SCHEDULE_ENTRY),
{
diff --git a/src/lib/useContent.ts b/src/lib/useContent.ts
index dc08f72..ebb747e 100644
--- a/src/lib/useContent.ts
+++ b/src/lib/useContent.ts
@@ -45,6 +45,7 @@ export type ContentBlock = {
| 'people'
| 'map'
| 'events'
+ | 'organizations'
text?: string | null
media?: string | null
href?: string | null
@@ -56,6 +57,8 @@ export type ContentBlock = {
cite?: string | null
/** A list block's style (092): null bold text, 'plain' the old look. */
list_style?: 'plain' | null
+ /** An organizations block's kind, listed when none are picked (093). */
+ org_kind?: 'region' | 'group' | 'partner' | 'ministry' | null
/** A video block's WebVTT file, for an uploaded video (066). */
captions?: string | null
items?: ContentBlockItem[]
@@ -138,6 +141,8 @@ export type ContentBlockItem = {
/** A featured event's heading and subheading (090). */
heading?: string | null
subheading?: string | null
+ /** An organizations block's organization (093). */
+ org_id?: string | null
/** A block entry's sub-items. */
items?: ContentBlockItem[]
/** Its block's tags it has, by key (087). */
diff --git a/src/pages/sections/OrgList-Card.tsx b/src/pages/sections/OrgList-Card.tsx
index fb6bb31..05837c4 100644
--- a/src/pages/sections/OrgList-Card.tsx
+++ b/src/pages/sections/OrgList-Card.tsx
@@ -19,6 +19,9 @@ import { useReadingMode } from '../../lib/readingMode.ts'
in that order
+ inside a content block (093):
+ no page gutter, names under
+ the block's heading
Where the vertical list expands in place, a card links out. The
card carries as much as fits at a glance and the organization's
@@ -123,11 +126,11 @@ function OrgCard({ org, accent, pageLabel, siteLabel, titled }) {
);
}
-function Block({ title, orgs, accent, pageLabel, siteLabel }) {
+function Block({ title, orgs, accent, pageLabel, siteLabel, nested = false }) {
if (orgs.length === 0) return null;
return (
-
+
{title && (
{title}
@@ -147,7 +150,7 @@ function Block({ title, orgs, accent, pageLabel, siteLabel }) {
accent={accent}
pageLabel={pageLabel}
siteLabel={siteLabel}
- titled={!!title}
+ titled={!!title || nested}
/>
))}
@@ -167,14 +170,30 @@ export default function OrgListCards({
siteLabel = "Visit site",
sort = byName,
empty = "Nothing to show here yet.",
+ nested = false,
+}: {
+ kind?: string | null;
+ ids?: string[];
+ title?: string;
+ groups?: Array<{ key: string; title: string; pageLabel?: string; siteLabel?: string }>;
+ groupBy?: (org: any) => unknown;
+ accent?: string;
+ pageLabel?: string;
+ siteLabel?: string;
+ sort?: ((a: any, b: any) => number) | null;
+ empty?: string;
+ nested?: boolean;
}) {
const { organizations, loading, error } = useOrganizations(kind, ids);
- const shell = children => (
-
- {children}
-
- );
+ const shell = children =>
+ nested ? (
+ {children}
+ ) : (
+
+ {children}
+
+ );
if (loading && organizations.length === 0) {
return shell(
@@ -214,6 +233,7 @@ export default function OrgListCards({
accent={accent}
pageLabel={pageLabel}
siteLabel={siteLabel}
+ nested={nested}
/>
);
}