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:
parent
4a1d6fd6e9
commit
9daf7b1a4f
29 changed files with 972 additions and 938 deletions
|
|
@ -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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -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,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -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>
|
||||
)
|
||||
}
|
||||
|
|
@ -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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -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
216
src/pages/SitePage.tsx
Normal 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>
|
||||
)
|
||||
}
|
||||
|
|
@ -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.",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue