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:
parent
b49497cc59
commit
0cc2a3f721
30 changed files with 716 additions and 216 deletions
|
|
@ -18,7 +18,7 @@ import { useMemo } from 'react'
|
|||
import { Link, useLocation } from 'react-router-dom'
|
||||
|
||||
import PageShell from '../components/PageShell.tsx'
|
||||
import { PAGE_LINKS } from '../navConfig.ts'
|
||||
import { useSiteNav } from '../lib/useSiteNav.ts'
|
||||
import { SITE_PAGES } from '../lib/site.ts'
|
||||
import { useDirectory, type Directory } from '../lib/useContent.ts'
|
||||
import { blogHref, eventHref, orgHref, personHref, teamHref, awardHref } from '../lib/hrefs.ts'
|
||||
|
|
@ -33,10 +33,11 @@ const ORG_KIND_LABEL: Record<string, string> = {
|
|||
partner: 'Partner',
|
||||
}
|
||||
|
||||
/* Everything an address could have meant: the static pages, then
|
||||
each kind of record, with the words to match it by. */
|
||||
function candidates(directory: Directory | null): Candidate[] {
|
||||
const pages: Candidate[] = Object.entries(SITE_PAGES).map(([path, page]) => ({
|
||||
/* 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,
|
||||
label: page.title,
|
||||
detail: 'Page',
|
||||
|
|
@ -65,7 +66,11 @@ function candidates(directory: Directory | null): Candidate[] {
|
|||
export default function NotFound() {
|
||||
const { pathname } = useLocation()
|
||||
const { data: directory, loading } = useDirectory()
|
||||
const matches = useMemo(() => suggest(pathname, candidates(directory ?? null)), [pathname, directory])
|
||||
const { main: pages, isHidden } = useSiteNav()
|
||||
const matches = useMemo(
|
||||
() => suggest(pathname, candidates(directory ?? null, isHidden)),
|
||||
[pathname, directory, isHidden],
|
||||
)
|
||||
const reading = useReadingMode()
|
||||
|
||||
return (
|
||||
|
|
@ -118,7 +123,7 @@ export default function NotFound() {
|
|||
accent: ACCENTS.green,
|
||||
content: (
|
||||
<div className="mx-auto flex max-w-6xl flex-wrap gap-3 px-6">
|
||||
{PAGE_LINKS.map((page) => (
|
||||
{pages.map((page) => (
|
||||
<Link
|
||||
key={page.path}
|
||||
to={page.path}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ const PAGE = sitePage('/qr')
|
|||
QR CODES PAGE: /qr
|
||||
|
||||
A QR code for any page on the site, for flyers, slides and
|
||||
signs. Unlisted: not in navConfig, so neither the header nor the
|
||||
footer links here. It lists only published records, so there is
|
||||
signs. Unlisted: not in Pages → Navigation's links, so neither
|
||||
the header nor the footer links here. It lists only published records, so there is
|
||||
nothing on it a visitor couldn't already reach.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
Bare on purpose. No PageShell, no announcement banner, no
|
||||
footer site map. None of that belongs around a staff tool, and
|
||||
/admin should never appear in navConfig.
|
||||
/admin should never appear in Pages → Navigation.
|
||||
|
||||
Three areas share this chrome: Home, the CMS and the Panel. The
|
||||
wordmark names whichever one you're in, and from anywhere but
|
||||
|
|
|
|||
|
|
@ -114,6 +114,12 @@ 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.
|
||||
{
|
||||
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.",
|
||||
},
|
||||
// One record, not a list: the item opens it directly.
|
||||
{
|
||||
to: "/admin/front_page",
|
||||
|
|
@ -147,6 +153,11 @@ export const PAGES_NAV = {
|
|||
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.",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
|
@ -227,7 +238,7 @@ export const PANEL_NAV = {
|
|||
{
|
||||
to: SITE_SETTINGS,
|
||||
label: "Site settings",
|
||||
blurb: "The site's name, description, preview image, icons, page titles and search indexing.",
|
||||
blurb: "The site's name, description, preview image, icons, colors, access groups and search indexing.",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@
|
|||
the two sets are kept deliberately in step (MIN_MESSAGE, and the
|
||||
ids in FEEDBACK_TYPES).
|
||||
|
||||
The page and section options come from navConfig, so adding a
|
||||
page to the nav adds it to this form too.
|
||||
The page and section options come from the header's pages (Pages
|
||||
→ Navigation, useSiteNav.ts), so adding a page to the nav adds it
|
||||
to this form too.
|
||||
|
||||
With fixedType the type is set and neither picker shows. The
|
||||
Privacy page uses it for data requests (DATA_REQUEST), which also
|
||||
|
|
@ -18,7 +19,7 @@
|
|||
import { CaretDown } from '@phosphor-icons/react';
|
||||
import { useState } from "react";
|
||||
import { post, ApiError } from "../../lib/api.ts";
|
||||
import { PAGE_LINKS } from "../../navConfig.ts";
|
||||
import { useSiteNav } from "../../lib/useSiteNav.ts";
|
||||
import { useNavSections, type NavSection } from "../../lib/navSections.ts";
|
||||
import { DATA_REQUEST, FEEDBACK_TYPES } from "../../data/feedbackTypes.ts";
|
||||
import { accentText, BRAND } from '../../lib/color.ts'
|
||||
|
|
@ -185,6 +186,7 @@ export function TilePicker({
|
|||
|
||||
function LocationPicker({ page, section, onPageChange, onSectionChange }) {
|
||||
const sectionsOf = useNavSections();
|
||||
const { pages } = useSiteNav();
|
||||
const sections = page === SITE_WIDE ? [] : sectionsOf(page);
|
||||
|
||||
return (
|
||||
|
|
@ -210,7 +212,7 @@ function LocationPicker({ page, section, onPageChange, onSectionChange }) {
|
|||
}}
|
||||
>
|
||||
<option value={SITE_WIDE}>Not page-specific</option>
|
||||
{PAGE_LINKS.map((p) => (
|
||||
{pages.map((p) => (
|
||||
<option key={p.path} value={p.path}>
|
||||
{p.label}
|
||||
</option>
|
||||
|
|
@ -238,9 +240,9 @@ function LocationPicker({ page, section, onPageChange, onSectionChange }) {
|
|||
}
|
||||
|
||||
// Human-readable version of the picked location, for the thank-you panel.
|
||||
function describeLocation(page, section, sectionsOf: (path: string) => NavSection[]) {
|
||||
function describeLocation(page, section, sectionsOf: (path: string) => NavSection[], pages: { path: string; label: string }[]) {
|
||||
if (page === SITE_WIDE) return null;
|
||||
const pageLabel = PAGE_LINKS.find((p) => p.path === page)?.label ?? page;
|
||||
const pageLabel = pages.find((p) => p.path === page)?.label ?? page;
|
||||
const sectionLabel = sectionsOf(page).find(
|
||||
(s) => s.hash === section,
|
||||
)?.label;
|
||||
|
|
@ -251,6 +253,7 @@ function describeLocation(page, section, sectionsOf: (path: string) => NavSectio
|
|||
|
||||
export default function FeedbackForm({ fixedType }: { fixedType?: string } = {}) {
|
||||
const sectionsOf = useNavSections();
|
||||
const { pages } = useSiteNav();
|
||||
const request = fixedType === DATA_REQUEST.id;
|
||||
const [type, setType] = useState<any>(fixedType ?? null);
|
||||
const [page, setPage] = useState(SITE_WIDE);
|
||||
|
|
@ -320,7 +323,7 @@ export default function FeedbackForm({ fixedType }: { fixedType?: string } = {})
|
|||
}
|
||||
|
||||
if (status === "sent") {
|
||||
const where = describeLocation(page, section, sectionsOf);
|
||||
const where = describeLocation(page, section, sectionsOf, pages);
|
||||
return (
|
||||
<div
|
||||
aria-live="polite"
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue