Navigation in the admin: header and footer links, page titles, hidden pages, Shop

Pages -> Navigation (migration 075) edits the header's pages and buttons
and the footer's links; navConfig.ts is now only the defaults. Page titles
and intros move there from Site settings. A hidden page answers Not found
below viewer (server and app) and is out of the menus and sitemap; signed
in, it shows with a bar. Adds a /shop page of sections, hidden, with its
header button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aidan Dona 2026-10-16 18:01:02 -05:00
parent b49497cc59
commit 0cc2a3f721
30 changed files with 716 additions and 216 deletions

View file

@ -19,8 +19,8 @@
site like every other choice), a full http(s) address, or a bare
domain, which gets https:// in front.
The main pages come from navConfig.ts, the same list the header
draws; records come from GET /directory, which lists only what's
The main pages come from Pages → Navigation (useSiteNav.ts), the
same list the header draws; records come from GET /directory, which lists only what's
published, and their URLs from hrefs.ts, the same builders the
site links with. So a code can only point at a page that exists.
@ -34,7 +34,7 @@
import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
import QrCode, { QR_DOVE, QR_INK, QR_PAPER, type QrCenter } from '../../components/QrCode.tsx'
import { NAV_ACTIONS, PAGE_LINKS } from '../../navConfig.ts'
import { useSiteNav } from '../../lib/useSiteNav.ts'
import { useNavSections } from '../../lib/navSections.ts'
import { awardHref, blogHref, eventHref, orgHref, personHref, teamHref } from '../../lib/hrefs.ts'
import { siteUrl } from '../../lib/site.ts'
@ -145,22 +145,21 @@ type Choice = { path: string; label: string }
type Group = { label?: string; choices: Choice[] }
/* The header's pages, then any nav action that is a page of its own
rather than an anchor on one of them (Give, not Contact Us). */
function mainPages(): Choice[] {
const pages = PAGE_LINKS.map((p) => ({ path: p.path, label: p.label }))
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 known = new Set(pages.map((p) => p.path))
for (const action of NAV_ACTIONS) {
const path = action.to.split('#')[0]
if (!action.to.includes('#') && !known.has(path)) {
pages.push({ path, label: action.label })
known.add(path)
}
for (const action of nav.actions) {
if (!action.path.startsWith('/') || action.path.includes('#') || known.has(action.path)) continue
pages.push({ path: action.path, label: action.label })
known.add(action.path)
}
return pages
}
function groupsFor(kind: Kind, directory: Directory | null): Group[] {
if (kind === 'pages') return [{ choices: mainPages() }]
function groupsFor(kind: Kind, directory: Directory | null, nav: ReturnType<typeof useSiteNav>): Group[] {
if (kind === 'pages') return [{ choices: mainPages(nav) }]
if (!directory) return []
switch (kind) {
@ -268,7 +267,8 @@ export default function QrCodeMaker() {
const [copied, setCopied] = useState(false)
const svgRef = useRef<SVGSVGElement>(null)
const groups = useMemo(() => groupsFor(kind, directory), [kind, directory])
const nav = useSiteNav()
const groups = useMemo(() => groupsFor(kind, directory, nav), [kind, directory, nav])
const choices = useMemo(() => groups.flatMap((group) => group.choices), [groups])
// Past FILTER_FROM records, a box above the select narrows them;
// the one chosen always stays.