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:
Aidan Dona 2026-10-17 00:34:56 -05:00
parent f33c0008fe
commit f1a0b06ac2
46 changed files with 1525 additions and 1339 deletions

View file

@ -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.

View file

@ -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 },
],
},
],
},
],
};

View file

@ -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)],
};

View file

@ -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.

View file

@ -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
}
}

View file

@ -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],
)
}

View file

@ -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')

View file

@ -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. */

View file

@ -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'

View file

@ -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')