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
|
|
@ -49,8 +49,8 @@ const lazyPage = (load) =>
|
|||
throw err
|
||||
}),
|
||||
)
|
||||
// Community, Retreats, Resources, Organization and History: each
|
||||
// built in the admin from sections.
|
||||
// Community, Retreats, Resources, Organization, History and Shop:
|
||||
// each built in the admin from sections.
|
||||
const SitePage = lazyPage(() => import("./pages/SitePage.tsx"))
|
||||
const Feedback = lazyPage(() => import("./pages/Feedback.tsx"))
|
||||
const Request = lazyPage(() => import("./pages/Request.tsx"))
|
||||
|
|
@ -107,6 +107,7 @@ export default function App() {
|
|||
<Route path="organization" element={<SitePage key="organization" id="organization" />} />
|
||||
<Route path="resources" element={<SitePage key="resources" id="resources" />} />
|
||||
<Route path="history" element={<SitePage key="history" id="history" />} />
|
||||
<Route path="shop" element={<SitePage key="shop" id="shop" />} />
|
||||
<Route path="feedback" element={<Feedback />} />
|
||||
<Route path="request" element={<Request />} />
|
||||
<Route path="qr" element={<QrCodes />} />
|
||||
|
|
|
|||
|
|
@ -1,31 +1,16 @@
|
|||
import { Link } from "react-router-dom";
|
||||
import { PAGE_LINKS, NAV_ACTIONS } from "../navConfig.ts";
|
||||
import { useNavSections } from "../lib/navSections.ts";
|
||||
import { useSiteNav } from "../lib/useSiteNav.ts";
|
||||
import SiteLink from "./SiteLink.tsx";
|
||||
import siteLogo from "../assets/logos/NGU_Logo.svg";
|
||||
import PlatformIcon from "./PlatformIcon.tsx";
|
||||
import { ORGANIZATION_DETAILS as Organization_Details } from "../data/organizationDetails.ts";
|
||||
import { SOCIAL_LINKS } from "../data/socialLinks.ts";
|
||||
|
||||
// Give's destination lives in navConfig so the footer and the nav can't drift.
|
||||
// Only the label differs down here.
|
||||
const giveAction = NAV_ACTIONS.find((a) => a.variant === "fancy");
|
||||
|
||||
/* An internal route, or an off-site address opened in a new tab. */
|
||||
type TouchLink = { label: string } & (
|
||||
| { external?: false; to: string }
|
||||
| { external: true; href: string }
|
||||
);
|
||||
|
||||
const Get_In_Touch: TouchLink[] = [
|
||||
{ label: "Feedback", to: "/feedback"},
|
||||
{ label: "Request", to: "/request" },
|
||||
{ label: "Contact Us", to: "/organization#contact" },
|
||||
];
|
||||
|
||||
const Footer_Links = [
|
||||
{ label: "Privacy Policy", to: "/privacy" },
|
||||
{ label: "Terms of Service", to: "/terms" },
|
||||
];
|
||||
/* Every link here is Pages → Navigation's (useSiteNav): the filled
|
||||
header buttons (Give) beside the logo, Get in Touch, the site map
|
||||
(the header's pages, their sections and the pages set under them)
|
||||
and the bottom row. */
|
||||
|
||||
const footerLinkClass =
|
||||
"text-white/65 hover:text-[var(--pal-green-2)] text-sm transition-colors";
|
||||
|
|
@ -41,6 +26,7 @@ const headingClass = "text-white/90 text-sm font-semibold mb-4";
|
|||
|
||||
export default function Footer() {
|
||||
const sectionsOf = useNavSections();
|
||||
const nav = useSiteNav();
|
||||
return (
|
||||
<footer className="py-16 px-6" style={{ background: "#001011" }}>
|
||||
<div className="max-w-6xl mx-auto">
|
||||
|
|
@ -53,17 +39,18 @@ export default function Footer() {
|
|||
<Link to="/" className="inline-block">
|
||||
<img src={siteLogo} alt="Next Generation of Unity" className="h-14 w-auto" />
|
||||
</Link>
|
||||
{giveAction && (
|
||||
<a
|
||||
href={giveAction.to}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="btn inline-block whitespace-nowrap px-6 py-2.5 text-sm text-white transition-transform duration-200 hover:-translate-y-0.5"
|
||||
style={{ background: "var(--color-action)" }}
|
||||
>
|
||||
{giveAction.label}
|
||||
</a>
|
||||
)}
|
||||
{nav.actions
|
||||
.filter((action) => action.filled)
|
||||
.map((action) => (
|
||||
<SiteLink
|
||||
key={`${action.label}${action.path}`}
|
||||
link={action}
|
||||
className="btn inline-block whitespace-nowrap px-6 py-2.5 text-sm text-white transition-transform duration-200 hover:-translate-y-0.5"
|
||||
style={{ background: "var(--color-action)" }}
|
||||
>
|
||||
{action.label}
|
||||
</SiteLink>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<address className="mt-5 not-italic text-sm leading-relaxed text-white/60">
|
||||
|
|
@ -100,22 +87,11 @@ export default function Footer() {
|
|||
|
||||
<h2 className={headingClass}>Get in Touch</h2>
|
||||
<ul className="flex flex-col gap-3">
|
||||
{Get_In_Touch.map((link) => (
|
||||
<li key={link.label}>
|
||||
{link.external ? (
|
||||
<a
|
||||
href={link.href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={pageLinkClass}
|
||||
>
|
||||
{link.label}
|
||||
</a>
|
||||
) : (
|
||||
<Link to={link.to} className={pageLinkClass}>
|
||||
{link.label}
|
||||
</Link>
|
||||
)}
|
||||
{nav.footer.map((link) => (
|
||||
<li key={`${link.label}${link.path}`}>
|
||||
<SiteLink link={link} className={pageLinkClass}>
|
||||
{link.label}
|
||||
</SiteLink>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
|
@ -126,13 +102,25 @@ export default function Footer() {
|
|||
<nav aria-label="Site map" className="mb-12 border-t border-white/10 pt-10">
|
||||
<h2 className={headingClass}>Site Map</h2>
|
||||
<ul className="grid grid-cols-2 gap-x-6 gap-y-6 sm:grid-cols-3 lg:grid-cols-6">
|
||||
{PAGE_LINKS.map((page) => {
|
||||
{nav.main.map((page) => {
|
||||
const sections = sectionsOf(page.path);
|
||||
return (
|
||||
<li key={page.path}>
|
||||
<Link to={page.path} className={pageLinkClass}>
|
||||
<SiteLink link={page} className={pageLinkClass}>
|
||||
{page.label}
|
||||
</Link>
|
||||
</SiteLink>
|
||||
|
||||
{page.children.length > 0 && (
|
||||
<ul className="flex flex-col">
|
||||
{page.children.map((child) => (
|
||||
<li key={child.path}>
|
||||
<SiteLink link={child} className={pageLinkClass}>
|
||||
{child.label}
|
||||
</SiteLink>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
{sections.length > 0 && (
|
||||
<ul className="mt-1 flex flex-col">
|
||||
|
|
@ -157,10 +145,10 @@ export default function Footer() {
|
|||
<div className="border-t border-white/10 pt-8 flex flex-col md:flex-row items-center justify-between gap-4">
|
||||
<p className="text-white/65 text-sm">© 2026 Next Generation of Unity. All rights reserved.</p>
|
||||
<div className="flex gap-6">
|
||||
{Footer_Links.map((link) => (
|
||||
<Link key={link.label} to={link.to} className={footerLinkClass}>
|
||||
{nav.legal.map((link) => (
|
||||
<SiteLink key={`${link.label}${link.path}`} link={link} className={footerLinkClass}>
|
||||
{link.label}
|
||||
</Link>
|
||||
</SiteLink>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import { X, List } from "@phosphor-icons/react";
|
||||
import { Suspense, useState, useEffect, useRef } from "react";
|
||||
import { X, List, EyeSlash } from "@phosphor-icons/react";
|
||||
import { lazy, Suspense, useState, useEffect, useRef } from "react";
|
||||
import { NavLink, Link, Outlet, useLocation } from "react-router-dom";
|
||||
import { PAGE_LINKS, NAV_ACTIONS } from "../navConfig.ts";
|
||||
import type { NavLink as NavLinkItem } from "../navConfig.ts";
|
||||
import { useNavSections } from "../lib/navSections.ts";
|
||||
import { useSiteNav } from "../lib/useSiteNav.ts";
|
||||
import SiteLink from "./SiteLink.tsx";
|
||||
import Banner from "./Banner.tsx";
|
||||
import siteLogo from "../assets/logos/NGU_Logo.svg";
|
||||
import Footer from "./Footer.tsx";
|
||||
|
|
@ -14,25 +16,20 @@ import ThemeToggle from "./ThemeToggle.tsx";
|
|||
import { jumpTo } from "../lib/focus.ts";
|
||||
import { useReadingMode } from "../lib/readingMode.ts";
|
||||
|
||||
/* ── Right-side nav actions ──────────────────────────────── */
|
||||
const NotFound = lazy(() => import("../pages/NotFound.tsx"));
|
||||
|
||||
type NavActionItem = {
|
||||
label: string;
|
||||
to: string;
|
||||
variant: string;
|
||||
external?: boolean;
|
||||
};
|
||||
/* ── Right-side nav actions ──────────────────────────────── */
|
||||
|
||||
const ACTION_VARIANTS: Record<
|
||||
string,
|
||||
{ className: string; style: React.CSSProperties }
|
||||
> = {
|
||||
ghost: {
|
||||
outline: {
|
||||
className:
|
||||
"font-semibold border border-white/30 text-white/85 hover:border-white/60 hover:text-white hover:bg-white/10",
|
||||
style: {},
|
||||
},
|
||||
fancy: {
|
||||
filled: {
|
||||
className: "font-bold text-white hover:scale-105",
|
||||
style: { background: "var(--color-action)" },
|
||||
},
|
||||
|
|
@ -48,33 +45,20 @@ function NavAction({
|
|||
size = "desktop",
|
||||
onClick,
|
||||
}: {
|
||||
item: NavActionItem;
|
||||
item: NavLinkItem;
|
||||
size?: keyof typeof ACTION_SIZES;
|
||||
onClick?: () => void;
|
||||
}) {
|
||||
const v = ACTION_VARIANTS[item.variant] ?? ACTION_VARIANTS.ghost;
|
||||
const v = ACTION_VARIANTS[item.filled ? "filled" : "outline"];
|
||||
const className = `inline-block whitespace-nowrap btn transition-all duration-200 active:scale-[0.98] ${ACTION_SIZES[size]} ${v.className}`;
|
||||
|
||||
return item.external ? (
|
||||
<a
|
||||
href={item.to}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={className}
|
||||
style={v.style}
|
||||
onClick={onClick}
|
||||
>
|
||||
return (
|
||||
<SiteLink link={item} className={className} style={v.style} onClick={onClick}>
|
||||
{item.label}
|
||||
</a>
|
||||
) : (
|
||||
<Link to={item.to} className={className} style={v.style} onClick={onClick}>
|
||||
{item.label}
|
||||
</Link>
|
||||
</SiteLink>
|
||||
);
|
||||
}
|
||||
|
||||
const navActions = NAV_ACTIONS as NavActionItem[];
|
||||
|
||||
/* ── Layout ──────────────────────────────────────────────── */
|
||||
|
||||
export default function Layout() {
|
||||
|
|
@ -95,6 +79,20 @@ export default function Layout() {
|
|||
const pageRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const sectionsOf = useNavSections();
|
||||
const nav = useSiteNav();
|
||||
// A hidden page (Pages → Navigation) is Not found below viewer; a
|
||||
// viewer and up sees it, under a bar saying so. The server answers
|
||||
// the same (server/src/siteNav.js); this covers the app's own moves.
|
||||
const hiddenHere = nav.isHidden(location.pathname);
|
||||
const page = (
|
||||
<Suspense fallback={null}>{hiddenHere && !nav.seesHidden ? <NotFound /> : <Outlet />}</Suspense>
|
||||
);
|
||||
const hiddenBar = hiddenHere && nav.seesHidden && (
|
||||
<p className="flex items-center justify-center gap-2 bg-tint px-6 py-2 text-center text-sm text-ink print:hidden">
|
||||
<EyeSlash size={18} weight="bold" aria-hidden="true" />
|
||||
This page is hidden: only signed-in admin accounts can see it. Show it in Pages → Navigation.
|
||||
</p>
|
||||
);
|
||||
|
||||
// Close the mobile menu whenever the route changes
|
||||
useEffect(() => {
|
||||
|
|
@ -177,9 +175,7 @@ export default function Layout() {
|
|||
<main id="main" tabIndex={-1} className="outline-none">
|
||||
<ReaderView source={pageRef} />
|
||||
<div ref={pageRef} hidden>
|
||||
<Suspense fallback={null}>
|
||||
<Outlet />
|
||||
</Suspense>
|
||||
{page}
|
||||
</div>
|
||||
</main>
|
||||
<AccessibilityPanel />
|
||||
|
|
@ -221,14 +217,15 @@ export default function Layout() {
|
|||
none: it's the logo's link too, and its bands are one
|
||||
scroll away. */}
|
||||
<div className="hidden lg:flex items-center gap-6">
|
||||
{PAGE_LINKS.map((page) => {
|
||||
{nav.main.map((page) => {
|
||||
const pageSections = page.path === "/" ? [] : sectionsOf(page.path);
|
||||
const hasMenu = pageSections.length > 0 || page.children.length > 0;
|
||||
return (
|
||||
<div
|
||||
key={page.path}
|
||||
className="group relative"
|
||||
onKeyDown={(e) => {
|
||||
if (e.key !== "Escape" || pageSections.length === 0) return;
|
||||
if (e.key !== "Escape" || !hasMenu) return;
|
||||
setDismissed(page.path);
|
||||
e.currentTarget.querySelector("a")?.focus();
|
||||
}}
|
||||
|
|
@ -250,7 +247,7 @@ export default function Layout() {
|
|||
>
|
||||
{page.label}
|
||||
</NavLink>
|
||||
{pageSections.length > 0 && (
|
||||
{hasMenu && (
|
||||
// pt-3 is the bridge the pointer crosses from the
|
||||
// link into the menu without it closing. Keyboard
|
||||
// focus opens it too, but only keyboard focus
|
||||
|
|
@ -276,6 +273,17 @@ export default function Layout() {
|
|||
</Link>
|
||||
</li>
|
||||
))}
|
||||
{/* Pages set under this one (Pages → Navigation), after its sections. */}
|
||||
{page.children.map((child) => (
|
||||
<li key={child.path}>
|
||||
<SiteLink
|
||||
link={child}
|
||||
className="block px-4 py-2 text-sm font-semibold text-white/90 transition-colors hover:bg-white/10 hover:text-[var(--pal-amber-2)] focus-visible:bg-white/10"
|
||||
>
|
||||
{child.label}
|
||||
</SiteLink>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
|
@ -287,8 +295,8 @@ export default function Layout() {
|
|||
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="hidden lg:flex items-center gap-3">
|
||||
{navActions.map((item) => (
|
||||
<NavAction key={item.label} item={item} />
|
||||
{nav.actions.map((item) => (
|
||||
<NavAction key={`${item.label}${item.path}`} item={item} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
|
|
@ -315,9 +323,8 @@ export default function Layout() {
|
|||
|
||||
{/* Page content */}
|
||||
<main id="main" tabIndex={-1} className="outline-none" inert={mobileMenuOpen}>
|
||||
<Suspense fallback={null}>
|
||||
<Outlet />
|
||||
</Suspense>
|
||||
{hiddenBar}
|
||||
{page}
|
||||
</main>
|
||||
|
||||
{/*Site Footer applied to every page*/}
|
||||
|
|
@ -346,7 +353,7 @@ export default function Layout() {
|
|||
</button>
|
||||
|
||||
<div className="w-64">
|
||||
{PAGE_LINKS.map((page) => {
|
||||
{nav.main.map((page) => {
|
||||
const pageSections = sectionsOf(page.path);
|
||||
const isActive = location.pathname === page.path;
|
||||
|
||||
|
|
@ -364,6 +371,22 @@ export default function Layout() {
|
|||
{page.label}
|
||||
</NavLink>
|
||||
|
||||
{/* Pages set under this one (Pages → Navigation) */}
|
||||
{page.children.length > 0 && (
|
||||
<div className="ml-3 pl-4 mb-2 flex flex-col">
|
||||
{page.children.map((child) => (
|
||||
<SiteLink
|
||||
key={child.path}
|
||||
link={child}
|
||||
className="text-white text-xl font-bold py-2 hover:text-[var(--pal-amber-2)] transition-colors"
|
||||
onClick={() => setMobileMenuOpen(false)}
|
||||
>
|
||||
{child.label}
|
||||
</SiteLink>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Sections nest under the page they belong to */}
|
||||
{isActive && pageSections.length > 0 && (
|
||||
<div
|
||||
|
|
@ -388,9 +411,9 @@ export default function Layout() {
|
|||
</div>
|
||||
|
||||
<div className="mt-8 flex flex-col items-center gap-3">
|
||||
{navActions.map((item) => (
|
||||
{nav.actions.map((item) => (
|
||||
<NavAction
|
||||
key={item.label}
|
||||
key={`${item.label}${item.path}`}
|
||||
item={item}
|
||||
size="mobile"
|
||||
onClick={() => setMobileMenuOpen(false)}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
import { Fragment, useEffect, useState, type ReactNode, type RefObject } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
import { PAGE_LINKS } from '../navConfig.ts'
|
||||
import { useSiteNav } from '../lib/useSiteNav.ts'
|
||||
|
||||
type Inline = string | { href: string; children: Inline[] }
|
||||
|
||||
|
|
@ -240,6 +240,7 @@ function Anchor({ href, children }: { href: string; children: ReactNode }) {
|
|||
|
||||
export default function ReaderView({ source }: { source: RefObject<HTMLElement | null> }) {
|
||||
const [blocks, setBlocks] = useState<Block[]>([])
|
||||
const { main: pages } = useSiteNav()
|
||||
|
||||
useEffect(() => {
|
||||
const root = source.current
|
||||
|
|
@ -264,7 +265,7 @@ export default function ReaderView({ source }: { source: RefObject<HTMLElement |
|
|||
return (
|
||||
<article className="reader">
|
||||
<p>
|
||||
{PAGE_LINKS.map((page, i) => (
|
||||
{pages.map((page, i) => (
|
||||
<span key={page.path}>
|
||||
{i > 0 && ' · '}
|
||||
<Link to={page.path}>{page.label}</Link>
|
||||
|
|
|
|||
30
src/components/SiteLink.tsx
Normal file
30
src/components/SiteLink.tsx
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { Link } from 'react-router-dom'
|
||||
|
||||
import type { NavLink } from '../navConfig.ts'
|
||||
|
||||
/* A nav link (Pages → Navigation): a route on the site, or a plain
|
||||
link for an address off it or one set to open in a new tab. */
|
||||
export default function SiteLink({
|
||||
link,
|
||||
children,
|
||||
...rest
|
||||
}: {
|
||||
link: NavLink
|
||||
children: React.ReactNode
|
||||
className?: string
|
||||
style?: React.CSSProperties
|
||||
onClick?: () => void
|
||||
}) {
|
||||
if (!link.path.startsWith('/') || link.newTab) {
|
||||
return (
|
||||
<a href={link.path} {...(link.newTab ? { target: '_blank', rel: 'noopener noreferrer' } : {})} {...rest}>
|
||||
{children}
|
||||
</a>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Link to={link.path} {...rest}>
|
||||
{children}
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@ import { timeline } from "./adminSchema/timeline.ts";
|
|||
import { frontPage } from "./adminSchema/frontPage.ts";
|
||||
import { blogPosts } from "./adminSchema/blog.ts";
|
||||
import { siteSettings } from "./adminSchema/siteSettings.ts";
|
||||
import { siteNav } from "./adminSchema/siteNav.ts";
|
||||
import { personTagTypes } from "./adminSchema/personTags.ts";
|
||||
import { tags } from "./adminSchema/tags.ts";
|
||||
import { contactTypes } from "./adminSchema/contactTypes.ts";
|
||||
|
|
@ -37,6 +38,7 @@ import {
|
|||
resourcesPage,
|
||||
organizationPage,
|
||||
historyPage,
|
||||
shopPage,
|
||||
} from "./adminSchema/sitePages.ts";
|
||||
|
||||
export const ADMIN_ENTITIES: Record<string, any> = {
|
||||
|
|
@ -57,6 +59,8 @@ export const ADMIN_ENTITIES: Record<string, any> = {
|
|||
resources_page: resourcesPage,
|
||||
organization_page: organizationPage,
|
||||
history_page: historyPage,
|
||||
shop_page: shopPage,
|
||||
navigation: siteNav,
|
||||
site_settings: siteSettings,
|
||||
};
|
||||
|
||||
|
|
|
|||
104
src/lib/adminSchema/siteNav.ts
Normal file
104
src/lib/adminSchema/siteNav.ts
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
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:
|
||||
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"],
|
||||
["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. 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",
|
||||
options: [["/", "Home (/)"], ...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" },
|
||||
],
|
||||
},
|
||||
{
|
||||
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),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
/* ── The site's own pages (056_site_pages.sql) ───────────────────
|
||||
Pages → Community, Retreats, Resources, Organization, History:
|
||||
Pages → Community, Retreats, Resources, Organization, History,
|
||||
Shop (075):
|
||||
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
|
||||
|
|
@ -254,3 +255,4 @@ 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", []);
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@ import { THEME_DEFAULTS } from "../../../server/src/themeDefaults.js";
|
|||
|
||||
/* ── Site settings (035_site_settings.sql) ───────────────────────
|
||||
Overrides for site.json, superadmins only: every blank falls back
|
||||
to what site.json says, which is shown as the default. */
|
||||
const SITE_PAGES: [string, string][] = Object.entries(siteConfiguration.pages).map(
|
||||
([path, page]) => [path, `${page.title} (${path})`],
|
||||
);
|
||||
to what site.json says, which is shown as the default. Page titles
|
||||
and intros are Pages → Navigation's (siteNav.ts). */
|
||||
|
||||
/* The palette an admin can change, in the order the dropdown lists
|
||||
it: token and label. The defaults come from the server's list
|
||||
|
|
@ -218,28 +216,5 @@ export const siteSettings = {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "pages",
|
||||
label: "Page titles and intros",
|
||||
note: "Change a static page's heading and intro, which are also its search title and description. Blank fields keep site.json's.",
|
||||
addLabel: "Change a page",
|
||||
title: (row) => SITE_PAGES.find(([path]) => path === row.path)?.[1] ?? "New page",
|
||||
blank: { path: "", title: "", description: "" },
|
||||
fields: [
|
||||
{ path: "path", label: "Page", widget: "select", options: SITE_PAGES, required: true },
|
||||
{
|
||||
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),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
table, so there is one answer to "where does an event live" and
|
||||
changing it is changing EVENT_BASE below.
|
||||
|
||||
navConfig.ts stays the source of truth for the *nav*: these are
|
||||
The nav is Pages → Navigation's (useSiteNav.ts): these are
|
||||
record routes, which never appear in it.
|
||||
|
||||
── On missing ids ──
|
||||
|
|
|
|||
56
src/lib/useSiteNav.ts
Normal file
56
src/lib/useSiteNav.ts
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
SITE NAV: the header's and footer's links, and the hidden pages
|
||||
|
||||
Pages → Navigation, for this visitor (server/src/siteNav.js): a
|
||||
link to a hidden page is only sent to a viewer and up. The page
|
||||
HTML carries it (window.__SITE__.nav), so the menus draw on the
|
||||
first paint; GET /api/nav asks again, which is also how the dev
|
||||
server (no page metadata) and a sign-in in another tab get it.
|
||||
Until either answers, navConfig.ts's defaults.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useMemo } from 'react'
|
||||
|
||||
import { NAV_DEFAULTS, type NavLink } from '../navConfig.ts'
|
||||
import { useRecord } from './useRecord.ts'
|
||||
|
||||
export type SiteNav = {
|
||||
links: NavLink[]
|
||||
/** Paths of hidden pages, eg. '/shop'. */
|
||||
hidden: string[]
|
||||
/** This visitor sees hidden pages (signed in, viewer and up). */
|
||||
seesHidden: boolean
|
||||
}
|
||||
|
||||
const fromPage: SiteNav | undefined =
|
||||
typeof window !== 'undefined' ? (window as unknown as { __SITE__?: { nav?: SiteNav } }).__SITE__?.nav : undefined
|
||||
|
||||
const DEFAULTS: SiteNav = { links: NAV_DEFAULTS, hidden: [], seesHidden: false }
|
||||
|
||||
/** A path's page: no #section or ?query, no trailing slash. */
|
||||
export const pageOf = (path: string): string => path.split(/[?#]/)[0].replace(/(.)\/+$/, '$1') || '/'
|
||||
|
||||
export function useSiteNav() {
|
||||
const { data } = useRecord<SiteNav>('/nav', 'nav')
|
||||
const nav = data ?? fromPage ?? DEFAULTS
|
||||
|
||||
return useMemo(() => {
|
||||
const main = nav.links.filter((l) => l.place === 'main')
|
||||
const top = main.filter((l) => !l.parent)
|
||||
const tops = new Set(top.map((l) => pageOf(l.path)))
|
||||
return {
|
||||
...nav,
|
||||
/** The header's pages, each with the links set under it. */
|
||||
main: top.map((page) => ({
|
||||
...page,
|
||||
children: main.filter((l) => l.parent && l.parent === pageOf(page.path)),
|
||||
})),
|
||||
/** Every main link, children included, for lists of the site's pages. */
|
||||
pages: main.filter((l) => !l.parent || tops.has(l.parent)),
|
||||
actions: nav.links.filter((l) => l.place === 'action'),
|
||||
footer: nav.links.filter((l) => l.place === 'footer'),
|
||||
legal: nav.links.filter((l) => l.place === 'legal'),
|
||||
isHidden: (path: string) => nav.hidden.includes(pageOf(path)),
|
||||
}
|
||||
}, [nav])
|
||||
}
|
||||
|
|
@ -1,22 +1,56 @@
|
|||
// Single source of truth for navigation.
|
||||
// Add a page here and in App.jsx, and both tiers of the nav update.
|
||||
/* ═══════════════════════════════════════════════════════════════
|
||||
NAV DEFAULTS
|
||||
|
||||
export const PAGE_LINKS = [
|
||||
{ label: "Home", path: "/" },
|
||||
{ label: "Retreats", path: "/retreats" },
|
||||
{ label: "Community", path: "/community" },
|
||||
{ label: "Resources", path: "/resources" },
|
||||
{ label: "Organization", path: "/organization" },
|
||||
{ label: "History", path: "/history" },
|
||||
];
|
||||
The header's and footer's links are edited in Pages → Navigation
|
||||
(075_site_nav.sql) and reach the app through useSiteNav
|
||||
(src/lib/useSiteNav.ts). This is what the app starts from before
|
||||
they arrive: the same links the migration seeded, so a dev server
|
||||
with no page metadata, or a moment before /api/nav answers, still
|
||||
has a menu. Change the menus in the admin, not here.
|
||||
|
||||
// Right-side actions. `variant` picks the styling, not the destination.
|
||||
export const NAV_ACTIONS = [
|
||||
{ label: "Contact Us", to: "/organization#contact", variant: "ghost" },
|
||||
{
|
||||
label: "Give",
|
||||
to: "/give",
|
||||
variant: "fancy",
|
||||
external: true,
|
||||
},
|
||||
];
|
||||
place: main the header's pages (sections drop down under
|
||||
each); with a parent, in that page's dropdown
|
||||
action the header's buttons (filled: the Give style,
|
||||
also beside the footer's logo)
|
||||
footer the footer's Get in Touch list
|
||||
legal the footer's bottom row
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
export type NavPlace = 'main' | 'action' | 'footer' | 'legal'
|
||||
|
||||
export type NavLink = {
|
||||
place: NavPlace
|
||||
label: string
|
||||
/** '/retreats', '/organization#contact', or an https:// address. */
|
||||
path: string
|
||||
/** A main link's page whose dropdown it sits in. */
|
||||
parent: string | null
|
||||
filled: boolean
|
||||
newTab: boolean
|
||||
}
|
||||
|
||||
const link = (place: NavPlace, label: string, path: string, more: Partial<NavLink> = {}): NavLink => ({
|
||||
place,
|
||||
label,
|
||||
path,
|
||||
parent: null,
|
||||
filled: false,
|
||||
newTab: false,
|
||||
...more,
|
||||
})
|
||||
|
||||
export const NAV_DEFAULTS: NavLink[] = [
|
||||
link('main', 'Home', '/'),
|
||||
link('main', 'Retreats', '/retreats'),
|
||||
link('main', 'Community', '/community'),
|
||||
link('main', 'Resources', '/resources'),
|
||||
link('main', 'Organization', '/organization'),
|
||||
link('main', 'History', '/history'),
|
||||
link('action', 'Contact Us', '/organization#contact'),
|
||||
link('action', 'Give', '/give', { filled: true, newTab: true }),
|
||||
link('footer', 'Feedback', '/feedback'),
|
||||
link('footer', 'Request', '/request'),
|
||||
link('footer', 'Contact Us', '/organization#contact'),
|
||||
link('legal', 'Privacy Policy', '/privacy'),
|
||||
link('legal', 'Terms of Service', '/terms'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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