Page management, step 1: every page in a registry, new pages, hidden and disabled

Migration 080 makes site_pages the list of every page: address, title,
intro, Hidden, Disabled (out of menus, sitemap and search) and card order.
site.json's pages and Navigation's page list move into it. Pages ->
Page management (one editor in place of six) makes new pages of sections
at any free address; the admin home opens Pages with a banner and a card
per page. A catch-all route draws whatever page is at an address; the
fixed pages take their words from the registry and can't be deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aidan Dona 2026-10-16 23:19:54 -05:00
parent 56acedf926
commit 1342691f49
36 changed files with 584 additions and 405 deletions

View file

@ -49,16 +49,9 @@ const lazyPage = (load) =>
throw err
}),
)
// Community, Retreats, Resources, Organization, History and Shop:
// each built in the admin from sections.
const SitePage = lazyPage(() => import("./pages/SitePage.tsx"))
const Feedback = lazyPage(() => import("./pages/Feedback.tsx"))
const Request = lazyPage(() => import("./pages/Request.tsx"))
const Giving = lazyPage(() => import("./pages/Giving.tsx"))
const QrCodes = lazyPage(() => import("./pages/QrCodes.tsx"))
const Privacy = lazyPage(() => import("./pages/Privacy.tsx"))
const Terms = lazyPage(() => import("./pages/Terms.tsx"))
const NotFound = lazyPage(() => import("./pages/NotFound.tsx"))
// Every page at its address (Pages → Page management): its sections,
// or one of the few the site draws in code (fixedPages.ts).
const PageAtPath = lazyPage(() => import("./pages/PageAtPath.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"))
@ -100,9 +93,7 @@ export default function App() {
{/* Layout renders the nav once and swaps page content into <Outlet /> */}
<Route element={<Layout />}>
<Route index element={<Home />} />
<Route path="retreats" element={<SitePage key="retreats" id="retreats" />} />
<Route path="/events/:id" element={<EventDetail />} />
<Route path="community" element={<SitePage key="community" id="community" />} />
<Route path="/regions/:id" element={<OrganizationDetail />} />
<Route path="/groups/:id" element={<OrganizationDetail />} />
<Route path="/partners/:id" element={<OrganizationDetail />} />
@ -112,20 +103,11 @@ export default function App() {
<Route path="/people/:id" element={<PersonDetail />} />
<Route path="/blog/:id" element={<BlogPost />} />
<Route path="/directory/:id" element={<DirectoryPage />} />
<Route path="organization" element={<SitePage key="organization" id="organization" />} />
<Route path="resources" element={<SitePage key="resources" id="resources" />} />
<Route path="history" element={<SitePage key="history" id="history" />} />
<Route path="shop" element={<SitePage key="shop" id="shop" />} />
<Route path="feedback" element={<Feedback />} />
<Route path="request" element={<Request />} />
<Route path="qr" element={<QrCodes />} />
<Route path="give" element={<Giving />} />
<Route path="privacy" element={<Privacy />} />
<Route path="terms" element={<Terms />} />
<Route path="sign-in" element={<SignIn />} />
<Route path="account" element={<Account />} />
<Route path="account/welcome" element={<AccountWelcome />} />
<Route path="*" element={<NotFound />} />
{/* Every page of the site: Pages → Page management (PageAtPath). */}
<Route path="*" element={<PageAtPath />} />
</Route>
{/* A schedule as a slideshow for a screen: full screen, no Layout. */}
<Route

View file

@ -33,14 +33,7 @@ import { personTagTypes } from "./adminSchema/personTags.ts";
import { tags } from "./adminSchema/tags.ts";
import { contactTypes } from "./adminSchema/contactTypes.ts";
import { redirects } from "./adminSchema/redirects.ts";
import {
communityPage,
retreatsPage,
resourcesPage,
organizationPage,
historyPage,
shopPage,
} from "./adminSchema/sitePages.ts";
import { pages } from "./adminSchema/sitePages.ts";
export const ADMIN_ENTITIES: Record<string, any> = {
organizations,
@ -55,12 +48,7 @@ export const ADMIN_ENTITIES: Record<string, any> = {
timeline,
front_page: frontPage,
blog_posts: blogPosts,
community_page: communityPage,
retreats_page: retreatsPage,
resources_page: resourcesPage,
organization_page: organizationPage,
history_page: historyPage,
shop_page: shopPage,
pages,
navigation: siteNav,
site_settings: siteSettings,
};
@ -79,12 +67,7 @@ export const PREVIEW_PATHS: Record<string, (row: any) => string | null> = {
timeline: () => "/history",
front_page: () => "/",
blog_posts: (row) => blogHref(row.id),
community_page: () => "/community",
retreats_page: () => "/retreats",
resources_page: () => "/resources",
organization_page: () => "/organization",
history_page: () => "/history",
shop_page: () => "/shop",
pages: (row) => row.path || null,
// The menus are on every page.
navigation: () => "/",
site_settings: () => "/",

View file

@ -1,16 +1,10 @@
import siteConfiguration from "../../../site.json";
/* ── Navigation (075_site_nav.sql) ───────────────────────────────
Pages → Navigation: the header's and footer's links, and each
static page's title, intro and whether it's hidden. Admins and up
save it, since hiding takes a page off the site. Server side:
Pages → Navigation: the header's and footer's links. The pages
themselves (titles, intros, Hidden, Disabled) are Page
management's (sitePages.ts). Admins and up. Server side:
server/src/admin-schema/siteNav.js; the site reads it through
server/src/siteNav.js and src/lib/useSiteNav.ts. */
const SITE_PAGES: [string, string][] = Object.entries(siteConfiguration.pages).map(
([path, page]) => [path, `${page.title} (${path})`],
);
const PLACES: [string, string][] = [
["main", "Header: pages"],
["action", "Header: buttons"],
@ -36,7 +30,7 @@ export const siteNav = {
{
key: "links",
label: "Links",
note: "Top to bottom, in the order each place shows them. A link to a hidden page is only shown to signed-in admin accounts. A header page lists its sections under it by itself (Pages → the page).",
note: "Top to bottom, in the order each place shows them. A link to a hidden page is only shown to signed-in admin accounts, and one to a disabled page to no one. A header page lists its sections under it by itself (Pages → the page).",
addLabel: "Add link",
title: (row) => (row.label ? `${row.label} · ${placeLabel(row.place) ?? "No place"}` : "New link"),
blank: { place: "", label: "", path: "", parent_path: "", style: "", new_tab: 0 },
@ -54,7 +48,7 @@ export const siteNav = {
path: "parent_path",
label: "Under page",
widget: "select",
options: [["/", "Home (/)"], ...SITE_PAGES],
optionsFrom: "site_pages",
blankLabel: "Default: its own place in the header",
help: "Lists it in that page's menu, after its sections, instead of in the header's row",
when: { path: "place", value: "main" },
@ -70,35 +64,5 @@ export const siteNav = {
{ path: "new_tab", label: "Opens in a new tab", widget: "checkbox" },
],
},
{
key: "pages",
label: "Pages",
note: "A page's heading and intro (also its search title and description), and whether it's hidden. A hidden page is out of the menus and the sitemap and says Not found to everyone but signed-in admin accounts, who see it with a bar saying it's hidden. Blank fields keep site.json's. A page not listed here shows as site.json has it.",
addLabel: "Add page",
title: (row) =>
`${SITE_PAGES.find(([path]) => path === row.path)?.[1] ?? "New page"}${row.is_hidden ? " · Hidden" : ""}`,
blank: { path: "", title: "", description: "", is_hidden: 0 },
fields: [
{ path: "path", label: "Page", widget: "select", options: SITE_PAGES, required: true },
{
path: "is_hidden",
label: "Hidden",
widget: "checkbox",
help: "Not found to everyone but signed-in admin accounts, eg. a page that isn't done",
},
{
path: "title",
label: "Title",
help: (row) => (row?.path ? `Default: ${siteConfiguration.pages[row.path]?.title ?? ""}` : undefined),
},
{
path: "description",
label: "Intro",
widget: "textarea",
full: true,
help: (row) => (row?.path ? `Default: ${siteConfiguration.pages[row.path]?.description ?? ""}` : undefined),
},
],
},
],
};

View file

@ -1,6 +1,6 @@
/* ── The site's own pages (056_site_pages.sql) ───────────────────
Pages → Community, Retreats, Resources, Organization, History,
Shop (075):
/* ── The site's pages (056_site_pages.sql, 080_page_registry.sql) ──
Pages → Page management: every page, its address, title, intro,
Hidden and Disabled, and new pages made here.
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
@ -8,7 +8,8 @@
src/pages/SitePage.tsx.
The preset values are the CHECK list on page_sections.preset;
each page offers the ones that belong on it. */
every page offers them all. The Community blog's settings show on
the Community page only (its id), for now. */
import { FEATURED_KINDS, featuredCardsChild, blocksChild } from "./shared.ts";
@ -162,26 +163,77 @@ const sectionsChild = (presets: string[]) => ({
],
});
const sitePage = (id: string, label: string, presets: string[], more: Record<string, any> = {}) => ({
key: `${id}_page`,
label,
singular: label.toLowerCase(),
idLabel: "Page",
singleton: id,
const COMMUNITY = { path: "id", value: "community" };
const ALL_PRESETS = Object.keys(PRESETS);
list: { columns: [], filters: [] },
/* The pages the site draws in code (src/pages/fixedPages.ts, and the
front page): no sections of their own yet. */
export const FIXED_PAGE_IDS = ["home", "give", "feedback", "request", "qr", "privacy", "terms"];
const isFixed = (row) => FIXED_PAGE_IDS.includes(row?.id);
groups: [],
...more,
children: [sectionsChild(presets), ...(more.children ?? [])],
});
const communityGroups = (groups) => groups.map((group) => ({ ...group, when: COMMUNITY }));
const communityChildren = (children) => children.map((child) => ({ ...child, when: COMMUNITY }));
export const communityPage = sitePage(
"community",
"Community page",
["community_blog", "group_map", "region_list", "partner_list", "people_directory"],
{
groups: [
export const pages = {
key: "pages",
label: "Page management",
singular: "page",
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.
list: {
columns: [
{ key: "title", label: "Page", primary: true },
{ key: "path", label: "Address" },
{ key: "is_hidden", label: "Hidden", widget: "bool" },
{ key: "is_disabled", label: "Disabled", widget: "bool" },
],
filters: [],
},
groups: [
{
legend: "The page",
fields: [
{ path: "title", label: "Title", required: true, help: "The page's heading, and its title in search and the browser tab, eg. Library" },
{
path: "path",
label: "Address",
required: true,
help: "Where it lives on the site, eg. /library. Lowercase letters, numbers, hyphens and /. Changing it breaks old links: update Navigation's too.",
},
{ path: "description", label: "Intro", widget: "textarea", full: true, help: "The line under the title, and its description in search." },
{
path: "is_hidden",
label: "Hidden",
widget: "checkbox",
help: "Not found to everyone but signed-in admin accounts, eg. a page that isn't done. Out of the menus and the sitemap.",
},
{
path: "is_disabled",
label: "Disabled",
widget: "checkbox",
help: "Out of the menus, the sitemap and search; its address still works for anyone with the link.",
},
{ 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: (row) => row?.id === "home" },
fields: [],
},
{
legend: "Its content",
note: "This page's content is built into the site (a form, an embed or set text), so it has no sections to edit here yet. Its title, intro, address and switches above are yours.",
when: { test: (row) => isFixed(row) && row?.id !== "home" },
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.",
@ -200,8 +252,14 @@ export const communityPage = sitePage(
{ path: "blog.external_label", label: "Button text", help: "Default: Read more on Substack" },
],
},
],
children: [
]
),
],
children: [
{ ...sectionsChild(ALL_PRESETS), when: { test: (row) => !isFixed(row) } },
...communityChildren(
[
{
key: "pinned_posts",
label: "Community blog: pinned posts (ours)",
@ -244,12 +302,7 @@ export const communityPage = sitePage(
{ 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"]);
export const shopPage = sitePage("shop", "Shop page", []);
]
),
],
};

View file

@ -24,7 +24,7 @@ export function useNavSections(): (path: string) => NavSection[] {
return useCallback(
(path: string) => {
if (path !== '/') {
return (sitePages?.[path.slice(1)] ?? []).map((section) => ({
return (sitePages?.[path] ?? []).map((section) => ({
label: section.title,
hash: `#${section.anchor}`,
}))

View file

@ -10,8 +10,9 @@
serves the plain index.html, it isn't there and site.json alone
applies.
A page's visible heading and intro and its search title and
description come from the same values, so they can't drift.
A page's heading and intro are its site_pages row's (Pages → Page
management), which also give its search title and description, so
they can't drift: useSiteNav and the page's own data carry them.
SITE_ORIGIN is the public address of the live site. It's used
where a URL has to leave the browser and still work: a printed QR
@ -22,9 +23,7 @@
import siteConfiguration from '../../site.json'
type PageText = { title: string; description: string }
type SiteText = { title?: string; pages?: Record<string, PageText>; privacyEmail?: string; requestFiles?: boolean }
type SiteText = { title?: string; privacyEmail?: string; requestFiles?: boolean }
/* What the server wrote into the page, if it did. */
const fromServer: SiteText =
@ -46,18 +45,6 @@ export const REQUEST_FILES: boolean = fromServer.requestFiles ?? true
/** A site path as a full URL on the live site. */
export const siteUrl = (path: string): string => new URL(path, SITE_ORIGIN).href
const PAGES: Record<string, PageText> = { ...siteConfiguration.pages, ...fromServer.pages }
/* Every static page's path and text, for the not-found page's suggestions. */
export const SITE_PAGES: Readonly<Record<string, PageText>> = PAGES
/** A static page's title and intro, from site.json's "pages". */
export function sitePage(path: string): PageText {
const page = PAGES[path]
if (!page) throw new Error(`site.json has no "pages" entry for ${path}`)
return page
}
/** The browser tab's title for a page: "Retreats | Next Generation
* of Unity", or the site name alone for the home page. */
export const documentTitle = (title?: string | null): string =>

View file

@ -1,12 +1,15 @@
/* ═══════════════════════════════════════════════════════════════
SITE NAV: the header's and footer's links, and the hidden pages
SITE NAV: the site's pages, the header's and footer's links, and
the hidden pages
Pages → Navigation, for this visitor (server/src/siteNav.js): a
link to a hidden page is only sent to a viewer and up. The page
HTML carries it (window.__SITE__.nav), so the menus draw on the
first paint; GET /api/nav asks again, which is also how the dev
server (no page metadata) and a sign-in in another tab get it.
Until either answers, navConfig.ts's defaults.
Pages → Page management and Pages → Navigation, for this visitor
(server/src/siteNav.js): a hidden page, and links to it, are only
sent to a viewer and up; a disabled page's links to no one. The
page HTML carries it (window.__SITE__.nav), so the menus draw on
the first paint; GET /api/nav asks again, which is also how the
dev server (no page metadata) and a sign-in in another tab get it.
Until either answers, navConfig.ts's links, and no pages yet
(`ready` false).
═══════════════════════════════════════════════════════════════ */
import { useMemo } from 'react'
@ -14,9 +17,20 @@ import { useMemo } from 'react'
import { NAV_DEFAULTS, type NavLink } from '../navConfig.ts'
import { useRecord } from './useRecord.ts'
/** A page of the site (site_pages). */
export type SitePageInfo = {
id: string
path: string
title: string
description: string | null
hidden: boolean
disabled: boolean
}
export type SiteNav = {
links: NavLink[]
/** Paths of hidden pages, eg. '/shop'. */
pages: SitePageInfo[]
/** Paths of hidden pages, eg. '/shop' (sent to a viewer and up only). */
hidden: string[]
/** This visitor sees hidden pages (signed in, viewer and up). */
seesHidden: boolean
@ -25,7 +39,7 @@ export type SiteNav = {
const fromPage: SiteNav | undefined =
typeof window !== 'undefined' ? (window as unknown as { __SITE__?: { nav?: SiteNav } }).__SITE__?.nav : undefined
const DEFAULTS: SiteNav = { links: NAV_DEFAULTS, hidden: [], seesHidden: false }
const DEFAULTS: SiteNav = { links: NAV_DEFAULTS, pages: [], hidden: [], seesHidden: false }
/** A path's page: no #section or ?query, no trailing slash. */
export const pageOf = (path: string): string => path.split(/[?#]/)[0].replace(/(.)\/+$/, '$1') || '/'
@ -38,19 +52,24 @@ export function useSiteNav() {
const main = nav.links.filter((l) => l.place === 'main')
const top = main.filter((l) => !l.parent)
const tops = new Set(top.map((l) => pageOf(l.path)))
const byPath = new Map(nav.pages.map((page) => [page.path, page]))
return {
...nav,
/** Whether the pages have arrived (else a page can't be told from a missing one). */
ready: Boolean(data ?? fromPage),
/** The header's pages, each with the links set under it. */
main: top.map((page) => ({
...page,
children: main.filter((l) => l.parent && l.parent === pageOf(page.path)),
})),
/** Every main link, children included, for lists of the site's pages. */
pages: main.filter((l) => !l.parent || tops.has(l.parent)),
pageLinks: main.filter((l) => !l.parent || tops.has(l.parent)),
actions: nav.links.filter((l) => l.place === 'action'),
footer: nav.links.filter((l) => l.place === 'footer'),
legal: nav.links.filter((l) => l.place === 'legal'),
isHidden: (path: string) => nav.hidden.includes(pageOf(path)),
/** The page at this path, or null. */
pageAt: (path: string): SitePageInfo | null => byPath.get(pageOf(path)) ?? null,
}
}, [nav])
}, [nav, data])
}

View file

@ -1,7 +1,7 @@
/* The site's own pages (Community, Retreats, Resources, Organization,
History), built in the admin from sections: GET /site-pages/:id
for one page's sections, GET /site-pages for every page's section
headings (the header's dropdowns, the footer, the side nav). */
/* The site's pages of sections (Pages → Page management): GET
/site-pages/:id for one page's title, intro and sections, GET
/site-pages for every page's section headings by the page's path
(the header's dropdowns, the footer, the side nav). */
import { useRecord, type Resource } from './useRecord.ts'
import type { ContentBlock } from './useContent.ts'
@ -24,7 +24,7 @@ export type SitePageSection = {
blocks: ContentBlock[]
}
export const useSitePage = (id: string): Resource<{ id: string; sections: SitePageSection[] }> =>
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 }>>> =>

View file

@ -1,10 +1,8 @@
import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts";
import type { PageText } from "./fixedPages.ts";
import FeedbackForm from "./sections/FeedbackForm.tsx";
import { BRAND } from "../lib/color.ts"
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/feedback");
/* ═══════════════════════════════════════════════════════════════
Feedback page.
@ -36,11 +34,12 @@ const SECTIONS = [
},
];
export default function Feedback() {
/* Its title and intro: its site_pages row (Pages → Page management). */
export default function Feedback({ page: PAGE }: { page: PageText }) {
return (
<PageShell
title={PAGE.title}
intro={PAGE.description}
intro={PAGE.description ?? undefined}
sections={SECTIONS}
/>
);

View file

@ -1,10 +1,8 @@
import { useEffect } from "react";
import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts";
import type { PageText } from "./fixedPages.ts";
import { BRAND } from "../lib/color.ts"
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/give");
const GIVING_URL =
"https://ngu.churchcenteronline.com/giving?open-in-church-center-modal=true";
@ -72,7 +70,8 @@ function GivingPanel() {
PAGE
═══════════════════════════════════════════════════════════════ */
export default function GivingPage() {
/* Its title and intro: its site_pages row (Pages → Page management). */
export default function GivingPage({ page: PAGE }: { page: PageText }) {
useChurchCenterModal();
const sections = [
@ -89,7 +88,7 @@ export default function GivingPage() {
return (
<PageShell
title={PAGE.title}
intro={PAGE.description}
intro={PAGE.description ?? undefined}
sections={sections}
/>
);

View file

@ -2,7 +2,7 @@
NOT FOUND: any address no route matches
Rather than a dead end, the closest pages to the address that
failed: the static pages (site.json's) and every public, listed
failed: the site's pages (Page management's) and every public, listed
record (GET /directory), scored by suggest.ts against the
address. So /organisation offers Organization, /retreat offers
Retreats, and an old /chapters/lynnwood offers the Lynnwood group.
@ -18,8 +18,7 @@ import { useMemo } from 'react'
import { Link, useLocation } from 'react-router-dom'
import PageShell from '../components/PageShell.tsx'
import { useSiteNav } from '../lib/useSiteNav.ts'
import { SITE_PAGES } from '../lib/site.ts'
import { useSiteNav, type SitePageInfo } from '../lib/useSiteNav.ts'
import { useDirectory, type Directory } from '../lib/useContent.ts'
import { blogHref, eventHref, orgHref, personHref, teamHref, awardHref } from '../lib/hrefs.ts'
import { suggest, type Candidate } from '../lib/suggest.ts'
@ -36,12 +35,12 @@ const ORG_KIND_LABEL: Record<string, string> = {
/* Everything an address could have meant: the static pages (not the
hidden ones), then each kind of record, with the words to match
it by. */
function candidates(directory: Directory | null, isHidden: (path: string) => boolean): Candidate[] {
const pages: Candidate[] = Object.entries(SITE_PAGES).filter(([path]) => !isHidden(path)).map(([path, page]) => ({
href: path,
function candidates(directory: Directory | null, sitePages: SitePageInfo[]): Candidate[] {
const pages: Candidate[] = sitePages.filter((page) => !page.hidden && page.path !== '/').map((page) => ({
href: page.path,
label: page.title,
detail: 'Page',
keys: [path.slice(1), page.title],
keys: [page.path.slice(1), page.title],
}))
if (!directory) return pages
@ -66,10 +65,10 @@ function candidates(directory: Directory | null, isHidden: (path: string) => boo
export default function NotFound() {
const { pathname } = useLocation()
const { data: directory, loading } = useDirectory()
const { main: pages, isHidden } = useSiteNav()
const { main: pages, pages: sitePages } = useSiteNav()
const matches = useMemo(
() => suggest(pathname, candidates(directory ?? null, isHidden)),
[pathname, directory, isHidden],
() => suggest(pathname, candidates(directory ?? null, sitePages)),
[pathname, directory, sitePages],
)
const reading = useReadingMode()

31
src/pages/PageAtPath.tsx Normal file
View file

@ -0,0 +1,31 @@
/* ═══════════════════════════════════════════════════════════════
PAGE AT PATH: any address the record routes don't take
Pages → Page management decides what's where: the site_pages row
at this path (useSiteNav) is drawn by its code when it's one of
the fixed pages (fixedPages.ts), or as its sections (SitePage).
No page there (or a hidden one, below viewer, which isn't sent):
Not found.
═══════════════════════════════════════════════════════════════ */
import { useLocation } from 'react-router-dom'
import { useSiteNav } from '../lib/useSiteNav.ts'
import { FIXED_PAGES } from './fixedPages.ts'
import NotFound from './NotFound.tsx'
import SitePage from './SitePage.tsx'
export default function PageAtPath() {
const { pathname } = useLocation()
const { ready, pageAt } = useSiteNav()
// Before the pages arrive (the dev server's first moment), nothing
// rather than a Not found that turns into the page.
if (!ready) return null
const page = pageAt(pathname)
if (!page || page.path === '/') return <NotFound />
const Fixed = FIXED_PAGES[page.id]
if (Fixed) return <Fixed key={page.id} page={page} />
return <SitePage key={page.id} id={page.id} />
}

View file

@ -3,12 +3,11 @@ import { Link } from "react-router-dom";
import LegalText, { type LegalPart } from "../components/LegalText.tsx";
import PageShell from "../components/PageShell.tsx";
import { DATA_REQUEST } from "../data/feedbackTypes.ts";
import { PRIVACY_EMAIL, sitePage } from "../lib/site.ts";
import { PRIVACY_EMAIL } from "../lib/site.ts";
import type { PageText } from "./fixedPages.ts";
import FeedbackForm from "./sections/FeedbackForm.tsx";
import { BRAND } from "../lib/color.ts"
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/privacy");
/* ═══════════════════════════════════════════════════════════════
Privacy policy, cookie notice included.
@ -210,6 +209,7 @@ const SECTIONS = [
},
];
export default function PrivacyPage() {
return <PageShell title={PAGE.title} intro={PAGE.description} sections={SECTIONS} />;
/* Its title and intro: its site_pages row (Pages → Page management). */
export default function PrivacyPage({ page: PAGE }: { page: PageText }) {
return <PageShell title={PAGE.title} intro={PAGE.description ?? undefined} sections={SECTIONS} />;
}

View file

@ -1,10 +1,8 @@
import PageShell from '../components/PageShell.tsx'
import { sitePage } from '../lib/site.ts'
import type { PageText } from './fixedPages.ts'
import QrCodeMaker from './sections/QrCodeMaker.tsx'
import { BRAND } from '../lib/color.ts'
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage('/qr')
/* ═══════════════════════════════════════════════════════════════
QR CODES PAGE: /qr
@ -30,11 +28,12 @@ const SECTIONS = [
},
]
export default function QrCodes() {
/* Its title and intro: its site_pages row (Pages → Page management). */
export default function QrCodes({ page: PAGE }: { page: PageText }) {
return (
<PageShell
title={PAGE.title}
intro={PAGE.description}
intro={PAGE.description ?? undefined}
sections={SECTIONS}
/>
)

View file

@ -1,10 +1,8 @@
import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts";
import type { PageText } from "./fixedPages.ts";
import RequestForm from "./sections/RequestForm.tsx";
import { BRAND } from "../lib/color.ts";
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/request");
/* ═══════════════════════════════════════════════════════════════
Request page: ask for something to be added to the site or
@ -27,6 +25,7 @@ const SECTIONS = [
},
];
export default function Request() {
return <PageShell title={PAGE.title} intro={PAGE.description} sections={SECTIONS} />;
/* Its title and intro: its site_pages row (Pages → Page management). */
export default function Request({ page: PAGE }: { page: PageText }) {
return <PageShell title={PAGE.title} intro={PAGE.description ?? undefined} sections={SECTIONS} />;
}

View file

@ -8,8 +8,8 @@
the site, from PRESETS below. A section with neither says it's
coming (ComingSoon) rather than showing a heading over nothing.
The title and intro are site.json's, which also gives the search
metadata.
The title and intro are its site_pages row's (Pages → Page
management), which also give the search metadata.
═══════════════════════════════════════════════════════════════ */
import { useEffect } from 'react'
@ -18,7 +18,7 @@ import { useLocation } from 'react-router-dom'
import PageShell from '../components/PageShell.tsx'
import ComingSoon from '../components/ComingSoon.tsx'
import ContentBlocks from '../components/ContentBlocks.tsx'
import { sitePage } from '../lib/site.ts'
import { useSiteNav } from '../lib/useSiteNav.ts'
import { useSectionManifest } from '../lib/sections.tsx'
import { useSitePage, type SitePageSection } from '../lib/useSitePages.ts'
import { useHistory } from '../lib/useHistory.ts'
@ -97,10 +97,12 @@ const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>>
}
export default function SitePage({ id }: { id: string }) {
const PAGE = sitePage(`/${id}`)
const { data: page, loading, error } = 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 (page) return <Sections title={PAGE.title} intro={PAGE.description} sections={page.sections} />
if (page) return <Sections title={PAGE.title} intro={PAGE.description ?? undefined} sections={page.sections} />
return (
<>

View file

@ -2,11 +2,9 @@ import { Link } from "react-router-dom";
import LegalText, { type LegalPart } from "../components/LegalText.tsx";
import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts";
import type { PageText } from "./fixedPages.ts";
import { BRAND } from "../lib/color.ts"
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/terms");
/* Change the date when the wording changes. */
const LAST_UPDATED = "September 28, 2026";
@ -88,6 +86,7 @@ const SECTIONS = [
},
];
export default function TermsPage() {
return <PageShell title={PAGE.title} intro={PAGE.description} sections={SECTIONS} />;
/* Its title and intro: its site_pages row (Pages → Page management). */
export default function TermsPage({ page: PAGE }: { page: PageText }) {
return <PageShell title={PAGE.title} intro={PAGE.description ?? undefined} sections={SECTIONS} />;
}

View file

@ -23,7 +23,9 @@
═══════════════════════════════════════════════════════════════ */
import { ArrowRight, ArrowUpRight } from "@phosphor-icons/react";
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { get } from "../../lib/api.ts";
import { useAuth } from "../../lib/auth.tsx";
import { useWideAdminPage } from "../../lib/adminWidth.tsx";
import { SITE_VERSION, VERSION_NAME } from "../../lib/version.ts";
@ -40,6 +42,8 @@ const tintOf = (color: string) => `color-mix(in srgb, ${color} 12%, var(--color-
function NavCard({ item, color }) {
const to = target(item);
// The group's banner (Page management): the whole row, a stronger fill.
const banner = Boolean(item.banner);
// Drop the child that just repeats the card's own destination:
// "All organizations" under Organizations.
@ -47,11 +51,13 @@ function NavCard({ item, color }) {
return (
<div
className="group relative flex flex-col border-l-4 p-5 shadow-sm transition-shadow hover:shadow-md"
style={{ borderColor: color, background: tintOf(color) }}
className={`group relative flex flex-col border-l-4 p-5 shadow-sm transition-shadow hover:shadow-md ${
banner ? "sm:col-span-2 xl:col-span-3" : ""
}`}
style={{ borderColor: color, background: banner ? `color-mix(in srgb, ${color} 22%, var(--color-surface))` : tintOf(color) }}
>
<div className="flex items-baseline gap-3">
<h3 className="text-base font-bold text-link">
<h3 className={`font-bold text-link ${banner ? "text-lg" : "text-base"}`}>
<Link
to={to}
className="after:absolute after:inset-0 after:content-['']"
@ -127,10 +133,33 @@ 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. */
function usePageCards() {
const [cards, setCards] = useState<any[]>([]);
useEffect(() => {
get("/admin/pages?limit=200", { ttl: 0 })
.then((list) =>
setCards(
list.rows.map((page) => ({
to: page.id === "home" ? "/admin/front_page" : `/admin/pages/${page.id}`,
label: page.title,
blurb: [page.path, page.is_hidden ? "Hidden" : null, page.is_disabled ? "Disabled" : null]
.filter(Boolean)
.join(" · "),
})),
),
)
.catch(() => setCards([]));
}, []);
return cards;
}
export default function AdminHome() {
const { user } = useAuth();
const role = ROLE_LABELS[user?.role] ?? user?.role;
useWideAdminPage();
const pageCards = usePageCards();
return (
<div className="grid gap-8 lg:grid-cols-[1fr_17rem] lg:items-start">
@ -142,9 +171,16 @@ export default function AdminHome() {
{GROUPS.map(({ nav, color }) => (
<CardBlock key={nav.label} title={nav.label} blurb={nav.blurb} color={color}>
{visibleItems(nav.children, user).map((item) => (
<NavCard key={item.to} item={item} 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
? [<NavCard key={item.to} item={item} color={color} />, ...pageCards.map((card) => (
<NavCard key={card.to} item={card} color={color} />
))]
: [<NavCard key={item.to} item={item} color={color} />],
)}
</CardBlock>
))}

View file

@ -418,7 +418,9 @@ export default function EntityEdit() {
}
}
const visible = (when) => !when || getPath(form, when.path) === when.value;
// A gate is a field's value, or a test of the whole form (a page's
// id deciding it has sections: sitePages.ts).
const visible = (when) => !when || (when.test ? when.test(form) : getPath(form, when.path) === when.value);
const groups = manifest.groups.filter((group) => visible(group.when));
const shownChildren = children.filter((child) => visible(child.when));

View file

@ -120,49 +120,30 @@ export const PAGES_NAV = {
label: "Pages",
blurb: "What a page shows and in what order.",
children: [
// The header's and footer's links, page titles and hidden pages.
// The banner on the admin home: every page, new ones, the menus.
// Each page's own card follows it there (AdminHome.tsx).
{
to: "/admin/navigation",
label: "Navigation",
blurb: "The header's pages and buttons, the footer's links, each page's title and intro, and which pages are hidden.",
to: "/admin/pages",
label: "Page management",
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/new", label: "New page" },
{ to: "/admin/navigation", label: "Menus (Navigation)" },
],
},
// One record, not a list: the item opens it directly.
// 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.",
},
// The site's own pages, in the header's order: each is its
// sections, built in the editor (sitePages.ts).
{
to: "/admin/retreats_page",
label: "Retreats",
blurb: "Its sections: the event carousels and grids, and anything else written for it.",
menuOnly: true,
},
{
to: "/admin/community_page",
label: "Community",
blurb: "Its sections: the blog (and its pinned posts and feeds), groups map, regions and partners.",
},
{
to: "/admin/resources_page",
label: "Resources",
blurb: "Its sections and their content.",
},
{
to: "/admin/organization_page",
label: "Organization",
blurb: "Mission, vision and values, the leadership teams and volunteering, details and contact.",
},
{
to: "/admin/history_page",
label: "History",
blurb: "Its sections: the timeline (its entries are under Data), and anything else.",
},
{
to: "/admin/shop_page",
label: "Shop",
blurb: "The shop's intro page: its sections and the links out to the store.",
to: "/admin/navigation",
label: "Navigation",
blurb: "The header's pages and buttons and the footer's links.",
},
],
};

23
src/pages/fixedPages.ts Normal file
View file

@ -0,0 +1,23 @@
/* ═══════════════════════════════════════════════════════════════
FIXED PAGES
The pages the site still draws in code, by their site_pages id
(Pages → Page management can rename, move, hide or disable them,
not delete them: server/src/admin-schema/sitePages.js,
FIXED_PAGES). Every other page is its sections (SitePage.tsx).
Each takes its title and intro from its row. The front page is
the index route of its own (Home.tsx).
═══════════════════════════════════════════════════════════════ */
import { lazy, type ComponentType } from 'react'
export type PageText = { title: string; description: string | null }
export const FIXED_PAGES: Record<string, ComponentType<{ page: PageText }>> = {
give: lazy(() => import('./Giving.tsx')),
feedback: lazy(() => import('./Feedback.tsx')),
request: lazy(() => import('./Request.tsx')),
qr: lazy(() => import('./QrCodes.tsx')),
privacy: lazy(() => import('./Privacy.tsx')),
terms: lazy(() => import('./Terms.tsx')),
}

View file

@ -186,7 +186,7 @@ export function TilePicker({
function LocationPicker({ page, section, onPageChange, onSectionChange }) {
const sectionsOf = useNavSections();
const { pages } = useSiteNav();
const { pageLinks: pages } = useSiteNav();
const sections = page === SITE_WIDE ? [] : sectionsOf(page);
return (
@ -253,7 +253,7 @@ function describeLocation(page, section, sectionsOf: (path: string) => NavSectio
export default function FeedbackForm({ fixedType }: { fixedType?: string } = {}) {
const sectionsOf = useNavSections();
const { pages } = useSiteNav();
const { pageLinks: pages } = useSiteNav();
const request = fixedType === DATA_REQUEST.id;
const [type, setType] = useState<any>(fixedType ?? null);
const [page, setPage] = useState(SITE_WIDE);

View file

@ -148,7 +148,7 @@ type Group = { label?: string; choices: Choice[] }
on the site rather than an anchor on one of them (Give, not
Contact Us). */
function mainPages(nav: ReturnType<typeof useSiteNav>): Choice[] {
const pages = nav.pages.map((p) => ({ path: p.path, label: p.label }))
const pages = nav.pageLinks.map((p) => ({ path: p.path, label: p.label }))
const known = new Set(pages.map((p) => p.path))
for (const action of nav.actions) {
if (!action.path.startsWith('/') || action.path.includes('#') || known.has(action.path)) continue