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

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