Page management, step 3: section types with their own settings; the front page as sections

Migration 083 gives the section types that need more than blocks their
own tables (hero, slides, countdown, stats, paths, featured cards, the
Community blog's slots, pinned posts and feeds) and turns the front page
into Home's sections: the hero, then its bands in order. Any section can
be hidden. The Front page editor, its tables and the Community page's
are gone; /api/front-page and /api/community-blog fold into the page's
sections (sectionData.js). The admin engine reads and writes a child
collection's own side tables and gated nested collections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aidan Dona 2026-10-17 00:34:56 -05:00
parent f33c0008fe
commit f1a0b06ac2
46 changed files with 1525 additions and 1339 deletions

View file

@ -7,8 +7,9 @@
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,
GET /site-pages/:id one page's title and intro and its shown
sections, in order, each with what its type
shows (sectionData.js): heading,
accent, preset (and an events preset's
filter and view), and its blocks; Not
found for a hidden page, below viewer
@ -22,6 +23,7 @@ import { Hono } from "hono";
import { currentUser } from "../auth.js";
import { navFor, seesHidden } from "../siteNav.js";
import { NO_STORE, json, loadBlocks } from "../shape.js";
import { withSectionData } from "../sectionData.js";
const sitePages = new Hono();
@ -34,17 +36,18 @@ sitePages.get("/site-pages", (c) => {
const rows = c
.get("db")
.prepare(
`SELECT p.path, s.anchor, s.title FROM page_sections s JOIN site_pages p ON p.id = s.page_id
`SELECT p.path, s.anchor, s.title, s.preset FROM page_sections s JOIN site_pages p ON p.id = s.page_id
WHERE s.is_hidden = 0
ORDER BY p.path, s.sort_order, s.id`,
)
.all();
const pages = {};
for (const row of rows) (pages[row.path] ??= []).push({ anchor: row.anchor, title: row.title });
for (const row of rows) (pages[row.path] ??= []).push({ anchor: row.anchor, title: row.title, preset: row.preset });
return json(c, { pages });
});
sitePages.get("/site-pages/:id", (c) => {
sitePages.get("/site-pages/:id", async (c) => {
const db = c.get("db");
const id = c.req.param("id");
const found = db.prepare(`SELECT title, description, is_hidden FROM site_pages WHERE id = ?`).get(id);
@ -56,7 +59,7 @@ sitePages.get("/site-pages/:id", (c) => {
const rows = db
.prepare(
`SELECT id, anchor, title, blurb, accent, preset, scope_id, event_type, view, org_kinds
FROM page_sections WHERE page_id = ? ORDER BY sort_order, id`,
FROM page_sections WHERE page_id = ? AND is_hidden = 0 ORDER BY sort_order, id`,
)
.all(id);
const blocks = loadBlocks(db, "page_section", rows.map((row) => String(row.id)));
@ -82,6 +85,8 @@ sitePages.get("/site-pages/:id", (c) => {
tags.set(section_id, [...(tags.get(section_id) ?? []), tag_id]);
}
const sections = await withSectionData(db, rows);
// 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({
@ -89,7 +94,7 @@ sitePages.get("/site-pages/:id", (c) => {
id,
title: found.title,
description: found.description,
sections: rows.map(({ id: sectionId, ...section }) => ({
sections: sections.map(({ id: sectionId, ...section }) => ({
...section,
blocks: blocks.get(String(sectionId)) ?? [],
org_ids: picked.get(sectionId) ?? [],