Page management, step 3: section types with their own settings; the front page as sections
Migration 083 gives the section types that need more than blocks their own tables (hero, slides, countdown, stats, paths, featured cards, the Community blog's slots, pinned posts and feeds) and turns the front page into Home's sections: the hero, then its bands in order. Any section can be hidden. The Front page editor, its tables and the Community page's are gone; /api/front-page and /api/community-blog fold into the page's sections (sectionData.js). The admin engine reads and writes a child collection's own side tables and gated nested collections. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f33c0008fe
commit
f1a0b06ac2
46 changed files with 1525 additions and 1339 deletions
17
src/App.tsx
17
src/App.tsx
|
|
@ -14,13 +14,12 @@ import { AuthProvider, RequireAuth } from "./lib/auth.tsx"
|
|||
import RequireRole from "./pages/admin/RequireRole.tsx"
|
||||
|
||||
/*Pages*/
|
||||
// Home is the landing page, so it ships in the main bundle. Every
|
||||
// other page, and all of the admin, is fetched when first visited:
|
||||
// a visitor to the front page never downloads the admin, the QR
|
||||
// encoder, the calendar or the group map. Layout and AdminLayout
|
||||
// wrap their <Outlet /> in <Suspense>, so the header stays put while
|
||||
// a page loads.
|
||||
import Home from "./pages/Home.tsx"
|
||||
// Every page, the front page included, and all of the admin, is
|
||||
// fetched when first visited: a visitor never downloads the admin,
|
||||
// and a page's own parts come with it. The front page's data is asked
|
||||
// for by its HTML before this runs (pageMeta.js, preload). Layout and
|
||||
// AdminLayout wrap their <Outlet /> in <Suspense>, so the header stays
|
||||
// put while a page loads.
|
||||
|
||||
/* A page's chunk can be missing when a deploy replaced the build while
|
||||
this tab still ran the old one. Reload once to pick up the new
|
||||
|
|
@ -51,6 +50,8 @@ const lazyPage = (load) =>
|
|||
)
|
||||
// Every page at its address (Pages → Page management): its sections.
|
||||
const PageAtPath = lazyPage(() => import("./pages/PageAtPath.tsx"))
|
||||
// The front page: its sections, in the front page's layout.
|
||||
const SitePage = lazyPage(() => import("./pages/SitePage.tsx"))
|
||||
// Profile accounts (076): signing in, an invite's welcome, the profile.
|
||||
const SignIn = lazyPage(() => import("./pages/SignIn.tsx"))
|
||||
const AccountWelcome = lazyPage(() => import("./pages/AccountWelcome.tsx"))
|
||||
|
|
@ -91,7 +92,7 @@ export default function App() {
|
|||
<Routes>
|
||||
{/* Layout renders the nav once and swaps page content into <Outlet /> */}
|
||||
<Route element={<Layout />}>
|
||||
<Route index element={<Home />} />
|
||||
<Route index element={<SitePage key="home" id="home" />} />
|
||||
<Route path="/events/:id" element={<EventDetail />} />
|
||||
<Route path="/regions/:id" element={<OrganizationDetail />} />
|
||||
<Route path="/groups/:id" element={<OrganizationDetail />} />
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import HomeLink from '../pages/sections/home/HomeLink.tsx'
|
|||
import VideoPlayer from './VideoPlayer.tsx'
|
||||
import { refHref } from '../lib/hrefs.ts'
|
||||
import { mediaUrl } from '../lib/media.ts'
|
||||
import type { FeaturedCard, FeaturedColumns, FeaturedSize } from '../lib/useFrontPage.ts'
|
||||
import type { FeaturedCard, FeaturedColumns, FeaturedSize } from '../lib/sectionTypes.ts'
|
||||
import { useReadingMode } from '../lib/readingMode.ts'
|
||||
import { useSmallImage } from '../lib/useSmallImage.ts'
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,10 @@ export type ShellSection = {
|
|||
accent: string;
|
||||
actions?: ReactNode;
|
||||
content: ReactNode;
|
||||
/** It draws its own heading (a band, sections/Bands.tsx): the shell adds none. */
|
||||
bare?: boolean;
|
||||
/** Left out of the side nav (the hero, a countdown). */
|
||||
unlisted?: boolean;
|
||||
};
|
||||
|
||||
type PageShellProps = {
|
||||
|
|
@ -75,8 +79,12 @@ export function Section({ section }: { section: ShellSection }) {
|
|||
// shell just gives it a place to sit.
|
||||
actions,
|
||||
content,
|
||||
bare,
|
||||
} = section;
|
||||
|
||||
// A band brings its own heading, padding and anchor.
|
||||
if (bare) return <>{content}</>;
|
||||
|
||||
return (
|
||||
<section
|
||||
id={id}
|
||||
|
|
@ -179,7 +187,9 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
|
|||
ro.observe(column);
|
||||
return () => ro.disconnect();
|
||||
}, [sideNav]);
|
||||
const navSections = sideNav ? sections.map((s) => ({ id: s.id, label: s.title, accent: s.accent })) : [];
|
||||
const navSections = sideNav
|
||||
? sections.filter((s) => !s.unlisted).map((s) => ({ id: s.id, label: s.title, accent: s.accent }))
|
||||
: [];
|
||||
const active = useActiveSection(navSections);
|
||||
const activeAccent = sections.find((s) => s.id === active)?.accent;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
PATH ICONS
|
||||
|
||||
The icons a "Find your way in" path can show (Front page →
|
||||
The icons a "Find your way in" path can show (Pages → a page's Connect nav section →
|
||||
Connect Nav → Icon), as [key, label]. The admin's dropdown lists
|
||||
the labels; Pathfinder.tsx draws the Phosphor icon for each key.
|
||||
Adding one is a line here and one in ICONS in Pathfinder.tsx.
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import { people } from "./adminSchema/people.ts";
|
|||
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 } from "./adminSchema/blog.ts";
|
||||
import { siteSettings } from "./adminSchema/siteSettings.ts";
|
||||
import { siteNav } from "./adminSchema/siteNav.ts";
|
||||
|
|
@ -46,7 +45,6 @@ export const ADMIN_ENTITIES: Record<string, any> = {
|
|||
teams,
|
||||
awards,
|
||||
timeline,
|
||||
front_page: frontPage,
|
||||
blog_posts: blogPosts,
|
||||
pages,
|
||||
navigation: siteNav,
|
||||
|
|
@ -65,7 +63,6 @@ export const PREVIEW_PATHS: Record<string, (row: any) => string | null> = {
|
|||
teams: (row) => teamHref(row.id),
|
||||
awards: (row) => awardHref(row.id),
|
||||
timeline: () => "/history",
|
||||
front_page: () => "/",
|
||||
blog_posts: (row) => blogHref(row.id),
|
||||
pages: (row) => row.path || null,
|
||||
// The menus are on every page.
|
||||
|
|
|
|||
|
|
@ -1,306 +0,0 @@
|
|||
import { mediaUrl } from "../media.ts";
|
||||
import { featuredCardsChild } from "./shared.ts";
|
||||
import { PATH_ICONS } from "../../data/pathIcons.ts";
|
||||
|
||||
/* ── Front page ──────────────────────────────────────────────────
|
||||
|
||||
One record (see the singleton note in server/src/admin-schema.js).
|
||||
The groups are the hero; the collections below are the rest of
|
||||
the page. Photos, the livestream and the featured video are
|
||||
editable whatever the mode, so each can be ready before the
|
||||
switch is flipped.
|
||||
|
||||
Section keys and stat sources are the CHECK lists on
|
||||
front_page_sections and front_page_stats. The labels here are what the admin reads; the values are
|
||||
what the page and the API key on. */
|
||||
|
||||
const FRONT_PAGE_SECTIONS = [
|
||||
["countdown", "Event Countdown"],
|
||||
["retreats", "Events Carousel (National Retreats)"],
|
||||
["calendar", "Event Calendar"],
|
||||
["stats", "Stats"],
|
||||
["timeline", "Featured Timeline"],
|
||||
["connect", "Connect Nav"],
|
||||
["featured", "Featured Content"],
|
||||
];
|
||||
|
||||
const STAT_SOURCES = [
|
||||
["manual", "Print Value Field"],
|
||||
["years_since", "Years Since Value"],
|
||||
["regions", "Count: regions"],
|
||||
["groups", "Count: groups"],
|
||||
["partners", "Count: partners"],
|
||||
["events_held", "Count: past events"],
|
||||
["retreats_held", "Count: past retreats"],
|
||||
["people", "Count: people in database"],
|
||||
["awards_given", "Count: public awards given"],
|
||||
];
|
||||
|
||||
export const frontPage = {
|
||||
key: "front_page",
|
||||
label: "Front page",
|
||||
singular: "front page",
|
||||
idLabel: "Page",
|
||||
singleton: "home",
|
||||
|
||||
list: { columns: [], filters: [] },
|
||||
|
||||
groups: [
|
||||
{
|
||||
legend: "Hero - Primary Section",
|
||||
note: "The first thing a visitor sees. Blank buttons don't render.",
|
||||
fields: [
|
||||
{
|
||||
path: "hero_backdrop",
|
||||
label: "Background",
|
||||
widget: "select",
|
||||
options: [
|
||||
["brand", "Brand: animated color and the dove"],
|
||||
["photos", "Photos: cycles through the photos below"],
|
||||
],
|
||||
blankLabel: "Default: brand",
|
||||
help: "Photos with none added shows the brand background",
|
||||
},
|
||||
{
|
||||
path: "hero_feature",
|
||||
label: "Feature",
|
||||
widget: "select",
|
||||
options: [
|
||||
["none", "Nothing: No additional overlay"],
|
||||
["livestream", "Livestream: the stream, with a LIVE badge"],
|
||||
["video", "Featured video: click to play"],
|
||||
["event", "Featured event: an event's card"],
|
||||
],
|
||||
blankLabel: "Default: nothing",
|
||||
help: "Switch to Livestream when you go live, and back when you're done",
|
||||
},
|
||||
{ path: "eyebrow", label: "Eyebrow", help: "Small line above the headline" },
|
||||
{ path: "headline", label: "Headline", full: true },
|
||||
{ path: "subhead", label: "Subhead", widget: "textarea", full: true },
|
||||
{ path: "primary_label", label: "Main button label" },
|
||||
{ path: "primary_url", label: "Main button link", help: "/page, #section-id or a full URL" },
|
||||
{ path: "secondary_label", label: "Second button label" },
|
||||
{ path: "secondary_url", label: "Second button link" },
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Photos, livestream, video and event",
|
||||
fields: [
|
||||
{
|
||||
path: "slide_seconds",
|
||||
label: "Seconds per photo",
|
||||
widget: "number",
|
||||
help: "Photos Background. Set from 3 to 60 seconds",
|
||||
},
|
||||
{
|
||||
path: "livestream_url",
|
||||
label: "Livestream link",
|
||||
full: true,
|
||||
help: "A YouTube, Facebook or Vimeo link, or any embed URL",
|
||||
},
|
||||
{ path: "livestream_title", label: "Livestream title", full: true },
|
||||
{
|
||||
path: "video_url",
|
||||
label: "Featured video",
|
||||
full: true,
|
||||
help:
|
||||
"A YouTube, Vimeo or Facebook link, or a video file: a filename in " +
|
||||
"the uploads folder, or a link ending in .mp4 or .webm",
|
||||
},
|
||||
{
|
||||
path: "video_still",
|
||||
label: "Video still",
|
||||
widget: "image",
|
||||
crop: 16 / 9,
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
frameFrom: "video_url",
|
||||
help: "Shown before it plays. Default: YouTube's own thumbnail, or a video file's first frame. Frame at takes a still from a YouTube or Facebook video.",
|
||||
},
|
||||
{
|
||||
path: "video_captions",
|
||||
label: "Video captions",
|
||||
widget: "image",
|
||||
folder: "captions",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "A WebVTT (.vtt) file, for a video file; YouTube, Vimeo and Facebook show their own. Default: none.",
|
||||
},
|
||||
{ path: "video_title", label: "Video title", full: true, help: "Shown after \"Featured video\" above the headline" },
|
||||
{
|
||||
path: "hero_event_id",
|
||||
label: "Featured event",
|
||||
widget: "select",
|
||||
optionsFrom: "events",
|
||||
blankLabel: "Default: the countdown's event",
|
||||
full: true,
|
||||
help: "For the Featured event feature. A pinned event that's over falls back to the countdown's",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Countdown",
|
||||
fields: [
|
||||
{
|
||||
path: "countdown_event_id",
|
||||
label: "Count down to",
|
||||
widget: "select",
|
||||
optionsFrom: "events",
|
||||
blankLabel: "Default: the next upcoming event",
|
||||
help: "Leave blank almost always. A pinned event that's over falls back to the next one",
|
||||
},
|
||||
{
|
||||
path: "countdown_scope_id",
|
||||
label: "Only this scope",
|
||||
widget: "select",
|
||||
optionsFrom: "event_scopes",
|
||||
blankLabel: "Default: any scope",
|
||||
help: "Narrows the next upcoming event. Ignored when an event is pinned above",
|
||||
},
|
||||
{
|
||||
path: "countdown_event_type",
|
||||
label: "Only this type",
|
||||
widget: "select",
|
||||
options: [
|
||||
["retreat", "Retreat"],
|
||||
["class", "Class"],
|
||||
["workshop", "Workshop"],
|
||||
["meeting", "Meeting"],
|
||||
["other", "Other"],
|
||||
],
|
||||
blankLabel: "Default: any type",
|
||||
help: "Combines with the scope: National + Retreat counts down to the next national retreat",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Featured Content",
|
||||
note: "The cards themselves are under Featured cards below, each with its own Size.",
|
||||
fields: [
|
||||
{
|
||||
path: "featured_columns",
|
||||
label: "Columns",
|
||||
widget: "select",
|
||||
options: [
|
||||
["2", "2 across"],
|
||||
["3", "3 across"],
|
||||
["4", "4 across"],
|
||||
],
|
||||
blankLabel: "Default: 3 across",
|
||||
help: "On a wide screen. Tablets show 2, phones 1",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
children: [
|
||||
{
|
||||
key: "sections",
|
||||
label: "Page sections",
|
||||
note: "Drag to reorder. Each section can appear once; leave one out to drop it.",
|
||||
addLabel: "Add section",
|
||||
title: (row) =>
|
||||
FRONT_PAGE_SECTIONS.find(([key]) => key === row.section)?.[1] ?? "New section",
|
||||
blank: { section: "", title: "", blurb: "" },
|
||||
fields: [
|
||||
{
|
||||
path: "section",
|
||||
label: "Section",
|
||||
widget: "select",
|
||||
options: FRONT_PAGE_SECTIONS,
|
||||
required: true,
|
||||
},
|
||||
{ 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" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "slides",
|
||||
label: "Hero photos",
|
||||
note: "Shown in Photos mode, in this order.",
|
||||
addLabel: "Add photo",
|
||||
title: (row) => row.caption || row.media || "New photo",
|
||||
blank: { media: "", alt: "", caption: "" },
|
||||
fields: [
|
||||
{ path: "media", label: "Photo", required: true, widget: "image", crop: 16 / 9, resolve: mediaUrl, full: true },
|
||||
{ path: "alt", label: "Description", help: "For screen readers" },
|
||||
{ path: "caption", label: "Caption", full: true },
|
||||
{ path: "link_url", label: "Link", help: "Optional; makes the caption a link" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "stats",
|
||||
label: "Numbers",
|
||||
note: "Counts update themselves. A typed-in number with no value is left out.",
|
||||
addLabel: "Add number",
|
||||
title: (row) => row.label || "New number",
|
||||
blank: { label: "", source: "", value: "" },
|
||||
fields: [
|
||||
{ path: "label", label: "Label", required: true },
|
||||
{
|
||||
path: "source",
|
||||
label: "Number Source",
|
||||
widget: "select",
|
||||
options: STAT_SOURCES,
|
||||
blankLabel: "Default: Print Value",
|
||||
},
|
||||
{ path: "value", label: "Value", help: "The number thats printed" },
|
||||
{ path: "suffix", label: "Suffix", help: "+, k, % …" },
|
||||
{ path: "note", label: "Note", full: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
...featuredCardsChild,
|
||||
fields: [
|
||||
...featuredCardsChild.fields,
|
||||
{
|
||||
path: "size",
|
||||
label: "Size",
|
||||
widget: "select",
|
||||
options: [
|
||||
["normal", "Normal: one cell"],
|
||||
["wide", "Wide: two columns"],
|
||||
["tall", "Tall: two rows"],
|
||||
["large", "Large: two columns, two rows"],
|
||||
],
|
||||
blankLabel: "Default: automatic (the first of three or more is large)",
|
||||
help: "On a wide screen. Phones show one card per row",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "paths",
|
||||
label: "Connect Nav",
|
||||
note: "Each path is a choice a visitor can pick; its actions appear when they do.",
|
||||
addLabel: "Add path",
|
||||
title: (row) => row.label || "New path",
|
||||
blank: { label: "", icon: "", blurb: "" },
|
||||
fields: [
|
||||
{ path: "label", label: "Label", required: true, help: "eg. Attend, Serve…" },
|
||||
{
|
||||
path: "icon",
|
||||
label: "Icon",
|
||||
widget: "select",
|
||||
options: PATH_ICONS,
|
||||
blankLabel: "Default: a dot",
|
||||
},
|
||||
{ path: "blurb", label: "Blurb", full: true },
|
||||
],
|
||||
children: [
|
||||
{
|
||||
key: "actions",
|
||||
label: "Actions",
|
||||
addLabel: "Add action",
|
||||
title: (row) => row.label || "New action",
|
||||
blank: { label: "", url: "" },
|
||||
fields: [
|
||||
{ path: "label", label: "Label", required: true },
|
||||
{ path: "url", label: "Link", required: true },
|
||||
{ path: "description", label: "Description", full: true },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
@ -12,6 +12,8 @@
|
|||
the Community page only (its id), for now. */
|
||||
|
||||
import { FEATURED_KINDS, featuredCardsChild, blocksChild } from "./shared.ts";
|
||||
import { mediaUrl } from "../media.ts";
|
||||
import { PATH_ICONS } from "../../data/pathIcons.ts";
|
||||
|
||||
const PRESETS = {
|
||||
community_blog: "Community blog (its settings are below)",
|
||||
|
|
@ -26,6 +28,12 @@ const PRESETS = {
|
|||
data_request_form: "Data request form (see, correct or delete)",
|
||||
giving: "Giving button (Church Center)",
|
||||
qr_maker: "QR code maker",
|
||||
hero: "Hero (headline, photos, video, livestream or event)",
|
||||
countdown: "Event countdown",
|
||||
calendar: "Event calendar",
|
||||
stats: "Numbers",
|
||||
featured_cards: "Featured cards",
|
||||
connect: "Connect nav (paths to choose from)",
|
||||
};
|
||||
|
||||
const ACCENT_OPTIONS = [
|
||||
|
|
@ -43,6 +51,272 @@ const EVENT_TYPES = [
|
|||
["other", "Other"],
|
||||
];
|
||||
|
||||
|
||||
/* Gates on the section's type. */
|
||||
const IS = (preset) => ({ path: "preset", value: preset });
|
||||
|
||||
const STAT_SOURCES = [
|
||||
["manual", "Print Value Field"],
|
||||
["years_since", "Years Since Value"],
|
||||
["regions", "Count: regions"],
|
||||
["groups", "Count: groups"],
|
||||
["partners", "Count: partners"],
|
||||
["events_held", "Count: past events"],
|
||||
["retreats_held", "Count: past retreats"],
|
||||
["people", "Count: people in database"],
|
||||
["awards_given", "Count: public awards given"],
|
||||
];
|
||||
|
||||
/* The settings of the section types that need them (083): each shows
|
||||
only for its type. A band draws its own heading from the section's
|
||||
title and blurb. */
|
||||
const BAND_FIELDS = [
|
||||
{
|
||||
path: "hero.backdrop",
|
||||
label: "Hero: background",
|
||||
widget: "select",
|
||||
options: [
|
||||
["brand", "Brand: animated color and the dove"],
|
||||
["photos", "Photos: cycles through the hero photos below"],
|
||||
],
|
||||
blankLabel: "Default: brand",
|
||||
help: "Photos with none added shows the brand background",
|
||||
when: IS("hero"),
|
||||
},
|
||||
{
|
||||
path: "hero.feature",
|
||||
label: "Hero: feature",
|
||||
widget: "select",
|
||||
options: [
|
||||
["none", "Nothing: No additional overlay"],
|
||||
["livestream", "Livestream: the stream, with a LIVE badge"],
|
||||
["video", "Featured video: click to play"],
|
||||
["event", "Featured event: an event's card"],
|
||||
],
|
||||
blankLabel: "Default: nothing",
|
||||
help: "Switch to Livestream when you go live, and back when you're done",
|
||||
when: IS("hero"),
|
||||
},
|
||||
{ path: "hero.eyebrow", label: "Hero: eyebrow", help: "Small line above the headline", when: IS("hero") },
|
||||
{ path: "hero.headline", label: "Hero: headline", full: true, when: IS("hero") },
|
||||
{ path: "hero.subhead", label: "Hero: subhead", widget: "textarea", full: true, when: IS("hero") },
|
||||
{ path: "hero.primary_label", label: "Hero: main button label", when: IS("hero") },
|
||||
{ path: "hero.primary_url", label: "Hero: main button link", help: "/page, #section-id or a full URL", when: IS("hero") },
|
||||
{ path: "hero.secondary_label", label: "Hero: second button label", when: IS("hero") },
|
||||
{ path: "hero.secondary_url", label: "Hero: second button link", when: IS("hero") },
|
||||
{ path: "hero.slide_seconds", label: "Hero: seconds per photo", widget: "number", help: "Photos background. 3 to 60. Default: 7", when: IS("hero") },
|
||||
{ path: "hero.livestream_url", label: "Hero: livestream link", full: true, help: "A YouTube, Facebook or Vimeo link, or any embed URL", when: IS("hero") },
|
||||
{ path: "hero.livestream_title", label: "Hero: livestream title", full: true, when: IS("hero") },
|
||||
{
|
||||
path: "hero.video_url",
|
||||
label: "Hero: featured video",
|
||||
full: true,
|
||||
help: "A YouTube, Vimeo or Facebook link, or a video file: a filename in the uploads folder, or a link ending in .mp4 or .webm",
|
||||
when: IS("hero"),
|
||||
},
|
||||
{
|
||||
path: "hero.video_still",
|
||||
label: "Hero: video still",
|
||||
widget: "image",
|
||||
crop: 16 / 9,
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
frameFrom: "hero.video_url",
|
||||
help: "Shown before it plays. Default: YouTube's own thumbnail, or a video file's first frame. Frame at takes a still from a YouTube or Facebook video.",
|
||||
when: IS("hero"),
|
||||
},
|
||||
{
|
||||
path: "hero.video_captions",
|
||||
label: "Hero: video captions",
|
||||
widget: "image",
|
||||
folder: "captions",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "A WebVTT (.vtt) file, for a video file; YouTube, Vimeo and Facebook show their own. Default: none.",
|
||||
when: IS("hero"),
|
||||
},
|
||||
{ path: "hero.video_title", label: "Hero: video title", full: true, help: "Shown after \"Featured video\" above the headline", when: IS("hero") },
|
||||
{
|
||||
path: "hero.event_id",
|
||||
label: "Hero: featured event",
|
||||
widget: "select",
|
||||
optionsFrom: "events",
|
||||
blankLabel: "Default: the page's countdown's event",
|
||||
full: true,
|
||||
help: "For the Featured event feature. A pinned event that's over falls back to the countdown's",
|
||||
when: IS("hero"),
|
||||
},
|
||||
{
|
||||
path: "countdown.event_id",
|
||||
label: "Count down to",
|
||||
widget: "select",
|
||||
optionsFrom: "events",
|
||||
blankLabel: "Default: the next upcoming event",
|
||||
help: "Leave blank almost always. A pinned event that's over falls back to the next one",
|
||||
when: IS("countdown"),
|
||||
},
|
||||
{
|
||||
path: "countdown.scope_id",
|
||||
label: "Countdown: only this scope",
|
||||
widget: "select",
|
||||
optionsFrom: "event_scopes",
|
||||
blankLabel: "Default: any scope",
|
||||
help: "Narrows the next upcoming event. Ignored when an event is pinned above",
|
||||
when: IS("countdown"),
|
||||
},
|
||||
{
|
||||
path: "countdown.event_type",
|
||||
label: "Countdown: only this type",
|
||||
widget: "select",
|
||||
options: [
|
||||
["retreat", "Retreat"],
|
||||
["class", "Class"],
|
||||
["workshop", "Workshop"],
|
||||
["meeting", "Meeting"],
|
||||
["other", "Other"],
|
||||
],
|
||||
blankLabel: "Default: any type",
|
||||
help: "Combines with the scope: National + Retreat counts down to the next national retreat",
|
||||
when: IS("countdown"),
|
||||
},
|
||||
{
|
||||
path: "featured.columns",
|
||||
label: "Featured cards: columns",
|
||||
widget: "select",
|
||||
options: [
|
||||
["2", "2 across"],
|
||||
["3", "3 across"],
|
||||
["4", "4 across"],
|
||||
],
|
||||
blankLabel: "Default: 3 across",
|
||||
help: "On a wide screen. Tablets show 2, phones 1",
|
||||
when: IS("featured_cards"),
|
||||
},
|
||||
{ path: "blog.internal_title", label: "Blog: our posts' heading", help: "Default: From NGU", when: IS("community_blog") },
|
||||
{ path: "blog.internal_slots", label: "Blog: our posts' slots", widget: "number", help: "0 to 12. Pinned posts first, then the newest. Default: 3", when: IS("community_blog") },
|
||||
{ path: "blog.external_title", label: "Blog: community posts' heading", help: "Default: From our community", when: IS("community_blog") },
|
||||
{ path: "blog.external_slots", label: "Blog: community posts' slots", widget: "number", help: "0 to 12. Pinned cards first, then the feeds' newest. Default: 3", when: IS("community_blog") },
|
||||
{ path: "blog.external_url", label: "Blog: button link", help: "eg. https://ngu.substack.com", full: true, when: IS("community_blog") },
|
||||
{ path: "blog.external_label", label: "Blog: button text", help: "Default: Read more on Substack", when: IS("community_blog") },
|
||||
];
|
||||
|
||||
const BAND_CHILDREN = [
|
||||
{
|
||||
key: "slides",
|
||||
label: "Hero photos",
|
||||
note: "Shown with the Photos background, in this order.",
|
||||
addLabel: "Add photo",
|
||||
when: IS("hero"),
|
||||
title: (row) => row.caption || row.media || "New photo",
|
||||
blank: { media: "", alt: "", caption: "" },
|
||||
fields: [
|
||||
{ path: "media", label: "Photo", required: true, widget: "image", crop: 16 / 9, resolve: mediaUrl, full: true },
|
||||
{ path: "alt", label: "Description", help: "For screen readers" },
|
||||
{ path: "caption", label: "Caption", full: true },
|
||||
{ path: "link_url", label: "Link", help: "Optional; makes the caption a link" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "stats",
|
||||
label: "Numbers",
|
||||
note: "Counts update themselves. A typed-in number with no value is left out.",
|
||||
addLabel: "Add number",
|
||||
when: IS("stats"),
|
||||
title: (row) => row.label || "New number",
|
||||
blank: { label: "", source: "", value: "" },
|
||||
fields: [
|
||||
{ path: "label", label: "Label", required: true },
|
||||
{ path: "source", label: "Number Source", widget: "select", options: STAT_SOURCES, blankLabel: "Default: Print Value" },
|
||||
{ path: "value", label: "Value", help: "The number that's printed" },
|
||||
{ path: "suffix", label: "Suffix", help: "+, k, % …" },
|
||||
{ path: "note", label: "Note", full: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
...featuredCardsChild,
|
||||
label: "Featured cards",
|
||||
when: IS("featured_cards"),
|
||||
fields: [
|
||||
...featuredCardsChild.fields,
|
||||
{
|
||||
path: "size",
|
||||
label: "Size",
|
||||
widget: "select",
|
||||
options: [
|
||||
["normal", "Normal: one cell"],
|
||||
["wide", "Wide: two columns"],
|
||||
["tall", "Tall: two rows"],
|
||||
["large", "Large: two columns, two rows"],
|
||||
],
|
||||
blankLabel: "Default: automatic (the first of three or more is large)",
|
||||
help: "On a wide screen. Phones show one card per row",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
...featuredCardsChild,
|
||||
label: "Blog: pinned community posts",
|
||||
note: "Always shown, before the feeds' newest. Paste a post's link and press Fetch preview.",
|
||||
addLabel: "Pin a post",
|
||||
when: IS("community_blog"),
|
||||
blank: { kind: "", url: "", title: "" },
|
||||
fields: featuredCardsChild.fields.map((field) =>
|
||||
field.path === "kind" ? { ...field, options: FEATURED_KINDS.filter(([kind]) => kind !== "record") } : field,
|
||||
),
|
||||
},
|
||||
{
|
||||
key: "blog_posts",
|
||||
label: "Blog: pinned posts (ours)",
|
||||
note: "Always shown, before the newest.",
|
||||
addLabel: "Pin a post",
|
||||
when: IS("community_blog"),
|
||||
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 }],
|
||||
},
|
||||
{
|
||||
key: "feeds",
|
||||
label: "Blog: feeds",
|
||||
note: "RSS or Atom feeds whose newest posts fill the community slots. Read about every 30 minutes.",
|
||||
addLabel: "Add feed",
|
||||
when: IS("community_blog"),
|
||||
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" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "paths",
|
||||
label: "Connect nav: paths",
|
||||
note: "Each path is a choice a visitor can pick; its actions appear when they do.",
|
||||
addLabel: "Add path",
|
||||
when: IS("connect"),
|
||||
title: (row) => row.label || "New path",
|
||||
blank: { label: "", icon: "", blurb: "" },
|
||||
fields: [
|
||||
{ path: "label", label: "Label", required: true, help: "eg. Attend, Serve…" },
|
||||
{ path: "icon", label: "Icon", widget: "select", options: PATH_ICONS, blankLabel: "Default: a dot" },
|
||||
{ path: "blurb", label: "Blurb", full: true },
|
||||
],
|
||||
children: [
|
||||
{
|
||||
key: "actions",
|
||||
label: "Actions",
|
||||
addLabel: "Add action",
|
||||
title: (row) => row.label || "New action",
|
||||
blank: { label: "", url: "" },
|
||||
fields: [
|
||||
{ path: "label", label: "Label", required: true },
|
||||
{ path: "url", label: "Link", required: true },
|
||||
{ path: "description", label: "Description", full: true },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const EVENTS = { path: "preset", value: "events" };
|
||||
const CARDS = { path: "preset", value: "partner_list" };
|
||||
|
||||
|
|
@ -58,7 +332,7 @@ const sectionsChild = (presets: string[]) => ({
|
|||
path: "title",
|
||||
label: "Title",
|
||||
required: true,
|
||||
help: "Up to 30 characters, so it fits the side nav. eg. Mission, Vision & Values",
|
||||
help: "Up to 30 characters, so it fits the side nav (60 on the front page). A band (hero, numbers...) draws it as its heading; the hero's isn't shown. eg. Mission, Vision & Values",
|
||||
},
|
||||
{
|
||||
path: "anchor",
|
||||
|
|
@ -68,6 +342,7 @@ const sectionsChild = (presets: string[]) => ({
|
|||
},
|
||||
{ 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" },
|
||||
{ path: "is_hidden", label: "Hidden", widget: "checkbox", help: "Left off the page for now, kept here." },
|
||||
...(presets.length
|
||||
? [
|
||||
{
|
||||
|
|
@ -125,6 +400,19 @@ const sectionsChild = (presets: string[]) => ({
|
|||
},
|
||||
]
|
||||
: []),
|
||||
...(presets.includes("timeline")
|
||||
? [
|
||||
{
|
||||
path: "view",
|
||||
label: "Shows",
|
||||
widget: "select",
|
||||
options: [["carousel", "A rail of the featured moments (the front page's)"]],
|
||||
blankLabel: "Default: the whole timeline",
|
||||
when: { path: "preset", value: "timeline" },
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...BAND_FIELDS,
|
||||
...(presets.includes("group_map")
|
||||
? [
|
||||
{
|
||||
|
|
@ -139,6 +427,7 @@ const sectionsChild = (presets: string[]) => ({
|
|||
: []),
|
||||
],
|
||||
children: [
|
||||
...BAND_CHILDREN,
|
||||
{
|
||||
key: "tags",
|
||||
label: "Directory: tags",
|
||||
|
|
@ -168,16 +457,11 @@ const sectionsChild = (presets: string[]) => ({
|
|||
],
|
||||
});
|
||||
|
||||
const COMMUNITY = { path: "id", value: "community" };
|
||||
const ALL_PRESETS = Object.keys(PRESETS);
|
||||
|
||||
/* Pages the site's own code links to: their address stays
|
||||
(server/src/admin-schema/sitePages.js, CORE_PAGES). */
|
||||
const CORE_PAGE_IDS = ["home", "give", "feedback", "request", "qr", "privacy", "terms"];
|
||||
const isHome = (row) => row?.id === "home";
|
||||
|
||||
const communityGroups = (groups) => groups.map((group) => ({ ...group, when: COMMUNITY }));
|
||||
const communityChildren = (children) => children.map((child) => ({ ...child, when: COMMUNITY }));
|
||||
|
||||
export const pages = {
|
||||
key: "pages",
|
||||
|
|
@ -186,8 +470,7 @@ export const pages = {
|
|||
idLabel: "URL ID",
|
||||
slugFrom: "title",
|
||||
// Every page's address, title, intro and switches, then its own
|
||||
// sections. The fixed pages (and the front page, edited in Front
|
||||
// page) have no sections here.
|
||||
// sections, the front page's included (its hero and bands).
|
||||
list: {
|
||||
columns: [
|
||||
{ key: "title", label: "Page", primary: true },
|
||||
|
|
@ -229,83 +512,7 @@ export const pages = {
|
|||
{ path: "sort_order", label: "Order", widget: "number", help: "Where its card sits on the admin home, lowest first. Default: 0" },
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Its content",
|
||||
note: "The front page's content is edited in Pages → Front page: its hero, and the bands it shows.",
|
||||
when: { test: isHome },
|
||||
fields: [],
|
||||
},
|
||||
...communityGroups(
|
||||
[
|
||||
{
|
||||
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: [
|
||||
{ ...sectionsChild(ALL_PRESETS), when: { test: (row) => !isHome(row) } },
|
||||
...communityChildren(
|
||||
[
|
||||
{
|
||||
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" },
|
||||
],
|
||||
},
|
||||
]
|
||||
),
|
||||
],
|
||||
children: [sectionsChild(ALL_PRESETS)],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
renders as its own name, so a CHECK is enough.
|
||||
|
||||
Adding a type is three edits: the CHECKs in a migration (on
|
||||
events.event_type and front_page.countdown_event_type), the enums
|
||||
events.event_type and section_countdown.event_type), the enums
|
||||
in both descriptor halves (the event's type and the front page's
|
||||
countdown type), and this list. Adding it here alone
|
||||
means the site offers a filter the database will refuse to store.
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
FRONT PAGE BANDS
|
||||
|
||||
Each band the front page can show (front_page_sections.section):
|
||||
the anchor it sits at, and the heading it gets when the admin gives
|
||||
it none. Home.tsx draws the bands; the nav and footer list the ones
|
||||
the front page is showing (navSections.ts). The countdown has no
|
||||
anchor: it's a card under the hero, not a section to jump to.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import type { FrontPage, FrontPageSectionKey } from './useFrontPage.ts'
|
||||
|
||||
export const FRONT_PAGE_BANDS: Record<FrontPageSectionKey, { id: string | null; title: string }> = {
|
||||
countdown: { id: null, title: 'Next up' },
|
||||
retreats: { id: 'retreats', title: 'National Retreats' },
|
||||
calendar: { id: 'calendar', title: 'What’s on' },
|
||||
stats: { id: 'numbers', title: 'By the numbers' },
|
||||
timeline: { id: 'story', title: 'Our story so far' },
|
||||
connect: { id: 'connect', title: 'Find your way in' },
|
||||
featured: { id: 'featured', title: 'Featured' },
|
||||
}
|
||||
|
||||
/* Whether a band has anything to draw: Home.tsx leaves out a band
|
||||
with nothing in it, and so does the nav. */
|
||||
export function bandShows(page: FrontPage, key: FrontPageSectionKey): boolean {
|
||||
switch (key) {
|
||||
case 'countdown':
|
||||
return Boolean(page.countdown)
|
||||
case 'stats':
|
||||
return page.stats.length > 0
|
||||
case 'connect':
|
||||
return page.paths.length > 0
|
||||
case 'featured':
|
||||
return page.featured.length > 0
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
@ -3,39 +3,27 @@
|
|||
dropdowns, the mobile menu and the footer's site map
|
||||
|
||||
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).
|
||||
or renaming a section changes the menus too (Pages → Page
|
||||
management, GET /site-pages), the front page's included. The hero
|
||||
and a countdown aren't listed: they're the top of a page, not a
|
||||
place to jump to (sections/Bands.tsx).
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useCallback } from 'react'
|
||||
|
||||
import { useSitePageHeadings } from './useSitePages.ts'
|
||||
import { useFrontPage } from './useFrontPage.ts'
|
||||
import { FRONT_PAGE_BANDS, bandShows } from './frontPageBands.ts'
|
||||
import { UNLISTED_PRESETS } from '../pages/sections/Bands.tsx'
|
||||
|
||||
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 (sitePages?.[path] ?? []).map((section) => ({
|
||||
label: section.title,
|
||||
hash: `#${section.anchor}`,
|
||||
}))
|
||||
}
|
||||
if (!page) return []
|
||||
return page.sections.flatMap((section) => {
|
||||
const band = FRONT_PAGE_BANDS[section.section]
|
||||
if (!band?.id || !bandShows(page, section.section)) return []
|
||||
return [{ label: section.title || band.title, hash: `#${band.id}` }]
|
||||
})
|
||||
},
|
||||
[page, sitePages],
|
||||
(path: string) =>
|
||||
(sitePages?.[path] ?? [])
|
||||
.filter((section) => !UNLISTED_PRESETS.includes(section.preset ?? ''))
|
||||
.map((section) => ({ label: section.title, hash: `#${section.anchor}` })),
|
||||
[sitePages],
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,11 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
FRONT PAGE DATA
|
||||
SECTION TYPES' DATA
|
||||
|
||||
GET /front-page, as routes/home.js shapes it: the hero, the
|
||||
visible sections in order, counted stats, paths with actions,
|
||||
and the countdown's event. Edited in the admin under Front page.
|
||||
|
||||
No fallback content. If the request fails the page says so: a
|
||||
plausible default home page would hide a broken server behind
|
||||
something that looks fine.
|
||||
What a band section's `data` holds (server/src/sectionData.js,
|
||||
in GET /site-pages/:id): a hero, a countdown's event, stats, a
|
||||
pathfinder's paths, featured cards. sections/Bands.tsx draws them.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useRecord, type Resource } from './useRecord.ts'
|
||||
import type { EventSeries } from './eventSeries.ts'
|
||||
import type { Link } from './useContent.ts'
|
||||
|
||||
|
|
@ -20,16 +15,6 @@ export type HeroBackdrop = 'brand' | 'photos'
|
|||
/** What sits beside the words, over the backdrop. */
|
||||
export type HeroFeature = 'none' | 'livestream' | 'video' | 'event'
|
||||
|
||||
/** The CHECK list on front_page_sections.section. */
|
||||
export type FrontPageSectionKey =
|
||||
| 'countdown'
|
||||
| 'retreats'
|
||||
| 'calendar'
|
||||
| 'stats'
|
||||
| 'timeline'
|
||||
| 'connect'
|
||||
| 'featured'
|
||||
|
||||
export type HeroButton = { label: string; url: string }
|
||||
|
||||
export type HeroSlide = {
|
||||
|
|
@ -53,18 +38,11 @@ export type Hero = {
|
|||
/** A link to embed or a video file; see videoSource in embeds.ts. */
|
||||
/** `still` is shown before it plays; resolve it with mediaUrl. */
|
||||
video: { url: string; title?: string | null; captions?: string | null; still?: string | null } | null
|
||||
/** With the 'event' feature: the pinned event, else the countdown's. */
|
||||
/** With the 'event' feature: the pinned event, else the page's countdown's. */
|
||||
event: HeroEvent | null
|
||||
}
|
||||
|
||||
export type FrontPageSection = {
|
||||
section: FrontPageSectionKey
|
||||
/** Null → the section's own heading. */
|
||||
title?: string | null
|
||||
blurb?: string | null
|
||||
}
|
||||
|
||||
export type FrontPageStat = {
|
||||
export type SectionStat = {
|
||||
label: string
|
||||
/** Already counted or typed; never null, since the API drops those. */
|
||||
value: string
|
||||
|
|
@ -74,7 +52,7 @@ export type FrontPageStat = {
|
|||
|
||||
export type PathAction = { label: string; description?: string | null; url: string }
|
||||
|
||||
export type FrontPagePath = {
|
||||
export type SectionPath = {
|
||||
label: string
|
||||
icon?: string | null
|
||||
blurb?: string | null
|
||||
|
|
@ -122,17 +100,3 @@ export type HeroEvent = CountdownEvent & {
|
|||
org_logo?: string | null
|
||||
links: Link[]
|
||||
}
|
||||
|
||||
export type FrontPage = {
|
||||
hero: Hero
|
||||
sections: FrontPageSection[]
|
||||
stats: FrontPageStat[]
|
||||
paths: FrontPagePath[]
|
||||
featured: FeaturedCard[]
|
||||
/** Columns across on a wide screen; null is the grid's default. */
|
||||
featured_columns: FeaturedColumns | null
|
||||
countdown: CountdownEvent | null
|
||||
}
|
||||
|
||||
export const useFrontPage = (): Resource<FrontPage> =>
|
||||
useRecord<FrontPage>('/front-page', 'front_page')
|
||||
|
|
@ -1,15 +1,16 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
BLOG DATA
|
||||
|
||||
GET /blog/:id and GET /community-blog, as routes/blog.js shapes
|
||||
them. The section's community posts arrive as featured cards, so
|
||||
GET /blog/:id, as routes/blog.js shapes it, and what a Community
|
||||
blog section shows (its `data`, server/src/sectionData.js). The
|
||||
section's community posts arrive as featured cards, so
|
||||
FeaturedCards.tsx draws them unchanged.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { detailPath } from './hrefs.ts'
|
||||
import { useRecord, type Resource } from './useRecord.ts'
|
||||
import type { ContentBlock } from './useContent.ts'
|
||||
import type { FeaturedCard } from './useFrontPage.ts'
|
||||
import type { FeaturedCard } from './sectionTypes.ts'
|
||||
|
||||
export type BlogAuthor = {
|
||||
id: string
|
||||
|
|
@ -59,8 +60,6 @@ export type CommunityBlog = {
|
|||
export const useBlogPost = (id?: string | null): Resource<BlogPostRecord> =>
|
||||
useRecord<BlogPostRecord>(detailPath('/blog', id), 'post')
|
||||
|
||||
export const useCommunityBlog = (): Resource<CommunityBlog> =>
|
||||
useRecord<CommunityBlog>('/community-blog', 'community_blog')
|
||||
|
||||
/** '2026-09-01' → 'September 1, 2026'. Parsed as a local date, so
|
||||
* it can't slip a day in a timezone west of UTC. */
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
*/
|
||||
|
||||
import type { BlogPostSummary } from './useBlog.ts'
|
||||
import type { FeaturedCard } from './useFrontPage.ts'
|
||||
import type { FeaturedCard } from './sectionTypes.ts'
|
||||
import { detailPath } from './hrefs.ts'
|
||||
import { useRecord, type Resource } from './useRecord.ts'
|
||||
import type { EventType } from './eventTypes.ts'
|
||||
|
|
|
|||
|
|
@ -21,11 +21,14 @@ export type SitePageSection = {
|
|||
org_kinds?: string | null
|
||||
/** Organization cards: a hand-picked list, in order, shown instead. */
|
||||
org_ids: string[]
|
||||
/** What its type shows beyond its blocks (server/src/sectionData.js):
|
||||
* a hero, a countdown's event, stats, paths, featured cards, a blog. */
|
||||
data?: any
|
||||
blocks: ContentBlock[]
|
||||
}
|
||||
|
||||
export const useSitePage = (id: string): Resource<{ id: string; title: string; description: string | null; sections: SitePageSection[] }> =>
|
||||
useRecord(`/site-pages/${id}`, 'page')
|
||||
|
||||
export const useSitePageHeadings = (): Resource<Record<string, Array<{ anchor: string; title: string }>>> =>
|
||||
export const useSitePageHeadings = (): Resource<Record<string, Array<{ anchor: string; title: string; preset: string | null }>>> =>
|
||||
useRecord('/site-pages', 'pages')
|
||||
|
|
|
|||
|
|
@ -1,129 +0,0 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
HOME: /
|
||||
|
||||
Not a PageShell page: the front page has no title bar, and each
|
||||
band draws its own heading in its own style.
|
||||
|
||||
Driven by the admin's Front page editor through GET /front-page.
|
||||
The hero comes first, always. After it, the bands in the order
|
||||
the admin dragged them into, minus any they hid. Which component
|
||||
draws a band is decided here, in SECTIONS, keyed on the same list
|
||||
the CHECK on front_page_sections holds, the database says "retreats,
|
||||
third, called National Retreats"; this file says what a retreats
|
||||
band looks like.
|
||||
|
||||
A band with nothing to show draws nothing: the countdown with no
|
||||
upcoming event, the numbers with no numbers, the timeline with
|
||||
nothing featured, the pathfinder with no paths, the featured band
|
||||
with no cards.
|
||||
|
||||
If /front-page fails, the hero still draws (empty) and the error
|
||||
takes the place of the bands, with a retry. There's deliberately
|
||||
no default page to fall back to: it would look fine and hide a
|
||||
broken server.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useEffect, type ReactNode } from 'react'
|
||||
|
||||
import HeroStage from './sections/home/HeroStage.tsx'
|
||||
import NextEventCountdown from './sections/home/NextEventCountdown.tsx'
|
||||
import RetreatsBand from './sections/home/RetreatsBand.tsx'
|
||||
import CalendarBand from './sections/home/CalendarBand.tsx'
|
||||
import StatsBand from './sections/home/StatsBand.tsx'
|
||||
import FeaturedBand from './sections/home/FeaturedBand.tsx'
|
||||
import FeaturedTimelineRail from './sections/home/FeaturedTimelineRail.tsx'
|
||||
import Pathfinder from './sections/home/Pathfinder.tsx'
|
||||
import { get } from '../lib/api.ts'
|
||||
import { documentTitle } from '../lib/site.ts'
|
||||
import {
|
||||
useFrontPage,
|
||||
type FrontPage,
|
||||
type FrontPageSection,
|
||||
type FrontPageSectionKey,
|
||||
} from '../lib/useFrontPage.ts'
|
||||
import { FRONT_PAGE_BANDS, bandShows } from '../lib/frontPageBands.ts'
|
||||
import './sections/home/home.css'
|
||||
|
||||
type BandProps = {
|
||||
page: FrontPage
|
||||
section: FrontPageSection
|
||||
title: string
|
||||
/** Position among the visible bands, 0 = straight after the hero. */
|
||||
position: number
|
||||
}
|
||||
|
||||
/* How each band renders. Its anchor, its heading when the admin
|
||||
gave it none, and whether it has anything to draw are
|
||||
frontPageBands.ts's, which the nav and footer read too; #connect is
|
||||
what the hero's second button points at out of the box. */
|
||||
const id = (key: FrontPageSectionKey) => FRONT_PAGE_BANDS[key].id ?? undefined
|
||||
|
||||
const BANDS: Record<FrontPageSectionKey, (props: BandProps) => ReactNode> = {
|
||||
countdown: ({ page, position }) => <NextEventCountdown event={page.countdown!} overlap={position === 0} />,
|
||||
retreats: ({ section, title }) => <RetreatsBand id={id('retreats')!} title={title} blurb={section.blurb} />,
|
||||
calendar: ({ section, title }) => <CalendarBand id={id('calendar')!} title={title} blurb={section.blurb} />,
|
||||
stats: ({ page, section, title }) => (
|
||||
<StatsBand id={id('stats')!} title={title} blurb={section.blurb} stats={page.stats} />
|
||||
),
|
||||
timeline: ({ section, title }) => <FeaturedTimelineRail id={id('timeline')!} title={title} blurb={section.blurb} />,
|
||||
connect: ({ page, section, title }) => (
|
||||
<Pathfinder id={id('connect')!} title={title} blurb={section.blurb} paths={page.paths} />
|
||||
),
|
||||
featured: ({ page, section, title }) => (
|
||||
<FeaturedBand id={id('featured')!} title={title} blurb={section.blurb} cards={page.featured} columns={page.featured_columns} />
|
||||
),
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
const { data: page, error, reload } = useFrontPage()
|
||||
|
||||
// The bands below ask for the timeline once the front page has said
|
||||
// which of them to show. Start it now, alongside it: api.ts hands the
|
||||
// same request to the band when it mounts, so the page waits for one
|
||||
// round trip instead of two. Events aren't fetched ahead: each band
|
||||
// asks the server for only its own, so there's no one list to start.
|
||||
useEffect(() => {
|
||||
get('/history').catch(() => {})
|
||||
}, [])
|
||||
|
||||
// Back to the site name when a visitor returns here from a page.
|
||||
useEffect(() => {
|
||||
document.title = documentTitle()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<HeroStage hero={page?.hero ?? null} />
|
||||
|
||||
{error && (
|
||||
<section className="px-6 py-24 text-center">
|
||||
<p className="text-danger">Couldn’t load the front page. {error}</p>
|
||||
<button
|
||||
type="button"
|
||||
onClick={reload}
|
||||
className="mt-4 btn border border-brand px-5 py-2 text-link hover:bg-tint"
|
||||
>
|
||||
Try again
|
||||
</button>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{page?.sections.map((section, position) => {
|
||||
const render = BANDS[section.section]
|
||||
// A key the CHECK has gained since this file was written, or a
|
||||
// band with nothing to draw.
|
||||
if (!render || !bandShows(page, section.section)) return null
|
||||
return (
|
||||
<div key={section.section}>
|
||||
{render({
|
||||
page,
|
||||
section,
|
||||
title: section.title || FRONT_PAGE_BANDS[section.section].title,
|
||||
position,
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
Pages → Page management decides what's where: the site_pages row
|
||||
at this path (useSiteNav), drawn as its sections (SitePage). The
|
||||
front page is the index route of its own (Home.tsx). No page there
|
||||
front page is the index route, SitePage too. No page there
|
||||
(or a hidden one, below viewer, which isn't sent): Not found.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,21 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
SITE PAGE: /community, /retreats, /resources, /organization,
|
||||
/history
|
||||
SITE PAGE: every page of the site, the front page included
|
||||
|
||||
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.
|
||||
Each is a list of sections built in the admin (Pages → Page
|
||||
management, 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. A band (the hero, the countdown, the numbers...:
|
||||
sections/Bands.tsx) draws itself, heading and all.
|
||||
|
||||
Two layouts:
|
||||
the front page no title bar: the bands one after another, as
|
||||
they always were, and any other section as a
|
||||
band of its own in the same style
|
||||
any other page PageShell: the title and intro, then each
|
||||
section under its heading (a band without one,
|
||||
since it draws its own)
|
||||
|
||||
The title and intro are its site_pages row's (Pages → Page
|
||||
management), which also give the search metadata.
|
||||
|
|
@ -16,6 +25,8 @@ import { useEffect } from 'react'
|
|||
import { useLocation } from 'react-router-dom'
|
||||
|
||||
import PageShell from '../components/PageShell.tsx'
|
||||
import { documentTitle } from '../lib/site.ts'
|
||||
import { bandFor, UNLISTED_PRESETS } from './sections/Bands.tsx'
|
||||
import ComingSoon from '../components/ComingSoon.tsx'
|
||||
import ContentBlocks from '../components/ContentBlocks.tsx'
|
||||
import { useSiteNav } from '../lib/useSiteNav.ts'
|
||||
|
|
@ -45,9 +56,10 @@ const PROGRAM_START_YEAR = 2000
|
|||
const NO_EVENT_REQUEST_SCOPES = ['national']
|
||||
|
||||
const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>> = {
|
||||
community_blog: () => ({
|
||||
community_blog: (section) => ({
|
||||
Component: CommunityBlog,
|
||||
request: { type: 'blog', label: 'Write for the blog' },
|
||||
props: { blog: section.data },
|
||||
}),
|
||||
group_map: (section) => ({
|
||||
Component: OrgListMap,
|
||||
|
|
@ -103,12 +115,16 @@ const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>>
|
|||
qr_maker: () => ({ Component: QrSection }),
|
||||
}
|
||||
|
||||
/* The front page's id (site_pages). */
|
||||
export const HOME = 'home'
|
||||
|
||||
export default function SitePage({ id }: { id: string }) {
|
||||
const { data: page, loading, error } = useSitePage(id)
|
||||
const { data: page, loading, error, reload } = useSitePage(id)
|
||||
// Its title and intro: its own data, or the nav's until that comes.
|
||||
const known = useSiteNav().pages.find((p) => p.id === id)
|
||||
const PAGE = { title: page?.title ?? known?.title ?? '', description: page?.description ?? known?.description ?? undefined }
|
||||
|
||||
if (id === HOME) return <FrontPage sections={page?.sections ?? null} error={error} reload={reload} />
|
||||
if (page) return <Sections title={PAGE.title} intro={PAGE.description ?? undefined} sections={page.sections} />
|
||||
|
||||
return (
|
||||
|
|
@ -136,8 +152,21 @@ function Sections({ title, intro, sections }: { title: string; intro?: string; s
|
|||
}, [hash])
|
||||
|
||||
const manifest = useSectionManifest(
|
||||
sections.map((section) => {
|
||||
sections.map((section, index) => {
|
||||
const accent = ACCENTS[section.accent ?? 'teal'] ?? BRAND
|
||||
// A band draws itself, heading and all: no heading of the shell's.
|
||||
const band = bandFor(section)
|
||||
if (band) {
|
||||
const node = band(section, { afterHero: sections[index - 1]?.preset === 'hero' })
|
||||
return {
|
||||
id: section.anchor,
|
||||
title: section.title,
|
||||
accent,
|
||||
bare: true,
|
||||
unlisted: UNLISTED_PRESETS.includes(section.preset ?? ''),
|
||||
Component: () => node,
|
||||
}
|
||||
}
|
||||
const preset = section.preset ? PRESETS[section.preset]?.(section) : null
|
||||
return {
|
||||
id: section.anchor,
|
||||
|
|
@ -155,6 +184,72 @@ function Sections({ title, intro, sections }: { title: string; intro?: string; s
|
|||
return <PageShell sideNav title={title} intro={intro} sections={manifest} />
|
||||
}
|
||||
|
||||
/* The front page: its bands one after another, under no title bar. A
|
||||
section that isn't a band is one in the same style: its heading,
|
||||
then its blocks and preset. If the page can't load, the error
|
||||
takes the bands' place, with a retry: there's deliberately no
|
||||
default page to fall back to, which would hide a broken server. */
|
||||
function FrontPage({ sections, error, reload }: { sections: SitePageSection[] | null; error: string | null; reload: () => void }) {
|
||||
const { hash } = useLocation()
|
||||
useEffect(() => {
|
||||
if (hash) jumpTo(decodeURIComponent(hash.slice(1)))
|
||||
}, [hash, sections])
|
||||
|
||||
// Back to the site name when a visitor returns here from a page.
|
||||
useEffect(() => {
|
||||
document.title = documentTitle()
|
||||
}, [])
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<section className="px-6 py-24 text-center">
|
||||
<p className="text-danger">Couldn’t load the front page. {error}</p>
|
||||
<button type="button" onClick={reload} className="mt-4 btn border border-brand px-5 py-2 text-link hover:bg-tint">
|
||||
Try again
|
||||
</button>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
if (!sections) return null
|
||||
|
||||
return (
|
||||
<>
|
||||
{sections.map((section, index) => {
|
||||
const band = bandFor(section)
|
||||
return (
|
||||
<div key={section.anchor}>
|
||||
{band ? band(section, { afterHero: sections[index - 1]?.preset === 'hero' }) : <PlainBand section={section} />}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/* A section on the front page that isn't a band: the bands' heading,
|
||||
then its blocks and preset as on any page. */
|
||||
function PlainBand({ section }: { section: SitePageSection }) {
|
||||
const accent = ACCENTS[section.accent ?? 'teal'] ?? BRAND
|
||||
const preset = section.preset ? PRESETS[section.preset]?.(section) : null
|
||||
const views = preset?.views
|
||||
return (
|
||||
<section id={section.anchor} className="py-24">
|
||||
<div className="mx-auto mb-12 max-w-6xl px-6">
|
||||
<h2 className="font-display text-4xl font-bold text-ink md:text-5xl">{section.title}</h2>
|
||||
{section.blurb && <p className="mt-3 max-w-xl text-lg text-muted">{section.blurb}</p>}
|
||||
</div>
|
||||
<SectionBody
|
||||
blocks={section.blocks}
|
||||
title={section.title}
|
||||
Preset={preset?.Component}
|
||||
presetProps={preset?.props}
|
||||
accent={accent}
|
||||
{...(views ? { view: views.default } : {})}
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
function SectionBody({ blocks, title, Preset, presetProps, ...rest }: any) {
|
||||
if (!blocks.length && !Preset) return <ComingSoon what={`our ${title}`} />
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -133,8 +133,7 @@ const QUICK_ADD = [
|
|||
{ to: "/admin/timeline/new", label: "New timeline entry" },
|
||||
];
|
||||
|
||||
/* A card per page (Pages → Page management), in its order: the
|
||||
front page's opens Front page, the others their page. */
|
||||
/* A card per page (Pages → Page management), in its order. */
|
||||
function usePageCards() {
|
||||
const [cards, setCards] = useState<any[]>([]);
|
||||
useEffect(() => {
|
||||
|
|
@ -142,7 +141,7 @@ function usePageCards() {
|
|||
.then((list) =>
|
||||
setCards(
|
||||
list.rows.map((page) => ({
|
||||
to: page.id === "home" ? "/admin/front_page" : `/admin/pages/${page.id}`,
|
||||
to: `/admin/pages/${page.id}`,
|
||||
label: page.title,
|
||||
blurb: [page.path, page.is_hidden ? "Hidden" : null, page.is_disabled ? "Disabled" : null]
|
||||
.filter(Boolean)
|
||||
|
|
@ -172,7 +171,6 @@ export default function AdminHome() {
|
|||
{GROUPS.map(({ nav, color }) => (
|
||||
<CardBlock key={nav.label} title={nav.label} blurb={nav.blurb} color={color}>
|
||||
{visibleItems(nav.children, user)
|
||||
.filter((item) => !item.menuOnly)
|
||||
.flatMap((item) =>
|
||||
// Every page gets a card of its own after the banner.
|
||||
item.banner
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ import { blocksChild, BLOCK_TYPES } from '../../lib/adminSchema/shared.ts'
|
|||
import { Repeater } from '../../components/admin/fields.tsx'
|
||||
import NewsletterRecipients from '../../components/admin/NewsletterRecipients.tsx'
|
||||
import { useEvents } from '../../lib/eventData.ts'
|
||||
import { useFrontPage, type FeaturedCard } from '../../lib/useFrontPage.ts'
|
||||
import type { FeaturedCard } from '../../lib/sectionTypes.ts'
|
||||
import { useSitePage } from '../../lib/useSitePages.ts'
|
||||
import type { BlogPostRecord } from '../../lib/useBlog.ts'
|
||||
import { blogHref, eventHref, refHref } from '../../lib/hrefs.ts'
|
||||
import { mediaUrl } from '../../lib/media.ts'
|
||||
|
|
@ -274,8 +275,11 @@ export default function AdminNewsletter() {
|
|||
const [message, setMessage] = useState<{ tone: 'ok' | 'error'; text: string } | null>(null)
|
||||
|
||||
const { events, loading: eventsLoading } = useEvents({ status: 'upcoming' })
|
||||
const { data: frontPage } = useFrontPage()
|
||||
const cards = frontPage?.featured ?? []
|
||||
// The front page's featured cards: its featured card sections'.
|
||||
const { data: frontPage } = useSitePage('home')
|
||||
const cards: FeaturedCard[] = (frontPage?.sections ?? [])
|
||||
.filter((section) => section.preset === 'featured_cards')
|
||||
.flatMap((section) => section.data?.cards ?? [])
|
||||
|
||||
useEffect(() => {
|
||||
get('/admin/blog_posts?is_published=1&is_listed=1&limit=200', { ttl: 0 })
|
||||
|
|
|
|||
|
|
@ -128,18 +128,11 @@ export const PAGES_NAV = {
|
|||
blurb: "Every page of the site: make new ones, change an address, title or intro, and hide or disable any of them. Then each page's sections.",
|
||||
banner: true,
|
||||
children: [
|
||||
{ to: "/admin/pages/home", label: "Front page" },
|
||||
{ to: "/admin/pages/new", label: "New page" },
|
||||
{ to: "/admin/navigation", label: "Menus (Navigation)" },
|
||||
],
|
||||
},
|
||||
// One record, not a list: the item opens it directly. On the
|
||||
// admin home, the Home page's own card goes here instead.
|
||||
{
|
||||
to: "/admin/front_page",
|
||||
label: "Front page",
|
||||
blurb: "The hero, its photos or livestream, and which bands the home page draws.",
|
||||
menuOnly: true,
|
||||
},
|
||||
{
|
||||
to: "/admin/navigation",
|
||||
label: "Navigation",
|
||||
|
|
|
|||
74
src/pages/sections/Bands.tsx
Normal file
74
src/pages/sections/Bands.tsx
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
BANDS
|
||||
|
||||
The section types that draw a whole band of their own, heading
|
||||
included, in the front page's style (083: they were the front
|
||||
page's, and go on any page now): the hero, the countdown, the
|
||||
calendar, the numbers, featured cards, the pathfinder, and the
|
||||
timeline's rail of featured moments (a timeline section opened as
|
||||
'carousel'). SitePage.tsx draws them as they are on the front
|
||||
page, and without its own heading on any other page.
|
||||
|
||||
Each takes the section (its anchor, title, blurb) and what its
|
||||
type shows (`data`, server/src/sectionData.js). A band with
|
||||
nothing to show draws nothing: the countdown with no upcoming
|
||||
event, the numbers with no numbers, the pathfinder with no paths,
|
||||
featured cards with no cards.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
import HeroStage from './home/HeroStage.tsx'
|
||||
import NextEventCountdown from './home/NextEventCountdown.tsx'
|
||||
import CalendarBand from './home/CalendarBand.tsx'
|
||||
import StatsBand from './home/StatsBand.tsx'
|
||||
import FeaturedBand from './home/FeaturedBand.tsx'
|
||||
import FeaturedTimelineRail from './home/FeaturedTimelineRail.tsx'
|
||||
import Pathfinder from './home/Pathfinder.tsx'
|
||||
import type { SitePageSection } from '../../lib/useSitePages.ts'
|
||||
import './home/home.css'
|
||||
|
||||
type BandContext = {
|
||||
/** The section before it is a hero: a countdown overlaps its foot. */
|
||||
afterHero: boolean
|
||||
}
|
||||
|
||||
type Band = (section: SitePageSection, context: BandContext) => ReactNode
|
||||
|
||||
const BANDS: Record<string, Band> = {
|
||||
hero: (section) => <HeroStage hero={section.data ?? null} />,
|
||||
countdown: (section, { afterHero }) =>
|
||||
section.data ? <NextEventCountdown event={section.data} overlap={afterHero} /> : null,
|
||||
calendar: (section) => <CalendarBand id={section.anchor} title={section.title} blurb={section.blurb} />,
|
||||
stats: (section) =>
|
||||
section.data?.length ? (
|
||||
<StatsBand id={section.anchor} title={section.title} blurb={section.blurb} stats={section.data} />
|
||||
) : null,
|
||||
featured_cards: (section) =>
|
||||
section.data?.cards?.length ? (
|
||||
<FeaturedBand
|
||||
id={section.anchor}
|
||||
title={section.title}
|
||||
blurb={section.blurb}
|
||||
cards={section.data.cards}
|
||||
columns={section.data.columns}
|
||||
/>
|
||||
) : null,
|
||||
connect: (section) =>
|
||||
section.data?.length ? (
|
||||
<Pathfinder id={section.anchor} title={section.title} blurb={section.blurb} paths={section.data} />
|
||||
) : null,
|
||||
}
|
||||
|
||||
/* The band a section draws, or undefined when its type isn't one
|
||||
(it's its blocks and preset, in a plain section). */
|
||||
export function bandFor(section: SitePageSection): Band | undefined {
|
||||
if (section.preset === 'timeline' && section.view === 'carousel') {
|
||||
return () => <FeaturedTimelineRail id={section.anchor} title={section.title} blurb={section.blurb} />
|
||||
}
|
||||
return section.preset ? BANDS[section.preset] : undefined
|
||||
}
|
||||
|
||||
/* Section types the menus don't list: the hero and the countdown are
|
||||
the top of a page, not places to jump to. */
|
||||
export const UNLISTED_PRESETS = ['hero', 'countdown']
|
||||
|
|
@ -21,7 +21,7 @@ import PlatformIcon from '../../components/PlatformIcon.tsx'
|
|||
import { blogHref } from '../../lib/hrefs.ts'
|
||||
import { mediaUrl } from '../../lib/media.ts'
|
||||
import { preview } from '../../lib/text.ts'
|
||||
import { postDate, useCommunityBlog, type BlogPostSummary } from '../../lib/useBlog.ts'
|
||||
import { postDate, type BlogPostSummary, type CommunityBlog as CommunityBlogData } from '../../lib/useBlog.ts'
|
||||
import HomeLink from './home/HomeLink.tsx'
|
||||
import { accentText, BRAND } from '../../lib/color.ts'
|
||||
import { useSmallImage } from '../../lib/useSmallImage.ts'
|
||||
|
|
@ -83,25 +83,10 @@ function Subheading({ children, accent }: { children: string; accent: string })
|
|||
)
|
||||
}
|
||||
|
||||
export default function CommunityBlog({ accent = BRAND }: { accent?: string }) {
|
||||
const { data: blog, loading, error, reload } = useCommunityBlog()
|
||||
|
||||
if (!blog) {
|
||||
return (
|
||||
<div className="mx-auto max-w-6xl px-6 text-muted">
|
||||
{loading ? (
|
||||
'Loading…'
|
||||
) : (
|
||||
<>
|
||||
Couldn’t load the blog. {error}{' '}
|
||||
<button type="button" onClick={reload} className="underline" style={{ color: accentText(accent) }}>
|
||||
Try again
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
/* Its posts come with the page (the section's data), so there's no
|
||||
loading here: the page has it or the page says it couldn't load. */
|
||||
export default function CommunityBlog({ blog, accent = BRAND }: { blog?: CommunityBlogData | null; accent?: string }) {
|
||||
if (!blog) return null
|
||||
|
||||
const { internal, external } = blog
|
||||
const hasInternal = internal.posts.length > 0
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import FeaturedCards from '../../../components/FeaturedCards.tsx'
|
||||
import type { FeaturedCard, FeaturedColumns } from '../../../lib/useFrontPage.ts'
|
||||
import type { FeaturedCard, FeaturedColumns } from '../../../lib/sectionTypes.ts'
|
||||
|
||||
type FeaturedBandProps = {
|
||||
id: string
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ import { focusOnMount } from '../../../lib/focus.ts'
|
|||
import { useReadingMode } from '../../../lib/readingMode.ts'
|
||||
import { eventHref } from '../../../lib/hrefs.ts'
|
||||
import { seriesLabel } from '../../../lib/eventSeries.ts'
|
||||
import type { Hero, HeroBackdrop, HeroEvent, HeroFeature, HeroSlide } from '../../../lib/useFrontPage.ts'
|
||||
import type { Hero, HeroBackdrop, HeroEvent, HeroFeature, HeroSlide } from '../../../lib/sectionTypes.ts'
|
||||
|
||||
const DEEP = '#001011'
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import { Link } from 'react-router-dom'
|
|||
|
||||
import { eventHref } from '../../../lib/hrefs.ts'
|
||||
import { upcomingOccurrences } from '../../../lib/eventSeries.ts'
|
||||
import type { CountdownEvent } from '../../../lib/useFrontPage.ts'
|
||||
import type { CountdownEvent } from '../../../lib/sectionTypes.ts'
|
||||
import { withAlpha, accentText, BRAND } from '../../../lib/color.ts'
|
||||
import { useReadingMode } from '../../../lib/readingMode.ts'
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
The connect section as a question rather than a wall of forms:
|
||||
pick what you're here for, and that path's actions arrive. Paths
|
||||
and actions are the admin's (Front page → Find your way in);
|
||||
and actions are the admin's (a Connect nav section's paths, Pages → Page management);
|
||||
a path with no actions never reaches this component.
|
||||
|
||||
The choices are a real tablist: arrow keys move between them,
|
||||
|
|
@ -28,7 +28,7 @@ import { ArrowRight, ArrowUpRight, BookOpen, Dot, CalendarBlank, ChatCircle, Com
|
|||
import { useId, useRef, useState, type CSSProperties, type KeyboardEvent } from 'react'
|
||||
|
||||
import HomeLink, { isExternal } from './HomeLink.tsx'
|
||||
import type { FrontPagePath } from '../../../lib/useFrontPage.ts'
|
||||
import type { SectionPath } from '../../../lib/sectionTypes.ts'
|
||||
import { ACCENTS, accentText, readableOn } from '../../../lib/color.ts'
|
||||
import { useReadingMode } from '../../../lib/readingMode.ts'
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ type PathfinderProps = {
|
|||
id: string
|
||||
title: string
|
||||
blurb?: string | null
|
||||
paths: FrontPagePath[]
|
||||
paths: SectionPath[]
|
||||
}
|
||||
|
||||
/* One accent per position, cycling. Paths are data; color is
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
RETREATS BAND
|
||||
|
||||
The National Retreats carousel from the Retreats page, as-is:
|
||||
same component, same filter, so an event edited in the admin
|
||||
shows up identically in both places. This file only adds the
|
||||
front page's heading and a way through to the full page.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { ArrowRight } from '@phosphor-icons/react'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
import EventListCards from '../EventList-Cards.tsx'
|
||||
import { accentText, BRAND } from '../../../lib/color.ts'
|
||||
|
||||
|
||||
type RetreatsBandProps = { id: string; title: string; blurb?: string | null }
|
||||
|
||||
export default function RetreatsBand({ id, title, blurb }: RetreatsBandProps) {
|
||||
return (
|
||||
<section id={id} className="overflow-hidden py-24">
|
||||
<div className="mx-auto mb-12 flex max-w-6xl flex-wrap items-end gap-6 px-6">
|
||||
<div>
|
||||
<h2 className="font-display text-4xl font-bold text-ink md:text-5xl">
|
||||
{title}
|
||||
</h2>
|
||||
{blurb && <p className="mt-3 max-w-xl text-lg text-muted">{blurb}</p>}
|
||||
</div>
|
||||
<Link
|
||||
to="/retreats"
|
||||
className="ml-auto btn border px-5 py-2 text-sm transition-colors hover:bg-surface"
|
||||
style={{ borderColor: BRAND, color: accentText(BRAND) }}
|
||||
>
|
||||
All retreats <ArrowRight size="1em" weight="bold" className="inline align-[-0.125em]" aria-hidden="true" />
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<EventListCards scope="national" type="retreat" view="carousel" accent={BRAND} />
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
|
||||
import type { FrontPageStat } from '../../../lib/useFrontPage.ts'
|
||||
import type { SectionStat } from '../../../lib/sectionTypes.ts'
|
||||
import { prefersLessMotion } from '../../../lib/motion.ts'
|
||||
import { useReadingMode } from '../../../lib/readingMode.ts'
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ type StatsBandProps = {
|
|||
id: string
|
||||
title: string
|
||||
blurb?: string | null
|
||||
stats: FrontPageStat[]
|
||||
stats: SectionStat[]
|
||||
}
|
||||
|
||||
export default function StatsBand({ id, title, blurb, stats }: StatsBandProps) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue