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

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