Page editors: Retreats, Community, Resources, Organization and History built from sections

Each page is now a list of sections edited in Admin → Pages: a title
(30 characters at most, for the side nav), URL ID, blurb and accent,
its own content blocks, and an optional preset (Community blog, groups
map, region list, partner cards, events, timeline, NGU's details).
Migration 056 seeds every page as the code drew it and moves the
Organization editor's blocks and volunteering into its sections. The
Community blog's settings move into the Community editor. The header,
footer and side nav read each page's sections from the API.

The admin engine reads and writes nested collections to any depth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-10-01 00:15:30 -05:00
parent 4a1d6fd6e9
commit 9daf7b1a4f
29 changed files with 972 additions and 938 deletions

View file

@ -49,11 +49,9 @@ const lazyPage = (load) =>
throw err
}),
)
const Retreats = lazyPage(() => import("./pages/Retreats.tsx"))
const Community = lazyPage(() => import("./pages/Community.tsx"))
const Organization = lazyPage(() => import("./pages/Organization.tsx"))
const Resources = lazyPage(() => import("./pages/Resources.tsx"))
const History = lazyPage(() => import("./pages/History.tsx"))
// Community, Retreats, Resources, Organization and History: each
// built in the admin from sections.
const SitePage = lazyPage(() => import("./pages/SitePage.tsx"))
const Feedback = lazyPage(() => import("./pages/Feedback.tsx"))
const Request = lazyPage(() => import("./pages/Request.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 /> */}
<Route element={<Layout />}>
<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="community" element={<Community />} />
<Route path="community" element={<SitePage key="community" id="community" />} />
<Route path="/regions/:id" element={<OrganizationDetail />} />
<Route path="/groups/: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="/people/:id" element={<PersonDetail />} />
<Route path="/blog/:id" element={<BlogPost />} />
<Route path="organization" element={<Organization />} />
<Route path="resources" element={<Resources />} />
<Route path="history" element={<History />} />
<Route path="organization" element={<SitePage key="organization" id="organization" />} />
<Route path="resources" element={<SitePage key="resources" id="resources" />} />
<Route path="history" element={<SitePage key="history" id="history" />} />
<Route path="feedback" element={<Feedback />} />
<Route path="request" element={<Request />} />
<Route path="qr" element={<QrCodes />} />

View file

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

View file

@ -1,12 +1,9 @@
import { preview } from "../text.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) ─────────────────────────────────────────
Posts at /blog/:id, and the Community page's blog section. The
section's community posts reuse the featured cards, limited to
links: a pinned Substack post is a link card, and Fetch preview
fills it from the post. */
Posts at /blog/:id. The Community page's blog section is edited
with that page (sitePages.ts). */
/* A post's body is the content blocks without the card/body choice:
a post only has a body. */
@ -106,87 +103,3 @@ export const blogPosts = {
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,
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: "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
dropdowns, the mobile menu and the footer's site map
The static pages' lists are PAGE_SECTIONS in navConfig.ts. The
front page's comes from the front page itself: the bands it is
showing, in the admin's order, each under its heading (Front page
→ Sections), so hiding a band or renaming it changes the menus too.
Every page's list comes from the page itself, so adding, moving
or renaming a section changes the menus too: the site pages'
sections (Pages → each page, GET /site-pages), and the front
page's bands it is showing, in the admin's order, each under its
heading (Front page → Sections).
═══════════════════════════════════════════════════════════════ */
import { useCallback } from 'react'
import { PAGE_SECTIONS } from '../navConfig.ts'
import { useSitePageHeadings } from './useSitePages.ts'
import { useFrontPage } from './useFrontPage.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[] {
const { data: page } = useFrontPage()
const { data: sitePages } = useSitePageHeadings()
return useCallback(
(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 []
return page.sections.flatMap((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}` }]
})
},
[page],
[page, sitePages],
)
}

View file

@ -47,8 +47,6 @@ export type BlogPostSummary = {
}
export type CommunityBlog = {
title?: string | null
blurb?: string | null
internal: { title?: string | null; posts: BlogPostSummary[] }
external: {
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" },
];
// 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.
export const NAV_ACTIONS = [
{ 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",
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",
label: "Community blog section",
blurb: "The Community page's blog: headings, pinned posts and feeds.",
label: "Community",
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",
label: "Organization page",
blurb: "Mission, vision and values, the leadership teams in order, and volunteering.",
label: "Organization",
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
The Community page's blog section (Admin → Pages → Community blog
section). Two halves, each pinned first and then newest, as
The Community page's blog section (Admin → Pages → Community
page, its Community blog preset and the blog settings). Two halves, each pinned first and then newest, as
routes/blog.js decides:
our posts cards for our own /blog/:id pages
@ -10,8 +10,7 @@
newest from the listed feeds), drawn by
FeaturedCards, with a button to the Substack
The section's heading and blurb come from the same record; the
page reads them through the same cached request (Community.tsx).
The section's heading and blurb are its section's, like any other.
A half with nothing in it isn't drawn.
═══════════════════════════════════════════════════════════════ */