NGU-Web/src/lib/adminSchema/siteNav.ts
Aidan Dona 1342691f49 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>
2026-10-16 23:19:54 -05:00

68 lines
2.6 KiB
TypeScript

/* ── Navigation (075_site_nav.sql) ───────────────────────────────
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 PLACES: [string, string][] = [
["main", "Header: pages"],
["action", "Header: buttons"],
["footer", "Footer: Get in Touch"],
["legal", "Footer: bottom row"],
];
const placeLabel = (place) => PLACES.find(([key]) => key === place)?.[1];
export const siteNav = {
key: "navigation",
label: "Navigation",
singular: "navigation",
idLabel: "Navigation",
singleton: "site",
writeRole: "admin",
list: { columns: [], filters: [] },
groups: [],
children: [
{
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, 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 },
fields: [
{ path: "place", label: "Shows in", widget: "select", options: PLACES, required: true },
{ path: "label", label: "Label", required: true, help: "eg. Shop" },
{
path: "path",
label: "Link",
required: true,
full: true,
help: "A page on the site, a section of one, or an address elsewhere, eg. /shop, /organization#contact or https://www.bonfire.com/store/…",
},
{
path: "parent_path",
label: "Under page",
widget: "select",
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" },
},
{
path: "style",
label: "Style",
widget: "select",
options: [["filled", "Filled, like Give (also beside the footer's logo)"]],
blankLabel: "Default: outlined",
when: { path: "place", value: "action" },
},
{ path: "new_tab", label: "Opens in a new tab", widget: "checkbox" },
],
},
],
};