/* ── 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", people_directory: "People directory (a tag's people)", }; 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("people_directory") ? [ { path: "tag_id", label: "Directory: tag", widget: "select", optionsFrom: "person_tag_types", blankLabel: "Default: none (shows nothing)", help: "Shows the first of its people and links to the full directory", when: { path: "preset", value: "people_directory" }, }, ] : []), ...(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 = {}) => ({ 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", "people_directory"], { 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", ["people_directory"]); export const organizationPage = sitePage("organization", "Organization page", ["people_directory"]); export const historyPage = sitePage("history", "History page", ["timeline"]);