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>
This commit is contained in:
Aidan Dona 2026-10-16 23:19:54 -05:00
parent 56acedf926
commit 1342691f49
36 changed files with 584 additions and 405 deletions

View file

@ -4,9 +4,11 @@
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,
GET /site-pages every page's section headings, by the
page's path, for the header's dropdowns
and the side nav
GET /site-pages/:id one page's title and intro and its
sections, in order: heading,
accent, preset (and an events preset's
filter and view), and its blocks; Not
found for a hidden page, below viewer
@ -18,7 +20,7 @@
import { Hono } from "hono";
import { currentUser } from "../auth.js";
import { hiddenPaths, navFor, seesHidden } from "../siteNav.js";
import { navFor, seesHidden } from "../siteNav.js";
import { NO_STORE, json, loadBlocks } from "../shape.js";
const sitePages = new Hono();
@ -31,19 +33,23 @@ sitePages.get("/nav", (c) => {
sitePages.get("/site-pages", (c) => {
const rows = c
.get("db")
.prepare(`SELECT page_id, anchor, title FROM page_sections ORDER BY page_id, sort_order, id`)
.prepare(
`SELECT p.path, s.anchor, s.title FROM page_sections s JOIN site_pages p ON p.id = s.page_id
ORDER BY p.path, s.sort_order, s.id`,
)
.all();
const pages = {};
for (const row of rows) (pages[row.page_id] ??= []).push({ anchor: row.anchor, title: row.title });
for (const row of rows) (pages[row.path] ??= []).push({ anchor: row.anchor, title: row.title });
return json(c, { pages });
});
sitePages.get("/site-pages/:id", (c) => {
const db = c.get("db");
const id = c.req.param("id");
const hidden = hiddenPaths(db).has(`/${id}`);
if (!db.prepare(`SELECT 1 FROM site_pages WHERE id = ?`).get(id) || (hidden && !seesHidden(currentUser(db, c)))) {
const found = db.prepare(`SELECT title, description, is_hidden FROM site_pages WHERE id = ?`).get(id);
const hidden = found?.is_hidden === 1;
if (!found || (hidden && !seesHidden(currentUser(db, c)))) {
return c.json({ error: "No such page." }, 404);
}
@ -81,6 +87,8 @@ sitePages.get("/site-pages/:id", (c) => {
return send({
page: {
id,
title: found.title,
description: found.description,
sections: rows.map(({ id: sectionId, ...section }) => ({
...section,
blocks: blocks.get(String(sectionId)) ?? [],