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

@ -7,7 +7,8 @@
can say no while production says yes
GET /anything the built index.html, its title, description,
preview image, canonical link and structured
data filled in for that path (pageMeta.js)
data filled in for that path (pageMeta.js),
and this visitor's menus (siteNav.js)
In production nginx serves files that exist (the JS, CSS,
uploads) itself and sends everything else here, so a shared link
@ -35,6 +36,7 @@ import { fileURLToPath } from "node:url";
import { Hono } from "hono";
import { currentUser } from "../auth.js";
import { metaFor, renderPage, robotsTxt, siteFor, sitemap } from "../pageMeta.js";
import { CACHE, NO_STORE } from "../shape.js";
@ -109,7 +111,8 @@ pages.get("*", (c, next) => {
let meta;
let page;
try {
meta = metaFor(c.get("db"), pathname);
// Who's asking decides whether a hidden page is there (siteNav.js).
meta = metaFor(c.get("db"), pathname, currentUser(c.get("db"), c));
page = renderPage(html, meta);
} catch (err) {
warnOnce(

View file

@ -1,11 +1,15 @@
/* ═══════════════════════════════════════════════════════════════
SITE PAGE ROUTES: read-only, mounted under /api
GET /nav this visitor's header and footer links and
the hidden pages (siteNav.js); not cached,
since it depends on who's signed in
GET /site-pages every site page's section headings, for
the header's dropdowns and the side nav
GET /site-pages/:id one page's sections, in order: heading,
accent, preset (and an events preset's
filter and view), and its blocks
filter and view), and its blocks; Not
found for a hidden page, below viewer
Edited in the admin as Pages → each page
(admin-schema/sitePages.js). Blocks are shaped as on any record
@ -13,10 +17,17 @@
═══════════════════════════════════════════════════════════════ */
import { Hono } from "hono";
import { json, loadBlocks } from "../shape.js";
import { currentUser } from "../auth.js";
import { hiddenPaths, navFor, seesHidden } from "../siteNav.js";
import { NO_STORE, json, loadBlocks } from "../shape.js";
const sitePages = new Hono();
sitePages.get("/nav", (c) => {
const db = c.get("db");
return c.json({ nav: navFor(db, currentUser(db, c)) }, 200, NO_STORE);
});
sitePages.get("/site-pages", (c) => {
const rows = c
.get("db")
@ -31,7 +42,8 @@ sitePages.get("/site-pages", (c) => {
sitePages.get("/site-pages/:id", (c) => {
const db = c.get("db");
const id = c.req.param("id");
if (!db.prepare(`SELECT 1 FROM site_pages WHERE id = ?`).get(id)) {
const hidden = hiddenPaths(db).has(`/${id}`);
if (!db.prepare(`SELECT 1 FROM site_pages WHERE id = ?`).get(id) || (hidden && !seesHidden(currentUser(db, c)))) {
return c.json({ error: "No such page." }, 404);
}
@ -53,7 +65,9 @@ sitePages.get("/site-pages/:id", (c) => {
picked.set(section_id, [...(picked.get(section_id) ?? []), org_id]);
}
return json(c, {
// A hidden page is only for those signed in: never kept.
const send = hidden ? (body) => c.json(body, 200, NO_STORE) : (body) => json(c, body);
return send({
page: {
id,
sections: rows.map(({ id: sectionId, ...section }) => ({