NGU-Web/src/lib/adminSchema/sitePages.ts
Zaldimmar f65664217e Details & Contact as blocks, not a preset; the side nav sits in the margin instead of shifting the sections
Migration 058 turns the organization_details preset into the
section's own blocks and drops it from page_sections' CHECK. The side
nav is placed in the left margin beside the 72rem content, from 88rem
screens up, so sections stay where they'd be without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 03:28:03 -05:00

214 lines
7.3 KiB
TypeScript

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