Page updates: v1.10.3 to v1.10.6 #20

Merged
ngu-git-admin merged 19 commits from page-updates into main 2026-10-01 09:23:31 +01:00
29 changed files with 972 additions and 938 deletions
Showing only changes of commit 9daf7b1a4f - Show all commits

View file

@ -29,10 +29,11 @@ what a dropdown in the admin editor says.
| ------------------------------------------------------------ | ---------------- | ------------------------------------ | | ------------------------------------------------------------ | ---------------- | ------------------------------------ |
| A record: an event, organization, person, team, award, timeline entry | the database | editing it in the admin | | A record: an event, organization, person, team, award, timeline entry | the database | editing it in the admin |
| The front page's words, photos, bands, stats and paths | the database | Admin → Pages → Front page | | The front page's words, photos, bands, stats and paths | the database | Admin → Pages → Front page |
| Blog posts, and the Community page's blog section (headings, pins, feeds) | the database | Admin → Data → Blog posts, and Admin → Pages → Community blog section | | Blog posts, and the Community page's blog settings (headings, pins, feeds) | the database | Admin → Data → Blog posts, and Admin → Pages → Community |
| The sections of Retreats, Community, Resources, Organization and History: titles, blurbs, accents, their content blocks and presets (the blog, groups map, regions, partners, events, timeline, NGU's details) | the database | Admin → Pages → the page. A section title is 30 characters at most (it's listed in the side nav); a front page heading fits about 60. Preset names: `PRESETS` in `src/lib/adminSchema/sitePages.ts`, what each draws: `PRESETS` in `src/pages/SitePage.tsx` |
| The **label** a dropdown shows in the admin | code | [one file](#renaming-what-a-dropdown-shows) | | The **label** a dropdown shows in the admin | code | [one file](#renaming-what-a-dropdown-shows) |
| The **list of allowed values** behind a fixed dropdown | database CHECK + code | [a migration and three files](#adding-removing-or-renaming-a-stored-value) | | The **list of allowed values** behind a fixed dropdown | database CHECK + code | [a migration and three files](#adding-removing-or-renaming-a-stored-value) |
| Navigation, page section titles, colors, the site banner, history decades, the map grid | code | [the file named below](#other-content-that-lives-in-code) | | Navigation, colors, the site banner, history decades, the map grid | code | [the file named below](#other-content-that-lives-in-code) |
| A static page's title and intro (also its search title and description), the site's name, description, preview image, icons, search indexing, privacy contact email | the database, over `site.json` | Admin → Panel → Site settings (superadmins). Blank uses `site.json`, which also holds the site's address and the pages' defaults. See `docs/seo.md` | | A static page's title and intro (also its search title and description), the site's name, description, preview image, icons, search indexing, privacy contact email | the database, over `site.json` | Admin → Panel → Site settings (superadmins). Blank uses `site.json`, which also holds the site's address and the pages' defaults. See `docs/seo.md` |
| Uploaded images | disk + the `media` table | Admin → Tools → Media, or any image field. See `docs/media-uploads.md` | | Uploaded images | disk + the `media` table | Admin → Tools → Media, or any image field. See `docs/media-uploads.md` |
@ -185,7 +186,7 @@ also in `server/src/admin-schema/` and a CHECK):
| Front page → Feature | none, livestream, video, event | **yes** | `HeroStage.tsx`; the event is picked in `server/src/routes/home.js` | | Front page → Feature | none, livestream, video, event | **yes** | `HeroStage.tsx`; the event is picked in `server/src/routes/home.js` |
| Front page → Sections → Section | countdown, retreats, calendar, stats, timeline, connect, featured | **yes**, `FRONT_PAGE_SECTIONS` | `SECTIONS` in `src/pages/Home.tsx`; see [below](#front-page-section-names) | | Front page → Sections → Section | countdown, retreats, calendar, stats, timeline, connect, featured | **yes**, `FRONT_PAGE_SECTIONS` | `SECTIONS` in `src/pages/Home.tsx`; see [below](#front-page-section-names) |
| Front page → Stats → Number Source | manual, years_since, regions, … | **yes**, `STAT_SOURCES` | `STAT_QUERIES` in `server/src/routes/home.js`; see [below](#front-page-stat-sources) | | Front page → Stats → Number Source | manual, years_since, regions, … | **yes**, `STAT_SOURCES` | `STAT_QUERIES` in `server/src/routes/home.js`; see [below](#front-page-stat-sources) |
| Front page → Featured cards → Card type (Community blog section → Pinned community posts offers link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` | | Front page → Featured cards → Card type (Community → Community blog: pinned community posts offers link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` |
| Front page → Featured cards → Record type | event, organization, person, team, award | no | `FEATURED_REFS` in `server/src/shape.js` (what each fills the card with); the triggers in `030_featured_cards.sql` | | Front page → Featured cards → Record type | event, organization, person, team, award | no | `FEATURED_REFS` in `server/src/shape.js` (what each fills the card with); the triggers in `030_featured_cards.sql` |
| Every list → Published / Listed / Featured filter | 1, 0 | **yes** | n/a | | Every list → Published / Listed / Featured filter | 1, 0 | **yes** | n/a |
@ -201,7 +202,7 @@ code):
| Event → Scope (+ list filter); Front page → Countdown → Only this scope | `event_scopes` | the `event_scopes` table (migration only) | | Event → Scope (+ list filter); Front page → Countdown → Only this scope | `event_scopes` | the `event_scopes` table (migration only) |
| Event hosts → Organization; affiliations; team and award "Organization" / "Awarded by"; person → Home organization | `organizations` | organizations, labeled by name | | Event hosts → Organization; affiliations; team and award "Organization" / "Awarded by"; person → Home organization | `organizations` | organizations, labeled by name |
| Event hosts / event people / team members / timeline people → Person | `people` | people | | Event hosts / event people / team members / timeline people → Person | `people` | people |
| Community blog section → Pinned posts → Post | `blog_posts` | blog posts, newest first | | Community → Community blog: pinned posts (ours) → Post | `blog_posts` | blog posts, newest first |
| Timeline → Record; Featured cards → Record | `record_refs` | every event, organization, award, person and team, narrowed by the type picked beside it | | Timeline → Record; Featured cards → Record | `record_refs` | every event, organization, award, person and team, narrowed by the type picked beside it |
| Affiliations → Team | `teams` | teams, filtered to the chosen organization | | Affiliations → Team | `teams` | teams, filtered to the chosen organization |
| Person awards → Award | `awards` | awards, labeled "Award (Organization)" | | Person awards → Award | `awards` | awards, labeled "Award (Organization)" |
@ -219,7 +220,7 @@ each is changed in a different place:
| **The heading on the page** ("National Retreats", "What's on") | **Admin → Pages → Front page → Page sections → Heading.** Blank uses the default below. | | **The heading on the page** ("National Retreats", "What's on") | **Admin → Pages → Front page → Page sections → Heading.** Blank uses the default below. |
| The default heading when that field is blank | `SECTIONS` in `src/pages/Home.tsx`, the `title` of each entry | | The default heading when that field is blank | `SECTIONS` in `src/pages/Home.tsx`, the `title` of each entry |
| **The name in the admin's Section dropdown** ("Events Carousel (National Retreats)") | `FRONT_PAGE_SECTIONS` in `src/lib/adminSchema/frontPage.ts` | | **The name in the admin's Section dropdown** ("Events Carousel (National Retreats)") | `FRONT_PAGE_SECTIONS` in `src/lib/adminSchema/frontPage.ts` |
| The subnav links under the header ("#Retreats", "#Calendar") | `PAGE_SECTIONS["/"]` in `src/navConfig.ts` | | The links in the header's Home dropdown | the bands shown, under their headings (`src/lib/navSections.ts`) |
To rename a band **for visitors**, use the admin. To rename how it To rename a band **for visitors**, use the admin. To rename how it
reads **in the editor's dropdown**, edit `FRONT_PAGE_SECTIONS`: reads **in the editor's dropdown**, edit `FRONT_PAGE_SECTIONS`:
@ -267,8 +268,8 @@ The numbers band's "Number Source" dropdown works the same way:
| What | File | Notes | | What | File | Notes |
| --- | --- | --- | | --- | --- | --- |
| Header and footer navigation, each page's sections (the header dropdowns, mobile menu and footer site map) | `src/navConfig.ts` | `PAGE_LINKS` (order), `PAGE_SECTIONS`, `NAV_ACTIONS`. The front page's sections aren't listed there: they follow the bands it shows (Front page → Sections), through `src/lib/navSections.ts` and `src/lib/frontPageBands.ts` (each band's anchor and default heading). A new page also needs a route in `src/App.tsx`. | | Header and footer navigation, each page's sections (the header dropdowns, mobile menu and footer site map) | `src/navConfig.ts` | `PAGE_LINKS` (order), `NAV_ACTIONS`. Each page's sections aren't listed there: they follow the page itself, through `src/lib/navSections.ts` (the site pages' sections from Admin → Pages; the front page's bands it shows, with `src/lib/frontPageBands.ts` giving each band's anchor and default heading). A new page also needs a route in `src/App.tsx`. |
| Section titles, blurbs and colors on Retreats, Community, Organization, Resources, Feedback, Privacy, Terms | the page file in `src/pages/` | the `SECTIONS` array at the top. A section's `id` must match its subnav `hash`. | | Section titles, blurbs and colors on Feedback, Privacy, Terms | the page file in `src/pages/` | the `SECTIONS` array at the top. |
| Site-wide announcement banner | `src/data/bannerConfig.ts` | `enabled: false` hides it. Bump `id` when the message changes, so people who dismissed the old one see the new one. | | Site-wide announcement banner | `src/data/bannerConfig.ts` | `enabled: false` hides it. Bump `id` when the message changes, so people who dismissed the old one see the new one. |
| History page decade headers | `src/data/historyDecades.ts` | Title, tagline and blurb per decade. | | History page decade headers | `src/data/historyDecades.ts` | Title, tagline and blurb per decade. |
| Group map tiles and area names | `src/data/mapGrid.ts` | `AREAS` (tile positions) and `AREA_NAMES`. Which region paints which tile is in the database (Admin → Data → Organizations → a region → Map areas). | | Group map tiles and area names | `src/data/mapGrid.ts` | `AREAS` (tile positions) and `AREA_NAMES`. Which region paints which tile is in the database (Admin → Data → Organizations → a region → Map areas). |

View file

@ -236,15 +236,13 @@ function readChildren(db, child, ownerId) {
) )
.all(...params); .all(...params);
// Nested collections, to any depth: a page's sections, each
// section's blocks, each block's items. The id goes as text: a JS
// number binds as REAL, which a TEXT owner column (a section's
// blocks) holds as '13.0'; text suits an INTEGER owner just as well.
for (const child2 of child.children ?? []) { for (const child2 of child.children ?? []) {
for (const row of rows) { for (const row of rows) {
row[child2.key] = db row[child2.key] = readChildren(db, child2, String(row.id));
.prepare(
`SELECT * FROM ${child2.table}
WHERE ${child2.owner.column} = ?
ORDER BY ${child2.order}`,
)
.all(row.id);
} }
} }
@ -378,6 +376,14 @@ export function updateRow(db, entity, rawId, payload) {
`UPDATE ${entity.table} SET ${sets.join(", ")} `UPDATE ${entity.table} SET ${sets.join(", ")}
WHERE ${entity.idColumn} = ?`, WHERE ${entity.idColumn} = ?`,
).run(...Object.values(values), id); ).run(...Object.values(values), id);
} else if (entity.concurrency) {
// A row that is only its collections (a site page and its
// sections) still marks the save, or the next stale save
// would pass the check above.
db.prepare(
`UPDATE ${entity.table} SET ${entity.concurrency} = datetime('now')
WHERE ${entity.idColumn} = ?`,
).run(id);
} }
writeExtensions(db, entity, id, payload, merged); writeExtensions(db, entity, id, payload, merged);
@ -516,8 +522,17 @@ function writeChildren(db, entity, id, payload, parentValues) {
if (payload[child.key] === undefined) continue; // not sent, not touched if (payload[child.key] === undefined) continue; // not sent, not touched
deleteChildren(db, child, id); deleteChildren(db, child, id);
writeRows(db, child, id, payload[child.key], `${child.key}.`, parentValues);
}
}
const incoming = Array.isArray(payload[child.key]) ? payload[child.key] : []; /* One collection's rows under one owner, then each row's own nested
collections under it, to any depth. Only the top level is deleted
first (writeChildren): a nested row goes with its owner, by a
foreign key's cascade or, for a polymorphic owner like a section's
blocks, by the owner table's cleanup trigger. */
function writeRows(db, child, ownerId, incomingRaw, prefix, parentValues) {
const incoming = Array.isArray(incomingRaw) ? incomingRaw : [];
// index is the row's place in what the client sent, so a // index is the row's place in what the client sent, so a
// validation error still points at the row the user is looking // validation error still points at the row the user is looking
@ -528,15 +543,14 @@ function writeChildren(db, entity, id, payload, parentValues) {
.filter(({ raw }) => child.allowBlank || !isBlankChildRow(child, raw)); .filter(({ raw }) => child.allowBlank || !isBlankChildRow(child, raw));
rows.forEach(({ raw, index }, position) => { rows.forEach(({ raw, index }, position) => {
const { values, errors } = coerceRow(child.columns, raw, { const rowPrefix = `${prefix}${index}.`;
prefix: `${child.key}.${index}.`, const { values, errors } = coerceRow(child.columns, raw, { prefix: rowPrefix });
});
if (Object.keys(errors).length) { if (Object.keys(errors).length) {
throw new HttpError(422, "Validation failed", errors); throw new HttpError(422, "Validation failed", errors);
} }
const names = [child.owner.column, ...Object.keys(values)]; const names = [child.owner.column, ...Object.keys(values)];
const params = [id, ...Object.values(values)]; const params = [ownerId, ...Object.values(values)];
if (child.owner.kindColumn) { if (child.owner.kindColumn) {
names.push(child.owner.kindColumn); names.push(child.owner.kindColumn);
@ -545,14 +559,14 @@ function writeChildren(db, entity, id, payload, parentValues) {
for (const [column, from] of Object.entries(child.owner.inherit ?? {})) { for (const [column, from] of Object.entries(child.owner.inherit ?? {})) {
if (names.includes(column)) continue; if (names.includes(column)) continue;
names.push(column); names.push(column);
params.push(parentValues[from] ?? id); params.push(parentValues[from] ?? ownerId);
} }
if (child.order === "sort_order" && !names.includes("sort_order")) { if (child.order === "sort_order" && !names.includes("sort_order")) {
names.push("sort_order"); names.push("sort_order");
params.push(position); params.push(position);
} }
const result = keyedDbErrors(`${child.key}.${index}.`, () => const result = keyedDbErrors(rowPrefix, () =>
db db
.prepare( .prepare(
`INSERT INTO ${child.table} (${names.join(", ")}) `INSERT INTO ${child.table} (${names.join(", ")})
@ -562,34 +576,9 @@ function writeChildren(db, entity, id, payload, parentValues) {
); );
for (const child2 of child.children ?? []) { for (const child2 of child.children ?? []) {
const incomingNested = Array.isArray(raw[child2.key]) ? raw[child2.key] : []; writeRows(db, child2, String(result.lastInsertRowid), raw[child2.key], `${rowPrefix}${child2.key}.`, values);
const nested = incomingNested
.map((rawItem, i) => ({ rawItem, i }))
.filter(({ rawItem }) => child2.allowBlank || !isBlankChildRow(child2, rawItem));
nested.forEach(({ rawItem, i }, nestedPosition) => {
const item = coerceRow(child2.columns, rawItem, {
prefix: `${child.key}.${index}.${child2.key}.${i}.`,
});
if (Object.keys(item.errors).length) {
throw new HttpError(422, "Validation failed", item.errors);
}
const itemNames = [child2.owner.column, ...Object.keys(item.values)];
const itemParams = [result.lastInsertRowid, ...Object.values(item.values)];
if (!itemNames.includes("sort_order")) {
itemNames.push("sort_order");
itemParams.push(nestedPosition);
}
db.prepare(
`INSERT INTO ${child2.table} (${itemNames.join(", ")})
VALUES (${itemNames.map(() => "?").join(", ")})`,
).run(...itemParams);
});
} }
}); });
}
} }
function deleteChildren(db, child, ownerId) { function deleteChildren(db, child, ownerId) {

View file

@ -49,9 +49,15 @@ import { teams } from "./admin-schema/teams.js";
import { awards } from "./admin-schema/awards.js"; import { awards } from "./admin-schema/awards.js";
import { timeline } from "./admin-schema/timeline.js"; import { timeline } from "./admin-schema/timeline.js";
import { frontPage } from "./admin-schema/frontPage.js"; import { frontPage } from "./admin-schema/frontPage.js";
import { blogPosts, communityPage } from "./admin-schema/blog.js"; import { blogPosts } from "./admin-schema/blog.js";
import { siteSettings } from "./admin-schema/siteSettings.js"; import { siteSettings } from "./admin-schema/siteSettings.js";
import { organizationPage } from "./admin-schema/organizationPage.js"; import {
communityPage,
retreatsPage,
resourcesPage,
organizationPage,
historyPage,
} from "./admin-schema/sitePages.js";
export const ENTITIES = { export const ENTITIES = {
organizations, organizations,
@ -63,7 +69,10 @@ export const ENTITIES = {
front_page: frontPage, front_page: frontPage,
blog_posts: blogPosts, blog_posts: blogPosts,
community_page: communityPage, community_page: communityPage,
retreats_page: retreatsPage,
resources_page: resourcesPage,
organization_page: organizationPage, organization_page: organizationPage,
history_page: historyPage,
site_settings: siteSettings, site_settings: siteSettings,
}; };

View file

@ -1,11 +1,10 @@
import { text, url, int, bool, date, featuredCardsChild, blocksChild } from "./columns.js"; import { text, bool, date, blocksChild } from "./columns.js";
/* ── Blog (031_blog.sql) ───────────────────────────────────────── /* ── Blog (031_blog.sql) ─────────────────────────────────────────
Posts of our own, with a content-block body and people as Posts of our own, with a content-block body and people as
authors, and the Community page's blog section, a singleton like authors. The Community page's blog section is edited with that
the front page. The section's community posts are featured cards page (sitePages.js). ──────────────────────────────────────── */
owned by 'community_page'. ─────────────────────────────────── */
export const blogPosts = { export const blogPosts = {
key: "blog_posts", key: "blog_posts",
@ -46,48 +45,3 @@ export const blogPosts = {
blocksChild("blog_post"), blocksChild("blog_post"),
], ],
}; };
export const communityPage = {
key: "community_page",
table: "community_page",
idColumn: "id",
idKind: "slug",
singleton: "community",
concurrency: "updated_at",
list: {
columns: ["id", "blog_title", "updated_at"],
filters: [],
search: [],
order: "id",
},
columns: [
text("blog_title"),
text("blog_blurb"),
text("internal_title"),
int("internal_slots"),
text("external_title"),
int("external_slots"),
url("external_url"),
text("external_label"),
],
children: [
{
key: "pinned_posts",
table: "community_page_pinned_posts",
owner: { column: "page_id" },
order: "sort_order",
columns: [text("post_id", { required: true })],
},
featuredCardsChild("community_page"),
{
key: "feeds",
table: "community_page_feeds",
owner: { column: "page_id" },
order: "sort_order",
columns: [url("url", { required: true }), text("label")],
},
],
};

View file

@ -1,43 +0,0 @@
/* The Organization page (/organization): one row, its blocks and its
volunteering links (055_organization_page.sql). Two block
collections, each its own owner kind, so the editor shows them
apart: the Mission, Vision & Values section, and the Leadership
section (a People block per team, in order). */
import { text, url, blocksChild } from "./columns.js";
export const organizationPage = {
key: "organization_page",
table: "organization_page",
idColumn: "id",
idKind: "slug",
singleton: "organization",
concurrency: "updated_at",
list: {
columns: ["id", "updated_at"],
filters: [],
search: [],
order: "id",
},
columns: [
text("mission_title"),
text("leadership_title"),
text("leadership_blurb"),
text("volunteer_title"),
text("volunteer_blurb"),
],
children: [
{ ...blocksChild("org_page_mission"), key: "mission_blocks" },
{ ...blocksChild("org_page_leadership"), key: "leadership_blocks" },
{
key: "volunteer_links",
table: "organization_page_links",
owner: { column: "page_id" },
order: "sort_order",
columns: [text("label", { required: true }), url("url", { required: true })],
},
],
};

View file

@ -0,0 +1,95 @@
import { text, url, int, enumeration, featuredCardsChild, blocksChild } from "./columns.js";
/* ── The site's own pages (056_site_pages.sql) ───────────────────
Community, Retreats, Resources, Organization and History: one
site_pages row each, edited as its own singleton, with its
sections nested under it and each section's blocks under that
(the blocks' items under them, as on any record). A section is
either its blocks or a preset, a prebuilt part of the site
(SitePage.tsx draws both).
Community also carries the blog section's settings: the
community_page row (same id) as an extension, and its pinned
posts, cards and feeds, all owned by that id. */
const sectionsChild = {
key: "sections",
table: "page_sections",
owner: { column: "page_id" },
order: "sort_order",
columns: [
text("anchor", { required: true }),
text("title", { required: true }),
text("blurb"),
enumeration("accent", ["teal", "deep", "green", "amber"]),
enumeration("preset", [
"community_blog",
"group_map",
"region_list",
"partner_list",
"events",
"timeline",
"organization_details",
]),
text("scope_id"),
enumeration("event_type", ["retreat", "class", "workshop", "meeting", "other"]),
enumeration("view", ["carousel", "grid", "map"]),
],
children: [blocksChild("page_section")],
};
const sitePage = (id, more = {}) => ({
key: `${id}_page`,
table: "site_pages",
idColumn: "id",
idKind: "slug",
singleton: id,
concurrency: "updated_at",
list: { columns: ["id", "updated_at"], filters: [], search: [], order: "id" },
columns: [],
...more,
children: [sectionsChild, ...(more.children ?? [])],
});
export const communityPage = sitePage("community", {
extensions: [
{
key: "blog",
table: "community_page",
idColumn: "id",
columns: [
text("internal_title"),
int("internal_slots"),
text("external_title"),
int("external_slots"),
url("external_url"),
text("external_label"),
],
},
],
children: [
{
key: "pinned_posts",
table: "community_page_pinned_posts",
owner: { column: "page_id" },
order: "sort_order",
columns: [text("post_id", { required: true })],
},
featuredCardsChild("community_page"),
{
key: "feeds",
table: "community_page_feeds",
owner: { column: "page_id" },
order: "sort_order",
columns: [url("url", { required: true }), text("label")],
},
],
});
export const retreatsPage = sitePage("retreats");
export const resourcesPage = sitePage("resources");
export const organizationPage = sitePage("organization");
export const historyPage = sitePage("history");

View file

@ -26,7 +26,7 @@ import history from "./routes/history.js";
import home from "./routes/home.js"; import home from "./routes/home.js";
import directory from "./routes/directory.js"; import directory from "./routes/directory.js";
import blog from "./routes/blog.js"; import blog from "./routes/blog.js";
import organizationPage from "./routes/organizationPage.js"; import sitePages from "./routes/sitePages.js";
import pages from "./routes/pages.js"; import pages from "./routes/pages.js";
import feedback from "./routes/feedback.js"; import feedback from "./routes/feedback.js";
import requests from "./routes/requests.js"; import requests from "./routes/requests.js";
@ -170,7 +170,7 @@ app.route("/api", history);
app.route("/api", home); app.route("/api", home);
app.route("/api", directory); app.route("/api", directory);
app.route("/api", blog); app.route("/api", blog);
app.route("/api", organizationPage); app.route("/api", sitePages);
// Tighter limit on the write path than anything else gets. // Tighter limit on the write path than anything else gets.
app.use("/api/feedback", rateLimit({ windowMs: 60_000, max: 5 })); app.use("/api/feedback", rateLimit({ windowMs: 60_000, max: 5 }));

View file

@ -0,0 +1,221 @@
-- ═══════════════════════════════════════════════════════════════
-- 056 PAGE EDITORS: SECTIONS FOR THE SITE'S OWN PAGES
--
-- Community, Retreats, Resources, Organization and History are
-- built in the admin (Pages → each page) as a list of sections. A
-- section is its title (30 characters at most: it's listed in the
-- page's side nav), an optional blurb, an accent and the anchor it
-- sits at, and then either
--
-- its own content blocks content_blocks owned 'page_section',
-- owner_id the section's id
-- a preset a prebuilt part of the site, drawn by
-- the page (SitePage.tsx): the Community
-- blog, the group map, the region list,
-- the partner cards, an event list (scope,
-- type and the view it opens in), the
-- timeline, NGU's address and tax details
--
-- Every page's sections are seeded as the code drew them, so nothing
-- moves on the site. Organization takes what 055's editor held: its
-- Mission and Leadership blocks, with the Volunteering title, blurb
-- and links appended to the Leadership section as a heading, a
-- paragraph and link buttons; 055's tables go.
--
-- The Community blog's own settings (its slots, pinned posts, feeds)
-- stay in community_page, now edited inside the Community page
-- editor; its heading and blurb become the blog section's own, so
-- community_page loses blog_title and blog_blurb.
--
-- content_blocks is rebuilt for its owner_kind CHECK (as 055 did),
-- moving 055's blocks across on the way. A section deleted (every
-- save rewrites them) takes its blocks with it, by trigger, since
-- the owner is polymorphic and can't be a foreign key.
-- ═══════════════════════════════════════════════════════════════
CREATE TABLE site_pages (
id TEXT PRIMARY KEY
CHECK (id IN ('community', 'retreats', 'resources', 'organization', 'history')),
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
) STRICT;
INSERT INTO site_pages (id) VALUES ('community'), ('retreats'), ('resources'), ('organization'), ('history');
CREATE TABLE page_sections (
id INTEGER PRIMARY KEY AUTOINCREMENT,
page_id TEXT NOT NULL REFERENCES site_pages (id) ON DELETE CASCADE,
sort_order INTEGER NOT NULL DEFAULT 0,
anchor TEXT NOT NULL
CONSTRAINT "A section's URL ID can use only lowercase letters, numbers and hyphens, eg. leadership."
CHECK (anchor <> '' AND anchor NOT GLOB '*[^a-z0-9-]*'),
title TEXT NOT NULL
CONSTRAINT "A section title can be 30 characters at most (it's listed in the page's side nav)."
CHECK (length(title) <= 30),
blurb TEXT,
accent TEXT CHECK (accent IN ('teal', 'deep', 'green', 'amber')),
preset TEXT CHECK (preset IN ('community_blog', 'group_map', 'region_list', 'partner_list',
'events', 'timeline', 'organization_details')),
-- An events preset's filter and first view.
scope_id TEXT REFERENCES event_scopes (id) ON DELETE SET NULL,
event_type TEXT CHECK (event_type IN ('retreat', 'class', 'workshop', 'meeting', 'other')),
view TEXT CHECK (view IN ('carousel', 'grid', 'map')),
UNIQUE (page_id, anchor)
) STRICT;
CREATE INDEX page_sections_page_idx ON page_sections (page_id, sort_order);
INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view)
SELECT 'community', 0, 'blog', COALESCE(blog_title, 'Community Blog'), blog_blurb, 'teal', 'community_blog', NULL, NULL, NULL
FROM community_page WHERE id = 'community';
INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view) VALUES
('community', 1, 'groups', 'Local Groups',
'Young adult groups meeting in person and online across the movement.', 'teal', 'group_map', NULL, NULL, 'map'),
('community', 2, 'regions', 'Unity Regions',
'The regional organizations that support groups and host their own gatherings.', 'deep', 'region_list', NULL, NULL, NULL),
('community', 3, 'partners', 'Partner Organizations',
'Organizations we collaborate with across the Unity movement and beyond.', 'amber', 'partner_list', NULL, NULL, NULL),
('retreats', 0, 'national', 'National Retreats',
'Our flagship gatherings, open to young adults across the country.', 'teal', 'events', 'national', 'retreat', 'carousel'),
('retreats', 1, 'regional', 'Regional Retreats',
'Smaller gatherings hosted by regions throughout the year.', 'green', 'events', 'regional', 'retreat', 'grid'),
('retreats', 2, 'partner', 'Partner Events',
'Retreats hosted by organizations we collaborate with.', 'amber', 'events', 'partner', 'retreat', 'grid'),
('resources', 0, 'unity', 'Unity Teachings',
'Core principles, readings, and study material from the Unity movement.', 'teal', NULL, NULL, NULL, NULL),
('resources', 1, 'branding', 'Branding & Marketing',
'Logos, colors, templates, and guidelines for representing NGU.', 'green', NULL, NULL, NULL, NULL),
('resources', 2, 'partner', 'Partner Resources',
'Material for the organizations we collaborate with.', 'amber', NULL, NULL, NULL, NULL),
('history', 0, 'timeline', 'NGU Timeline', 'Open a year to see what happened.', 'teal', 'timeline', NULL, NULL, NULL),
('organization', 2, 'contact', 'Details & Contact', NULL, 'deep', 'organization_details', NULL, NULL, NULL);
INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, accent)
SELECT 'organization', 0, 'mission', substr(COALESCE(mission_title, 'Mission, Vision & Values'), 1, 30), NULL, 'teal'
FROM organization_page WHERE id = 'organization';
INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, accent)
SELECT 'organization', 1, 'leadership', substr(COALESCE(leadership_title, 'Leadership'), 1, 30), leadership_blurb, 'green'
FROM organization_page WHERE id = 'organization';
ALTER TABLE community_page DROP COLUMN blog_title;
ALTER TABLE community_page DROP COLUMN blog_blurb;
-- ── Blocks: the new owner kind, 055's blocks moved across ──────
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')),
owner_id TEXT NOT NULL,
slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body')),
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')),
text TEXT,
media TEXT,
href TEXT,
alt TEXT,
cite TEXT,
team_id TEXT REFERENCES teams (id) ON DELETE SET NULL
) STRICT;
INSERT INTO content_blocks_new
(id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id)
SELECT b.id,
CASE WHEN b.owner_kind IN ('org_page_mission', 'org_page_leadership') THEN 'page_section' ELSE b.owner_kind END,
CASE b.owner_kind
WHEN 'org_page_mission' THEN
(SELECT CAST(s.id AS TEXT) FROM page_sections s WHERE s.page_id = 'organization' AND s.anchor = 'mission')
WHEN 'org_page_leadership' THEN
(SELECT CAST(s.id AS TEXT) FROM page_sections s WHERE s.page_id = 'organization' AND s.anchor = 'leadership')
ELSE b.owner_id
END,
b.slot, b.sort_order, b.type, b.text, b.media, b.href, b.alt, b.cite, b.team_id
FROM content_blocks b;
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);
-- Volunteering, appended to the Leadership section where 055 had it.
INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text)
SELECT 'page_section', CAST(s.id AS TEXT), 'body', 1000, 'heading', COALESCE(p.volunteer_title, 'Volunteering')
FROM organization_page p
JOIN page_sections s ON s.page_id = 'organization' AND s.anchor = 'leadership'
WHERE p.volunteer_title IS NOT NULL OR p.volunteer_blurb IS NOT NULL
OR EXISTS (SELECT 1 FROM organization_page_links);
INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text)
SELECT 'page_section', CAST(s.id AS TEXT), 'body', 1001, 'paragraph', p.volunteer_blurb
FROM organization_page p
JOIN page_sections s ON s.page_id = 'organization' AND s.anchor = 'leadership'
WHERE p.volunteer_blurb IS NOT NULL;
INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type)
SELECT 'page_section', CAST(s.id AS TEXT), 'body', 1002, 'links'
FROM page_sections s
WHERE s.page_id = 'organization' AND s.anchor = 'leadership'
AND EXISTS (SELECT 1 FROM organization_page_links);
INSERT INTO content_block_items (block_id, sort_order, text, url)
SELECT b.id, l.sort_order, l.label, l.url
FROM organization_page_links l
JOIN content_blocks b ON b.owner_kind = 'page_section' AND b.type = 'links' AND b.sort_order = 1002;
DROP TABLE organization_page_links;
DROP TABLE organization_page;
-- ── Triggers last (see CLAUDE.md, Migrations) ──
CREATE TRIGGER site_pages_touch
AFTER UPDATE ON site_pages
FOR EACH ROW WHEN new.updated_at = old.updated_at
BEGIN
UPDATE site_pages SET updated_at = datetime('now') WHERE id = new.id;
END;
CREATE TRIGGER page_sections_cleanup
AFTER DELETE ON page_sections
BEGIN
DELETE FROM content_blocks WHERE owner_kind = 'page_section' AND owner_id = CAST(old.id AS TEXT);
END;
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')
END;
END;

View file

@ -191,8 +191,6 @@ blog.get("/community-blog", async (c) => {
return json(c, { return json(c, {
community_blog: { community_blog: {
title: page.blog_title,
blurb: page.blog_blurb,
internal: { internal: {
title: page.internal_title, title: page.internal_title,
posts: posts.map((row) => posts: posts.map((row) =>

View file

@ -1,43 +0,0 @@
/* ═══════════════════════════════════════════════════════════════
ORGANIZATION PAGE ROUTE: read-only, mounted under /api
GET /organization-page the Organization page's own content:
its section titles, the Mission and
Leadership blocks, and Volunteering
(title, blurb, links)
Edited in the admin as Pages → Organization page
(admin-schema/organizationPage.js). The blocks are shaped as on
any record page (loadBlocks), so ContentBlocks draws them.
═══════════════════════════════════════════════════════════════ */
import { Hono } from "hono";
import { json, loadBlocks } from "../shape.js";
const ID = "organization";
const organizationPage = new Hono();
organizationPage.get("/organization-page", (c) => {
const db = c.get("db");
const row = db.prepare(`SELECT * FROM organization_page WHERE id = ?`).get(ID) ?? {};
const links = db
.prepare(`SELECT label, url FROM organization_page_links WHERE page_id = ? ORDER BY sort_order, id`)
.all(ID);
return json(c, {
page: {
mission_title: row.mission_title ?? null,
mission_blocks: loadBlocks(db, "org_page_mission", [ID]).get(ID) ?? [],
leadership_title: row.leadership_title ?? null,
leadership_blurb: row.leadership_blurb ?? null,
leadership_blocks: loadBlocks(db, "org_page_leadership", [ID]).get(ID) ?? [],
volunteer: {
title: row.volunteer_title ?? null,
blurb: row.volunteer_blurb ?? null,
links,
},
},
});
});
export default organizationPage;

View file

@ -0,0 +1,57 @@
/* ═══════════════════════════════════════════════════════════════
SITE PAGE ROUTES: read-only, mounted under /api
GET /site-pages every site page's section headings, for
the header's dropdowns and the side nav
GET /site-pages/:id one page's sections, in order: heading,
accent, preset (and an events preset's
filter and view), and its blocks
Edited in the admin as Pages → each page
(admin-schema/sitePages.js). Blocks are shaped as on any record
page (loadBlocks), so ContentBlocks draws them.
═══════════════════════════════════════════════════════════════ */
import { Hono } from "hono";
import { json, loadBlocks } from "../shape.js";
const sitePages = new Hono();
sitePages.get("/site-pages", (c) => {
const rows = c
.get("db")
.prepare(`SELECT page_id, anchor, title FROM page_sections ORDER BY page_id, sort_order, id`)
.all();
const pages = {};
for (const row of rows) (pages[row.page_id] ??= []).push({ anchor: row.anchor, title: row.title });
return json(c, { pages });
});
sitePages.get("/site-pages/:id", (c) => {
const db = c.get("db");
const id = c.req.param("id");
if (!db.prepare(`SELECT 1 FROM site_pages WHERE id = ?`).get(id)) {
return c.json({ error: "No such page." }, 404);
}
const rows = db
.prepare(
`SELECT id, anchor, title, blurb, accent, preset, scope_id, event_type, view
FROM page_sections WHERE page_id = ? ORDER BY sort_order, id`,
)
.all(id);
const blocks = loadBlocks(db, "page_section", rows.map((row) => String(row.id)));
return json(c, {
page: {
id,
sections: rows.map(({ id: sectionId, ...section }) => ({
...section,
blocks: blocks.get(String(sectionId)) ?? [],
})),
},
});
});
export default sitePages;

View file

@ -49,11 +49,9 @@ const lazyPage = (load) =>
throw err throw err
}), }),
) )
const Retreats = lazyPage(() => import("./pages/Retreats.tsx")) // Community, Retreats, Resources, Organization and History: each
const Community = lazyPage(() => import("./pages/Community.tsx")) // built in the admin from sections.
const Organization = lazyPage(() => import("./pages/Organization.tsx")) const SitePage = lazyPage(() => import("./pages/SitePage.tsx"))
const Resources = lazyPage(() => import("./pages/Resources.tsx"))
const History = lazyPage(() => import("./pages/History.tsx"))
const Feedback = lazyPage(() => import("./pages/Feedback.tsx")) const Feedback = lazyPage(() => import("./pages/Feedback.tsx"))
const Request = lazyPage(() => import("./pages/Request.tsx")) const Request = lazyPage(() => import("./pages/Request.tsx"))
const Giving = lazyPage(() => import("./pages/Giving.tsx")) const Giving = lazyPage(() => import("./pages/Giving.tsx"))
@ -91,9 +89,9 @@ export default function App() {
{/* Layout renders the nav once and swaps page content into <Outlet /> */} {/* Layout renders the nav once and swaps page content into <Outlet /> */}
<Route element={<Layout />}> <Route element={<Layout />}>
<Route index element={<Home />} /> <Route index element={<Home />} />
<Route path="retreats" element={<Retreats />} /> <Route path="retreats" element={<SitePage key="retreats" id="retreats" />} />
<Route path="/events/:id" element={<EventDetail />} /> <Route path="/events/:id" element={<EventDetail />} />
<Route path="community" element={<Community />} /> <Route path="community" element={<SitePage key="community" id="community" />} />
<Route path="/regions/:id" element={<OrganizationDetail />} /> <Route path="/regions/:id" element={<OrganizationDetail />} />
<Route path="/groups/:id" element={<OrganizationDetail />} /> <Route path="/groups/:id" element={<OrganizationDetail />} />
<Route path="/partners/:id" element={<OrganizationDetail />} /> <Route path="/partners/:id" element={<OrganizationDetail />} />
@ -102,9 +100,9 @@ export default function App() {
<Route path="/awards/:id" element={<AwardDetail />} /> <Route path="/awards/:id" element={<AwardDetail />} />
<Route path="/people/:id" element={<PersonDetail />} /> <Route path="/people/:id" element={<PersonDetail />} />
<Route path="/blog/:id" element={<BlogPost />} /> <Route path="/blog/:id" element={<BlogPost />} />
<Route path="organization" element={<Organization />} /> <Route path="organization" element={<SitePage key="organization" id="organization" />} />
<Route path="resources" element={<Resources />} /> <Route path="resources" element={<SitePage key="resources" id="resources" />} />
<Route path="history" element={<History />} /> <Route path="history" element={<SitePage key="history" id="history" />} />
<Route path="feedback" element={<Feedback />} /> <Route path="feedback" element={<Feedback />} />
<Route path="request" element={<Request />} /> <Route path="request" element={<Request />} />
<Route path="qr" element={<QrCodes />} /> <Route path="qr" element={<QrCodes />} />

View file

@ -25,9 +25,15 @@ import { teams } from "./adminSchema/teams.ts";
import { awards } from "./adminSchema/awards.ts"; import { awards } from "./adminSchema/awards.ts";
import { timeline } from "./adminSchema/timeline.ts"; import { timeline } from "./adminSchema/timeline.ts";
import { frontPage } from "./adminSchema/frontPage.ts"; import { frontPage } from "./adminSchema/frontPage.ts";
import { blogPosts, communityPage } from "./adminSchema/blog.ts"; import { blogPosts } from "./adminSchema/blog.ts";
import { siteSettings } from "./adminSchema/siteSettings.ts"; import { siteSettings } from "./adminSchema/siteSettings.ts";
import { organizationPage } from "./adminSchema/organizationPage.ts"; import {
communityPage,
retreatsPage,
resourcesPage,
organizationPage,
historyPage,
} from "./adminSchema/sitePages.ts";
export const ADMIN_ENTITIES: Record<string, any> = { export const ADMIN_ENTITIES: Record<string, any> = {
organizations, organizations,
@ -39,7 +45,10 @@ export const ADMIN_ENTITIES: Record<string, any> = {
front_page: frontPage, front_page: frontPage,
blog_posts: blogPosts, blog_posts: blogPosts,
community_page: communityPage, community_page: communityPage,
retreats_page: retreatsPage,
resources_page: resourcesPage,
organization_page: organizationPage, organization_page: organizationPage,
history_page: historyPage,
site_settings: siteSettings, site_settings: siteSettings,
}; };

View file

@ -1,12 +1,9 @@
import { preview } from "../text.ts";
import { mediaUrl } from "../media.ts"; import { mediaUrl } from "../media.ts";
import { PUBLISHED_FIELD, LISTED_FIELD, FEATURED_KINDS, featuredCardsChild, blocksChild } from "./shared.ts"; import { PUBLISHED_FIELD, LISTED_FIELD, blocksChild } from "./shared.ts";
/* ── Blog (031_blog.sql) ───────────────────────────────────────── /* ── Blog (031_blog.sql) ─────────────────────────────────────────
Posts at /blog/:id, and the Community page's blog section. The Posts at /blog/:id. The Community page's blog section is edited
section's community posts reuse the featured cards, limited to with that page (sitePages.ts). */
links: a pinned Substack post is a link card, and Fetch preview
fills it from the post. */
/* A post's body is the content blocks without the card/body choice: /* A post's body is the content blocks without the card/body choice:
a post only has a body. */ a post only has a body. */
@ -106,87 +103,3 @@ export const blogPosts = {
blogBlocksChild, blogBlocksChild,
], ],
}; };
export const communityPage = {
key: "community_page",
label: "Community blog section",
singular: "community blog section",
idLabel: "Page",
singleton: "community",
list: { columns: [], filters: [] },
groups: [
{
legend: "Section",
note: "The first section of the Community page.",
fields: [
{ path: "blog_title", label: "Heading", help: "Default: Community Blog" },
{ path: "blog_blurb", label: "Blurb", widget: "textarea", full: true },
],
},
{
legend: "Our posts",
note: "Pinned posts first, then the newest published, listed posts, up to the number of slots.",
fields: [
{ path: "internal_title", label: "Heading", help: "Default: From NGU" },
{ path: "internal_slots", label: "Slots", widget: "number", help: "0 to 12. Default: 3" },
],
},
{
legend: "Community posts",
note: "Pinned cards first, then the newest items from the feeds below, up to the number of slots.",
fields: [
{ path: "external_title", label: "Heading", help: "Default: From our community" },
{ path: "external_slots", label: "Slots", widget: "number", help: "0 to 12. Default: 3" },
{ path: "external_url", label: "Button link", help: "eg. https://ngu.substack.com", full: true },
{ path: "external_label", label: "Button text", help: "Default: Read more on Substack" },
],
},
],
children: [
{
key: "pinned_posts",
label: "Pinned posts (ours)",
note: "Always shown, before the newest.",
addLabel: "Pin a post",
title: (row, options) =>
options?.blog_posts?.find((p) => p.id === row.post_id)?.label ?? "New pin",
blank: { post_id: "" },
fields: [
{
path: "post_id",
label: "Post",
widget: "select",
optionsFrom: "blog_posts",
required: true,
},
],
},
{
...featuredCardsChild,
label: "Pinned community posts",
note: "Always shown, before the feeds' newest. Paste a post's link and press Fetch preview.",
addLabel: "Pin a post",
blank: { kind: "", url: "", title: "" },
fields: featuredCardsChild.fields.map((field) =>
field.path === "kind"
? { ...field, options: FEATURED_KINDS.filter(([kind]) => kind !== "record") }
: field,
),
},
{
key: "feeds",
label: "Feeds",
note: "RSS or Atom feeds whose newest posts fill the community slots. Read about every 30 minutes.",
addLabel: "Add feed",
title: (row) => row.label || row.url || "New feed",
blank: { url: "", label: "" },
fields: [
{ path: "url", label: "Feed URL", required: true, full: true, help: "eg. https://ngu.substack.com/feed" },
{ path: "label", label: "Source name", help: "Shown on its cards. Default: the feed's own title" },
],
},
],
};

View file

@ -173,7 +173,7 @@ export const frontPage = {
options: FRONT_PAGE_SECTIONS, options: FRONT_PAGE_SECTIONS,
required: true, required: true,
}, },
{ path: "title", label: "Heading", help: "Heading Override" }, { path: "title", label: "Heading", help: "Default: the band's own name. Up to about 60 characters fit." },
{ path: "blurb", label: "Blurb", full: true }, { path: "blurb", label: "Blurb", full: true },
{ path: "is_hidden", label: "Hidden", widget: "checkbox", help: "Hide for now" }, { path: "is_hidden", label: "Hidden", widget: "checkbox", help: "Hide for now" },
], ],

View file

@ -1,71 +0,0 @@
/* Pages → Organization page: the /organization page's own content.
Server side: server/src/admin-schema/organizationPage.js. Each
section's blocks are their own collection; the Leadership blocks
are where the teams go, a People block each, in order. */
import { blocksChild } from "./shared.ts";
/* A block collection for one section: the shared block editor,
without "Shown in" (these blocks only ever show on the page). */
const sectionBlocks = (key: string, label: string, note: string) => ({
...blocksChild,
key,
label,
note,
fields: blocksChild.fields.filter((field) => field.path !== "slot"),
});
export const organizationPage = {
key: "organization_page",
label: "Organization page",
singular: "organization page",
idLabel: "Page",
singleton: "organization",
list: { columns: [], filters: [] },
groups: [
{
legend: "Mission, Vision & Values",
note: "The page's first section. Its content is the Mission blocks below.",
fields: [{ path: "mission_title", label: "Heading", help: "Default: Mission, Vision & Values" }],
},
{
legend: "Leadership",
note: "The second section: the Leadership blocks below, then Volunteering.",
fields: [
{ path: "leadership_title", label: "Heading", help: "Default: Leadership" },
{ path: "leadership_blurb", label: "Blurb", widget: "textarea", full: true },
],
},
{
legend: "Volunteering",
note: "Under the leadership: a title, a line or two and the links below.",
fields: [
{ path: "volunteer_title", label: "Title", help: "Default: Volunteering" },
{ path: "volunteer_blurb", label: "Blurb", widget: "textarea", full: true },
],
},
],
children: [
sectionBlocks("mission_blocks", "Mission blocks", "The Mission, Vision & Values section: headings, paragraphs, lists, whatever it needs."),
sectionBlocks(
"leadership_blocks",
"Leadership blocks",
"The Leadership section, in order: eg. a People block for the Board of Trustees, then one for the Retreat Team.",
),
{
key: "volunteer_links",
label: "Volunteering links",
note: "Buttons under the volunteering blurb.",
addLabel: "Add link",
title: (row) => row.label || row.url || "New link",
blank: { label: "", url: "" },
fields: [
{ path: "label", label: "Label", required: true, help: "eg. Volunteer at a retreat" },
{ path: "url", label: "Link", required: true, full: true, help: "A page on this site (eg. /request) or anywhere else" },
],
},
],
};

View file

@ -0,0 +1,215 @@
/* ── The site's own pages (056_site_pages.sql) ───────────────────
Pages → Community, Retreats, Resources, Organization, History:
each page is its sections, in order, and each section is its
heading and its own content blocks, then a preset if it has one
(a prebuilt part of the site, drawn under the blocks). Server
side: server/src/admin-schema/sitePages.js; the page is
src/pages/SitePage.tsx.
The preset values are the CHECK list on page_sections.preset;
each page offers the ones that belong on it. */
import { FEATURED_KINDS, featuredCardsChild, blocksChild } from "./shared.ts";
const PRESETS = {
community_blog: "Community blog (its settings are below)",
group_map: "Local groups map",
region_list: "Unity Regions list",
partner_list: "Partner organization cards",
events: "Event carousel or grid",
timeline: "Timeline",
organization_details: "Address, tax ID and email",
};
const ACCENT_OPTIONS = [
["teal", "Teal"],
["deep", "Deep teal"],
["green", "Green"],
["amber", "Amber"],
];
const EVENT_TYPES = [
["retreat", "Retreat"],
["class", "Class"],
["workshop", "Workshop"],
["meeting", "Meeting"],
["other", "Other"],
];
const EVENTS = { path: "preset", value: "events" };
const sectionsChild = (presets: string[]) => ({
key: "sections",
label: "Sections",
note: "Top to bottom. Each is listed in the page's side nav and the header's menu under its title.",
addLabel: "Add section",
title: (row) => row.title || "New section",
blank: { anchor: "", title: "", blurb: "", accent: "", preset: "", content_blocks: [] },
fields: [
{
path: "title",
label: "Title",
required: true,
help: "Up to 30 characters, so it fits the side nav. eg. Mission, Vision & Values",
},
{
path: "anchor",
label: "URL ID",
required: true,
help: "The section's link after the #: lowercase letters, numbers and hyphens, eg. leadership",
},
{ path: "blurb", label: "Blurb", widget: "textarea", full: true, help: "A line under the title" },
{ path: "accent", label: "Accent", widget: "select", options: ACCENT_OPTIONS, blankLabel: "Default: Teal" },
...(presets.length
? [
{
path: "preset",
label: "Preset",
widget: "select",
options: presets.map((key) => [key, PRESETS[key]]),
blankLabel: "Default: none, just the blocks below",
help: "A prebuilt part of the site, shown under the section's blocks",
},
]
: []),
...(presets.includes("events")
? [
{
path: "scope_id",
label: "Events: scope",
widget: "select",
optionsFrom: "event_scopes",
blankLabel: "Default: every scope",
when: EVENTS,
},
{
path: "event_type",
label: "Events: type",
widget: "select",
options: EVENT_TYPES,
blankLabel: "Default: every type",
when: EVENTS,
},
{
path: "view",
label: "Opens as",
widget: "select",
options: [["carousel", "Carousel"], ["grid", "Grid"]],
blankLabel: "Default: Carousel",
when: EVENTS,
},
]
: []),
...(presets.includes("group_map")
? [
{
path: "view",
label: "Opens as",
widget: "select",
options: [["map", "Map"], ["grid", "Grid"]],
blankLabel: "Default: Map",
when: { path: "preset", value: "group_map" },
},
]
: []),
],
children: [
{
...blocksChild,
label: "Blocks",
note: "The section's own content: headings, paragraphs, people, links, whatever it needs.",
fields: blocksChild.fields.filter((field) => field.path !== "slot"),
},
],
});
const sitePage = (id: string, label: string, presets: string[], more: Record<string, any> = {}) => ({
key: `${id}_page`,
label,
singular: label.toLowerCase(),
idLabel: "Page",
singleton: id,
list: { columns: [], filters: [] },
groups: [],
...more,
children: [sectionsChild(presets), ...(more.children ?? [])],
});
export const communityPage = sitePage(
"community",
"Community page",
["community_blog", "group_map", "region_list", "partner_list"],
{
groups: [
{
legend: "Community blog: our posts",
note: "For the Community blog preset. Pinned posts first, then the newest published, listed posts, up to the number of slots.",
fields: [
{ path: "blog.internal_title", label: "Heading", help: "Default: From NGU" },
{ path: "blog.internal_slots", label: "Slots", widget: "number", help: "0 to 12. Default: 3" },
],
},
{
legend: "Community blog: community posts",
note: "Pinned cards first, then the newest items from the feeds below, up to the number of slots.",
fields: [
{ path: "blog.external_title", label: "Heading", help: "Default: From our community" },
{ path: "blog.external_slots", label: "Slots", widget: "number", help: "0 to 12. Default: 3" },
{ path: "blog.external_url", label: "Button link", help: "eg. https://ngu.substack.com", full: true },
{ path: "blog.external_label", label: "Button text", help: "Default: Read more on Substack" },
],
},
],
children: [
{
key: "pinned_posts",
label: "Community blog: pinned posts (ours)",
note: "Always shown, before the newest.",
addLabel: "Pin a post",
title: (row, options) =>
options?.blog_posts?.find((p) => p.id === row.post_id)?.label ?? "New pin",
blank: { post_id: "" },
fields: [
{
path: "post_id",
label: "Post",
widget: "select",
optionsFrom: "blog_posts",
required: true,
},
],
},
{
...featuredCardsChild,
label: "Community blog: pinned community posts",
note: "Always shown, before the feeds' newest. Paste a post's link and press Fetch preview.",
addLabel: "Pin a post",
blank: { kind: "", url: "", title: "" },
fields: featuredCardsChild.fields.map((field) =>
field.path === "kind"
? { ...field, options: FEATURED_KINDS.filter(([kind]) => kind !== "record") }
: field,
),
},
{
key: "feeds",
label: "Community blog: feeds",
note: "RSS or Atom feeds whose newest posts fill the community slots. Read about every 30 minutes.",
addLabel: "Add feed",
title: (row) => row.label || row.url || "New feed",
blank: { url: "", label: "" },
fields: [
{ path: "url", label: "Feed URL", required: true, full: true, help: "eg. https://ngu.substack.com/feed" },
{ path: "label", label: "Source name", help: "Shown on its cards. Default: the feed's own title" },
],
},
],
},
);
export const retreatsPage = sitePage("retreats", "Retreats page", ["events"]);
export const resourcesPage = sitePage("resources", "Resources page", []);
export const organizationPage = sitePage("organization", "Organization page", ["organization_details"]);
export const historyPage = sitePage("history", "History page", ["timeline"]);

View file

@ -2,15 +2,16 @@
NAV SECTIONS: the sections listed under each page in the header's NAV SECTIONS: the sections listed under each page in the header's
dropdowns, the mobile menu and the footer's site map dropdowns, the mobile menu and the footer's site map
The static pages' lists are PAGE_SECTIONS in navConfig.ts. The Every page's list comes from the page itself, so adding, moving
front page's comes from the front page itself: the bands it is or renaming a section changes the menus too: the site pages'
showing, in the admin's order, each under its heading (Front page sections (Pages → each page, GET /site-pages), and the front
→ Sections), so hiding a band or renaming it changes the menus too. page's bands it is showing, in the admin's order, each under its
heading (Front page → Sections).
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { useCallback } from 'react' import { useCallback } from 'react'
import { PAGE_SECTIONS } from '../navConfig.ts' import { useSitePageHeadings } from './useSitePages.ts'
import { useFrontPage } from './useFrontPage.ts' import { useFrontPage } from './useFrontPage.ts'
import { FRONT_PAGE_BANDS, bandShows } from './frontPageBands.ts' import { FRONT_PAGE_BANDS, bandShows } from './frontPageBands.ts'
@ -18,10 +19,16 @@ export type NavSection = { label: string; hash: string }
export function useNavSections(): (path: string) => NavSection[] { export function useNavSections(): (path: string) => NavSection[] {
const { data: page } = useFrontPage() const { data: page } = useFrontPage()
const { data: sitePages } = useSitePageHeadings()
return useCallback( return useCallback(
(path: string) => { (path: string) => {
if (path !== '/') return PAGE_SECTIONS[path] ?? [] if (path !== '/') {
return (sitePages?.[path.slice(1)] ?? []).map((section) => ({
label: section.title,
hash: `#${section.anchor}`,
}))
}
if (!page) return [] if (!page) return []
return page.sections.flatMap((section) => { return page.sections.flatMap((section) => {
const band = FRONT_PAGE_BANDS[section.section] const band = FRONT_PAGE_BANDS[section.section]
@ -29,6 +36,6 @@ export function useNavSections(): (path: string) => NavSection[] {
return [{ label: section.title || band.title, hash: `#${band.id}` }] return [{ label: section.title || band.title, hash: `#${band.id}` }]
}) })
}, },
[page], [page, sitePages],
) )
} }

View file

@ -47,8 +47,6 @@ export type BlogPostSummary = {
} }
export type CommunityBlog = { export type CommunityBlog = {
title?: string | null
blurb?: string | null
internal: { title?: string | null; posts: BlogPostSummary[] } internal: { title?: string | null; posts: BlogPostSummary[] }
external: { external: {
title?: string | null title?: string | null

25
src/lib/useSitePages.ts Normal file
View file

@ -0,0 +1,25 @@
/* The site's own pages (Community, Retreats, Resources, Organization,
History), built in the admin from sections: GET /site-pages/:id
for one page's sections, GET /site-pages for every page's section
headings (the header's dropdowns, the footer, the side nav). */
import { useRecord, type Resource } from './useRecord.ts'
import type { ContentBlock } from './useContent.ts'
export type SitePageSection = {
anchor: string
title: string
blurb?: string | null
accent?: 'teal' | 'deep' | 'green' | 'amber' | null
preset?: string | null
scope_id?: string | null
event_type?: string | null
view?: string | null
blocks: ContentBlock[]
}
export const useSitePage = (id: string): Resource<{ id: string; sections: SitePageSection[] }> =>
useRecord(`/site-pages/${id}`, 'page')
export const useSitePageHeadings = (): Resource<Record<string, Array<{ anchor: string; title: string }>>> =>
useRecord('/site-pages', 'pages')

View file

@ -10,36 +10,6 @@ export const PAGE_LINKS = [
{ label: "History", path: "/history" }, { label: "History", path: "/history" },
]; ];
// Sections belong to a page, keyed by that page's path: the header's
// dropdowns, the mobile menu and the footer list them (navSections.ts).
// The front page's aren't here: they follow the bands it's showing.
export const PAGE_SECTIONS: Record<string, Array<{ label: string; hash: string }>> = {
"/retreats": [
{ label: "National", hash: "#national" },
{ label: "Regional", hash: "#regional" },
{ label: "Partner Events", hash: "#partner"},
],
"/community": [
{ label: "Community Blog", hash: "#blog" },
{ label: "Local Groups", hash: "#groups" },
{ label: "Unity Regions", hash: "#regions" },
{ label: "Partner Organizations", hash: "#partners" },
],
"/organization": [
{ label: "Mission & Values", hash: "#mission" },
{ label: "Leadership", hash: "#leadership" },
{ label: "Details & Contact", hash: "#contact" },
],
"/resources": [
{ label: "Unity Teachings", hash: "#unity" },
{ label: "Branding & Marketing", hash: "#branding" },
{ label: "Partner Resources", hash: "#partner" },
],
"/history": [
{ label: "Timeline", hash: "#timeline" },
],
};
// Right-side actions. `variant` picks the styling, not the destination. // Right-side actions. `variant` picks the styling, not the destination.
export const NAV_ACTIONS = [ export const NAV_ACTIONS = [
{ label: "Contact Us", to: "/organization#contact", variant: "ghost" }, { label: "Contact Us", to: "/organization#contact", variant: "ghost" },

View file

@ -1,96 +0,0 @@
import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts";
import { useSectionManifest } from "../lib/sections.tsx";
import OrgListMap, { OrgMapToggle } from "./sections/OrgList-Map.tsx";
import OrgListVertical from "./sections/OrgList-Vertical.tsx";
import OrgListCards from "./sections/OrgList-Card.tsx";
import CommunityBlog from "./sections/CommunityBlog.tsx";
import { useCommunityBlog } from "../lib/useBlog.ts";
import { ACCENTS, BRAND } from "../lib/color.ts"
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/community");
/* ═══════════════════════════════════════════════════════════════
COMMUNITY PAGE
The blog first, then two views of the organizations table. The
map is filtered to groups; the vertical list is filtered to
regions. Same rows, same endpoint, different shape on the page.
The blog's heading and blurb are the admin's (Pages → Community blog
section), so that one entry is built here from the same cached
request CommunityBlog makes for its posts.
═══════════════════════════════════════════════════════════════ */
const BLOG_DEFAULT_TITLE = "Community Blog";
const SECTIONS = [
{
id: "groups",
title: "Local Groups",
blurb:
"Young adult groups meeting in person and online across the movement.",
accent: BRAND,
Component: OrgListMap,
request: { type: "group", label: "Add or update a group" },
views: { options: ["map", "grid"], default: "map", Toggle: OrgMapToggle },
},
{
id: "regions",
title: "Unity Regions",
blurb:
"The regional organizations that support groups and host their own gatherings.",
accent: "#3b5456",
Component: OrgListVertical,
request: { type: "region", label: "Request a region update" },
props: {
kind: "region",
pageLabel: "Region page",
groupBy: org => org.details?.scope,
groups: [
{ key: "domestic", title: "US Unity Regions" },
{ key: "international", title: "International Unity Regions" },
],
},
},
{
id: "partners",
title: "Partner Organizations",
blurb:
"Organizations we collaborate with across the Unity movement and beyond.",
accent: ACCENTS.amber,
Component: OrgListCards,
request: { type: "partner", label: "Request a partner listing" },
props: {
kind: "partner",
pageLabel: "Partner page",
empty: "· Partner organizations coming soon ·",
},
},
];
export default function CommunityPage() {
const { data: blog } = useCommunityBlog();
const sections = useSectionManifest([
{
id: "blog",
title: blog?.title || BLOG_DEFAULT_TITLE,
blurb: blog?.blurb ?? undefined,
accent: BRAND,
Component: CommunityBlog,
request: { type: "blog", label: "Write for the blog" },
},
...SECTIONS,
]);
return (
<PageShell
sideNav
title={PAGE.title}
intro={PAGE.description}
sections={sections}
/>
);
}

View file

@ -1,88 +0,0 @@
import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts";
import HistoryTimeline from "./sections/history/HistoryTimeline.tsx";
import { HISTORY_DECADES } from "../data/historyDecades.ts";
import { useHistory } from "../lib/useHistory.ts";
import { BRAND } from "../lib/color.ts"
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/history");
/**
* Year the program starts. Decades ending before this render with the
* pre-program treatment, so the gap moves if the founding date is ever
* corrected, no hardcoded 2000 anywhere in the components.
*/
const PROGRAM_START_YEAR = 2000;
const BACKGROUND = "var(--color-surface)";
export default function History() {
const { items, loading, error, reload } = useHistory();
// Section renders `content` outside its own max-width wrapper, so the
// container lives here. The custom properties bind the timeline to
// this section's accent and background, --tl-surface must match
// `background` or the rail will show through the year dots.
const wrap = (children: React.ReactNode) => (
<div
className="max-w-6xl mx-auto px-6"
style={{ "--tl-accent": BRAND, "--tl-surface": BACKGROUND } as React.CSSProperties}
>
{children}
</div>
);
let content: React.ReactNode;
if (loading) {
content = wrap(
<p className="py-12 text-muted" role="status">
Loading the timeline…
</p>,
);
} else if (error) {
// Say what failed and offer the one action that might fix it.
// A history page that silently renders nothing looks like an
// organization with no history.
content = wrap(
<div className="py-12">
<p className="text-danger">Couldn’t load the timeline. {error}</p>
<button
type="button"
onClick={reload}
className="mt-3 btn border border-brand px-4 py-1.5 text-sm text-link transition-colors hover:bg-tint"
>
Try again
</button>
</div>,
);
} else {
content = wrap(
<HistoryTimeline
items={items}
decades={HISTORY_DECADES}
direction="desc"
programStartYear={PROGRAM_START_YEAR}
/>,
);
}
return (
<PageShell
sideNav
title={PAGE.title}
intro={PAGE.description}
sections={[
{
id: "timeline",
title: "NGU Timeline",
blurb:
"Open a year to see what happened.",
accent: BRAND,
content,
},
]}
/>
);
}

View file

@ -1,153 +0,0 @@
/* ═══════════════════════════════════════════════════════════════
ORGANIZATION: /organization
NGU itself, in three parts, edited in the admin as Pages →
Organization page (GET /organization-page):
mission Mission, Vision & Values: the page's mission blocks
leadership its leadership blocks, in order (a People block per
team: the Board of Trustees, then the Retreat Team),
then Volunteering: a title, a blurb and its links
contact NGU's address, nonprofit status and email
(src/data/organizationDetails.ts)
A section with nothing written yet says so (ComingSoon) rather
than showing a heading over nothing.
═══════════════════════════════════════════════════════════════ */
import PageShell from '../components/PageShell.tsx'
import ComingSoon from '../components/ComingSoon.tsx'
import ContentBlocks from '../components/ContentBlocks.tsx'
import HomeLink from './sections/home/HomeLink.tsx'
import { sitePage } from '../lib/site.ts'
import { useRecord } from '../lib/useRecord.ts'
import type { ContentBlock } from '../lib/useContent.ts'
import { ORGANIZATION_DETAILS } from '../data/organizationDetails.ts'
import { ACCENTS, BRAND } from '../lib/color.ts'
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage('/organization')
type OrganizationPage = {
mission_title?: string | null
mission_blocks: ContentBlock[]
leadership_title?: string | null
leadership_blurb?: string | null
leadership_blocks: ContentBlock[]
volunteer: { title?: string | null; blurb?: string | null; links: Array<{ label: string; url: string }> }
}
export default function Organization() {
const { data: page, loading, error } = useRecord<OrganizationPage>('/organization-page', 'page')
const pending = (what: string) =>
error ? (
<p className="mx-auto max-w-6xl px-6 text-danger">Couldn’t load {what} right now.</p>
) : loading || !page ? (
<div className="mx-auto max-w-6xl px-6">
<div className="skeleton !min-h-40" aria-label={`Loading ${what}`} />
</div>
) : null
return (
<PageShell
title={PAGE.title}
intro={PAGE.description}
sideNav
sections={[
{
id: 'mission',
title: page?.mission_title || 'Mission, Vision & Values',
accent: BRAND,
content:
pending('our mission') ??
(page!.mission_blocks.length > 0 ? (
<div className="mx-auto max-w-6xl px-6">
<div className="max-w-3xl">
<ContentBlocks blocks={page!.mission_blocks} accent={BRAND} />
</div>
</div>
) : (
<ComingSoon what="our mission, vision and values" />
)),
},
{
id: 'leadership',
title: page?.leadership_title || 'Leadership',
blurb: page?.leadership_blurb ?? undefined,
accent: ACCENTS.green,
content: pending('our leadership') ?? <Leadership page={page!} />,
},
{
id: 'contact',
title: 'Details & Contact',
accent: ACCENTS.deep,
content: <Contact />,
},
]}
/>
)
}
function Leadership({ page }: { page: OrganizationPage }) {
const { volunteer } = page
const hasVolunteering = Boolean(volunteer.title || volunteer.blurb || volunteer.links.length)
return (
<div className="mx-auto max-w-6xl space-y-14 px-6">
{page.leadership_blocks.length > 0 ? (
<ContentBlocks blocks={page.leadership_blocks} accent={ACCENTS.green} />
) : (
<ComingSoon what="our leadership list" />
)}
{hasVolunteering && (
<div className="max-w-3xl">
<h3 className="text-2xl font-bold text-ink">{volunteer.title || 'Volunteering'}</h3>
{volunteer.blurb && <p className="mt-2 leading-relaxed text-body">{volunteer.blurb}</p>}
{volunteer.links.length > 0 && (
<div className="mt-5 flex flex-wrap gap-3">
{volunteer.links.map((link) => (
<HomeLink
key={`${link.url}-${link.label}`}
url={link.url}
className="btn inline-block bg-action px-5 py-2.5 text-white transition-colors hover:bg-action-hover"
>
{link.label}
</HomeLink>
))}
</div>
)}
</div>
)}
</div>
)
}
function Contact() {
const details = ORGANIZATION_DETAILS
return (
<div className="mx-auto grid max-w-6xl gap-8 px-6 md:grid-cols-2">
<div className="space-y-3 text-body">
<address className="not-italic leading-relaxed">
{details.street}
<br />
{details.cityLine}
<br />
<span className="text-sm text-muted">({details.addressNote})</span>
</address>
<p className="text-sm text-muted">
{details.nonprofit} Tax ID: {details.taxId}.
</p>
</div>
<div>
<a
href={`mailto:${details.email}`}
className="btn inline-block border border-link px-6 py-2.5 text-link transition-colors hover:bg-tint"
>
{details.email}
</a>
</div>
</div>
)
}

View file

@ -1,42 +0,0 @@
import PageShell from "../components/PageShell.tsx";
import ComingSoon from "../components/ComingSoon.tsx";
import { sitePage } from "../lib/site.ts";
import { ACCENTS, BRAND } from "../lib/color.ts"
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/resources");
const SECTIONS = [
{
id: "unity",
title: "Unity Teachings",
blurb: "Core principles, readings, and study material from the Unity movement.",
accent: BRAND,
content: <ComingSoon what="our Unity teachings" />,
},
{
id: "branding",
title: "Branding & Marketing",
blurb: "Logos, colors, templates, and guidelines for representing NGU.",
accent: ACCENTS.green,
content: <ComingSoon what="our branding and marketing kit" />,
},
{
id: "partner",
title: "Partner Resources",
blurb: "Material for the organizations we collaborate with.",
accent: ACCENTS.amber,
content: <ComingSoon what="resources for partners" />,
},
];
export default function ResourcesPage() {
return (
<PageShell
sideNav
title={PAGE.title}
intro={PAGE.description}
sections={SECTIONS}
/>
);
}

View file

@ -1,121 +0,0 @@
import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts";
import { useSectionManifest } from "../lib/sections.tsx";
import EventListCards, { EventCardsToggle } from "./sections/EventList-Cards.tsx";
import { ACCENTS, BRAND } from "../lib/color.ts"
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/retreats");
/* ═══════════════════════════════════════════════════════════════
RETREATS PAGE
Three bands, all the same view of the same table with a
different filter. The page declares them and does nothing else,
each section fetches its own slice.
Two filters per band now, and they answer different questions:
scope whose gathering it is. event_scopes holds six of
these; this page draws three.
type what kind of gathering it is. Pinned to "retreat"
everywhere on this page, which is what the page is
for and what lets "Partner" read as a heading rather
than a catch-all.
Because every band is pinned to one type, EventListCards finds a
single kind in each and draws no type chips. Drop the `type` from
a band and the chips appear on their own.
What this page deliberately does not show: local, international
and other scopes, and every non-retreat type. Those are reachable
from their host's page and by URL, and get a band here when
there's enough of them to fill one, see the block at the bottom.
To reorder the page, move a line. To add a different kind of
section, add an entry with another Component.
═══════════════════════════════════════════════════════════════ */
const CARD_VIEWS = { options: ["carousel", "grid"], Toggle: EventCardsToggle };
/* Pinned on every band. Named rather than repeated so turning this
page into "everything, filtered" later is one deletion. */
const RETREATS = { type: "retreat" };
const SECTIONS = [
{
id: "national",
title: "National Retreats",
blurb: "Our flagship gatherings, open to young adults across the country.",
accent: BRAND,
Component: EventListCards,
props: { scope: "national", ...RETREATS },
views: { ...CARD_VIEWS, default: "carousel" },
request: { type: "event", label: "Add or update an event" },
},
{
id: "regional",
title: "Regional Retreats",
blurb: "Smaller gatherings hosted by regions throughout the year.",
accent: ACCENTS.green,
Component: EventListCards,
props: { scope: "regional", ...RETREATS },
views: { ...CARD_VIEWS, default: "grid" },
},
{
id: "partner",
title: "Partner Events",
blurb: "Retreats hosted by organizations we collaborate with.",
accent: ACCENTS.amber,
Component: EventListCards,
props: { scope: "partner", ...RETREATS },
views: { ...CARD_VIEWS, default: "grid" },
},
/* The other three scopes, ready to uncomment. Each needs an accent
and a background of its own, those are presentation and live
here, not in event_scopes.
{
id: "local",
title: "Local Events",
blurb: "Hosted by individual groups.",
accent: ACCENTS.green,
Component: EventListCards,
props: { scope: "local", ...RETREATS_ONLY },
views: { ...CARD_VIEWS, default: "grid" },
},
{
id: "international",
title: "International Events",
blurb: "Gatherings beyond the US.",
accent: ACCENTS.deep,
Component: EventListCards,
props: { scope: "international", ...RETREATS_ONLY },
views: { ...CARD_VIEWS, default: "grid" },
},
{
id: "other",
title: "Other Events",
blurb: "Everything that doesn't fit the categories above.",
accent: ACCENTS.amber,
Component: EventListCards,
props: { scope: "other", ...RETREATS_ONLY },
views: { ...CARD_VIEWS, default: "grid" },
},
*/
];
export default function RetreatsPage() {
const sections = useSectionManifest(SECTIONS);
return (
<PageShell
sideNav
title={PAGE.title}
intro={PAGE.description}
sections={sections}
/>
);
}

216
src/pages/SitePage.tsx Normal file
View file

@ -0,0 +1,216 @@
/* ═══════════════════════════════════════════════════════════════
SITE PAGE: /community, /retreats, /resources, /organization,
/history
Each is a list of sections built in the admin (Pages → the page,
GET /site-pages/:id). A section is its heading, then its own
content blocks, then its preset if it has one: a prebuilt part of
the site, from PRESETS below. A section with neither says it's
coming (ComingSoon) rather than showing a heading over nothing.
The title and intro are site.json's, which also gives the search
metadata.
═══════════════════════════════════════════════════════════════ */
import { useEffect } from 'react'
import { useLocation } from 'react-router-dom'
import PageShell from '../components/PageShell.tsx'
import ComingSoon from '../components/ComingSoon.tsx'
import ContentBlocks from '../components/ContentBlocks.tsx'
import { sitePage } from '../lib/site.ts'
import { useSectionManifest } from '../lib/sections.tsx'
import { useSitePage, type SitePageSection } from '../lib/useSitePages.ts'
import { useHistory } from '../lib/useHistory.ts'
import { ORGANIZATION_DETAILS } from '../data/organizationDetails.ts'
import { HISTORY_DECADES } from '../data/historyDecades.ts'
import { ACCENTS, BRAND } from '../lib/color.ts'
import { scrollBehavior } from '../lib/motion.ts'
import OrgListMap, { OrgMapToggle } from './sections/OrgList-Map.tsx'
import OrgListVertical from './sections/OrgList-Vertical.tsx'
import OrgListCards from './sections/OrgList-Card.tsx'
import EventListCards, { EventCardsToggle } from './sections/EventList-Cards.tsx'
import CommunityBlog from './sections/CommunityBlog.tsx'
import HistoryTimeline from './sections/history/HistoryTimeline.tsx'
/* Year the program starts: decades ending before it get the
pre-program look on the timeline. */
const PROGRAM_START_YEAR = 2000
/* Each preset: the view it draws, its fixed props, its toggle (the
section's own view picks the first one) and its Request button.
The keys are the CHECK list on page_sections.preset. */
const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>> = {
community_blog: () => ({
Component: CommunityBlog,
request: { type: 'blog', label: 'Write for the blog' },
}),
group_map: (section) => ({
Component: OrgListMap,
request: { type: 'group', label: 'Add or update a group' },
views: { options: ['map', 'grid'], default: section.view === 'grid' ? 'grid' : 'map', Toggle: OrgMapToggle },
}),
region_list: () => ({
Component: OrgListVertical,
request: { type: 'region', label: 'Request a region update' },
props: {
kind: 'region',
pageLabel: 'Region page',
groupBy: (org: any) => org.details?.scope,
groups: [
{ key: 'domestic', title: 'US Unity Regions' },
{ key: 'international', title: 'International Unity Regions' },
],
},
}),
partner_list: () => ({
Component: OrgListCards,
request: { type: 'partner', label: 'Request a partner listing' },
props: { kind: 'partner', pageLabel: 'Partner page', empty: '· Partner organizations coming soon ·' },
}),
events: (section) => ({
Component: EventListCards,
request: { type: 'event', label: 'Add or update an event' },
props: { scope: section.scope_id ?? undefined, type: section.event_type ?? undefined },
views: {
options: ['carousel', 'grid'],
default: section.view === 'grid' ? 'grid' : 'carousel',
Toggle: EventCardsToggle,
},
}),
timeline: () => ({ Component: Timeline }),
organization_details: () => ({ Component: OrganizationDetails }),
}
export default function SitePage({ id }: { id: string }) {
const PAGE = sitePage(`/${id}`)
const { data: page, loading, error } = useSitePage(id)
if (page) return <Sections title={PAGE.title} intro={PAGE.description} sections={page.sections} />
return (
<>
<PageShell title={PAGE.title} intro={PAGE.description} sections={[]} />
<div className="mx-auto max-w-6xl px-6 py-20">
{error ? (
<p className="text-danger">Couldn’t load this page right now.</p>
) : (
loading && <div className="skeleton !min-h-40" aria-label="Loading the page" />
)}
</div>
</>
)
}
/* Its own component so the manifest, which seeds each toggle's view
once, sees the loaded sections. */
function Sections({ title, intro, sections }: { title: string; intro?: string; sections: SitePageSection[] }) {
// Layout scrolls to a link's #section on arrival, before the
// sections have loaded; this does it again once they're here.
const { hash } = useLocation()
useEffect(() => {
if (hash) document.getElementById(decodeURIComponent(hash.slice(1)))?.scrollIntoView({ behavior: scrollBehavior() })
}, [hash])
const manifest = useSectionManifest(
sections.map((section) => {
const accent = ACCENTS[section.accent ?? 'teal'] ?? BRAND
const preset = section.preset ? PRESETS[section.preset]?.(section) : null
return {
id: section.anchor,
title: section.title,
blurb: section.blurb ?? undefined,
accent,
...preset,
// Blocks, then the preset under them.
Component: SectionBody,
props: { blocks: section.blocks, title: section.title, Preset: preset?.Component, presetProps: preset?.props },
}
}),
)
return <PageShell sideNav title={title} intro={intro} sections={manifest} />
}
function SectionBody({ blocks, title, Preset, presetProps, ...rest }: any) {
if (!blocks.length && !Preset) return <ComingSoon what={`our ${title}`} />
return (
<>
{blocks.length > 0 && (
<div className={`mx-auto max-w-6xl px-6 ${Preset ? 'mb-12' : ''}`}>
<ContentBlocks blocks={blocks} accent={rest.accent} />
</div>
)}
{Preset && <Preset {...presetProps} {...rest} />}
</>
)
}
function Timeline({ accent = BRAND }: { accent?: string }) {
const { items, loading, error, reload } = useHistory()
// The custom properties bind the timeline to this section's accent
// and the page's surface, which the rail must match or it shows
// through the year dots.
return (
<div
className="mx-auto max-w-6xl px-6"
style={{ '--tl-accent': accent, '--tl-surface': 'var(--color-surface)' } as React.CSSProperties}
>
{loading ? (
<p className="py-12 text-muted" role="status">
Loading the timeline…
</p>
) : error ? (
// A history page that silently renders nothing looks like an
// organization with no history: say so, and offer a retry.
<div className="py-12">
<p className="text-danger">Couldn’t load the timeline. {error}</p>
<button
type="button"
onClick={reload}
className="btn mt-3 border border-brand px-4 py-1.5 text-sm text-link transition-colors hover:bg-tint"
>
Try again
</button>
</div>
) : (
<HistoryTimeline
items={items}
decades={HISTORY_DECADES}
direction="desc"
programStartYear={PROGRAM_START_YEAR}
/>
)}
</div>
)
}
/* NGU's address, nonprofit status and email (src/data/organizationDetails.ts). */
function OrganizationDetails() {
const details = ORGANIZATION_DETAILS
return (
<div className="mx-auto grid max-w-6xl gap-8 px-6 md:grid-cols-2">
<div className="space-y-3 text-body">
<address className="not-italic leading-relaxed">
{details.street}
<br />
{details.cityLine}
<br />
<span className="text-sm text-muted">({details.addressNote})</span>
</address>
<p className="text-sm text-muted">
{details.nonprofit} Tax ID: {details.taxId}.
</p>
</div>
<div>
<a
href={`mailto:${details.email}`}
className="btn inline-block border border-link px-6 py-2.5 text-link transition-colors hover:bg-tint"
>
{details.email}
</a>
</div>
</div>
)
}

View file

@ -100,15 +100,32 @@ export const PAGES_NAV = {
label: "Front page", label: "Front page",
blurb: "The hero, its photos or livestream, and which bands the home page draws.", blurb: "The hero, its photos or livestream, and which bands the home page draws.",
}, },
// The site's own pages, in the header's order: each is its
// sections, built in the editor (sitePages.ts).
{
to: "/admin/retreats_page",
label: "Retreats",
blurb: "Its sections: the event carousels and grids, and anything else written for it.",
},
{ {
to: "/admin/community_page", to: "/admin/community_page",
label: "Community blog section", label: "Community",
blurb: "The Community page's blog: headings, pinned posts and feeds.", blurb: "Its sections: the blog (and its pinned posts and feeds), groups map, regions and partners.",
},
{
to: "/admin/resources_page",
label: "Resources",
blurb: "Its sections and their content.",
}, },
{ {
to: "/admin/organization_page", to: "/admin/organization_page",
label: "Organization page", label: "Organization",
blurb: "Mission, vision and values, the leadership teams in order, and volunteering.", blurb: "Mission, vision and values, the leadership teams and volunteering, details and contact.",
},
{
to: "/admin/history_page",
label: "History",
blurb: "Its sections: the timeline (its entries are under Data), and anything else.",
}, },
], ],
}; };

View file

@ -1,8 +1,8 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
COMMUNITY BLOG COMMUNITY BLOG
The Community page's blog section (Admin → Pages → Community blog The Community page's blog section (Admin → Pages → Community
section). Two halves, each pinned first and then newest, as page, its Community blog preset and the blog settings). Two halves, each pinned first and then newest, as
routes/blog.js decides: routes/blog.js decides:
our posts cards for our own /blog/:id pages our posts cards for our own /blog/:id pages
@ -10,8 +10,7 @@
newest from the listed feeds), drawn by newest from the listed feeds), drawn by
FeaturedCards, with a button to the Substack FeaturedCards, with a button to the Substack
The section's heading and blurb come from the same record; the The section's heading and blurb are its section's, like any other.
page reads them through the same cached request (Community.tsx).
A half with nothing in it isn't drawn. A half with nothing in it isn't drawn.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */