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:
parent
56acedf926
commit
1342691f49
36 changed files with 584 additions and 405 deletions
|
|
@ -14,10 +14,11 @@
|
|||
── Where it comes from ──
|
||||
/site.json (SITE_CONFIG): the site's name, address, default
|
||||
description and image, icons, and each static page's title and
|
||||
description. Laid over it: Panel → Site settings (the
|
||||
site_settings table, 035) and Pages → Navigation's page titles
|
||||
(site_nav_pages, 075), where anything set wins and anything
|
||||
blank falls back to site.json. siteFor(db) does the merge. The
|
||||
default description and image, and icons. Laid over it: Panel →
|
||||
Site settings (the site_settings table, 035), where anything set
|
||||
wins and anything blank falls back to site.json. siteFor(db) does
|
||||
the merge. Each page's title and intro are its site_pages row's
|
||||
(Pages → Page management, 080). The
|
||||
pages read the same merged values (renderPage writes them into
|
||||
the HTML as window.__SITE__, see src/lib/site.ts), so a
|
||||
heading and its search title can't drift.
|
||||
|
|
@ -47,7 +48,7 @@ import { fileURLToPath } from "node:url";
|
|||
import { loadBlocks, paragraphs } from "./shape.js";
|
||||
import { themeCss } from "./theme.js";
|
||||
import { driveReady } from "./googleService.js";
|
||||
import { hiddenFrom, hiddenPaths, navFor } from "./siteNav.js";
|
||||
import { allPages, hiddenFrom, navFor, pageAt } from "./siteNav.js";
|
||||
|
||||
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
|
|
@ -75,24 +76,15 @@ const origin = (site) => (site.url ?? "").replace(/\/$/, "");
|
|||
|
||||
/* site.json with the admin's Site settings laid over it: a value set
|
||||
there wins, a blank one falls back. indexing 'on' / 'off' overrides
|
||||
robots.index for this database only. Page overrides (Pages →
|
||||
Navigation) apply only to pages site.json knows. */
|
||||
robots.index for this database only. pages: every page's title
|
||||
and intro, by path (site_pages). */
|
||||
export function siteFor(db) {
|
||||
const base = loadSite();
|
||||
const row = db.prepare(`SELECT * FROM site_settings WHERE id = 'site'`).get() ?? {};
|
||||
|
||||
const pages = { ...(base.pages ?? {}) };
|
||||
const overrides = db
|
||||
.prepare(`SELECT path, title, description FROM site_nav_pages WHERE nav_id = 'site'`)
|
||||
.all();
|
||||
for (const page of overrides) {
|
||||
const known = pages[page.path];
|
||||
if (!known) continue;
|
||||
pages[page.path] = {
|
||||
title: page.title || known.title,
|
||||
description: page.description || known.description,
|
||||
};
|
||||
}
|
||||
const pages = Object.fromEntries(
|
||||
allPages(db).map((page) => [page.path, { title: page.title, description: page.description ?? "" }]),
|
||||
);
|
||||
|
||||
return {
|
||||
...base,
|
||||
|
|
@ -410,10 +402,17 @@ export function metaFor(db, rawPath, user = null) {
|
|||
// in particular, so never indexed or in the sitemap.
|
||||
if (ACCOUNT_PAGES[pathname]) return { ...meta, title: titled(site, ACCOUNT_PAGES[pathname]), noindex: true };
|
||||
|
||||
const page = site.pages?.[pathname];
|
||||
// A page of the site (site_pages): hidden is Not found below
|
||||
// viewer; disabled stays out of search.
|
||||
const page = pageAt(db, pathname);
|
||||
if (page && hiddenFrom(db, user, pathname)) return notFound(meta);
|
||||
if (page) {
|
||||
return { ...meta, title: titled(site, page.title), description: plainText(page.description) ?? meta.description };
|
||||
return {
|
||||
...meta,
|
||||
title: titled(site, page.title),
|
||||
description: plainText(page.description) ?? meta.description,
|
||||
noindex: page.is_disabled === 1,
|
||||
};
|
||||
}
|
||||
|
||||
// An event's schedule presentation (SchedulePresent.tsx): the
|
||||
|
|
@ -558,13 +557,13 @@ export function sitemap(db) {
|
|||
const site = siteFor(db);
|
||||
const base = origin(site);
|
||||
const day = (value) => (value ? String(value).slice(0, 10) : null);
|
||||
const hidden = hiddenPaths(db);
|
||||
|
||||
const entries = [
|
||||
{ loc: "/" },
|
||||
...Object.keys(site.pages ?? {})
|
||||
.filter((loc) => !hidden.has(loc))
|
||||
.map((loc) => ({ loc })),
|
||||
// Pages that are neither hidden nor disabled.
|
||||
...allPages(db)
|
||||
.filter((page) => page.path !== "/" && page.is_hidden !== 1 && page.is_disabled !== 1)
|
||||
.map((page) => ({ loc: page.path })),
|
||||
...db
|
||||
.prepare(`SELECT id, updated_at FROM events WHERE is_published = 1 AND is_listed = 1`)
|
||||
.all()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue