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:
parent
f33c0008fe
commit
f1a0b06ac2
46 changed files with 1525 additions and 1339 deletions
|
|
@ -24,7 +24,7 @@
|
|||
heading and its search title can't drift.
|
||||
The database: records' names, taglines, first paragraphs and
|
||||
images. A blank site description falls back to the front page's
|
||||
subhead.
|
||||
hero's subhead.
|
||||
|
||||
── Rules ──
|
||||
published, listed indexed, in the sitemap
|
||||
|
|
@ -167,8 +167,18 @@ function firstParagraph(db, ownerKind, id, slot) {
|
|||
|
||||
const ORG_ROUTES = { region: "/regions", group: "/groups", partner: "/partners", national: "/organizations" };
|
||||
|
||||
/* The front page's first hero (083): its subhead is the site's
|
||||
description when Site settings and site.json have none. */
|
||||
const homeHero = (db) =>
|
||||
db
|
||||
.prepare(
|
||||
`SELECT h.* FROM section_hero h JOIN page_sections s ON s.id = h.section_id
|
||||
WHERE s.page_id = 'home' AND s.is_hidden = 0 ORDER BY s.sort_order LIMIT 1`,
|
||||
)
|
||||
.get();
|
||||
|
||||
function defaults(site, db, pathname) {
|
||||
const home = db.prepare(`SELECT headline, subhead FROM front_page WHERE id = 'home'`).get();
|
||||
const home = homeHero(db);
|
||||
return {
|
||||
status: 200,
|
||||
title: site.title,
|
||||
|
|
@ -370,18 +380,16 @@ export function metaFor(db, rawPath, user = null) {
|
|||
// The home page's data, and its first hero photo when the hero is
|
||||
// a slideshow, requested alongside the app's JavaScript instead of
|
||||
// after it has run.
|
||||
const hero = db.prepare(`SELECT hero_backdrop FROM front_page WHERE id = 'home'`).get();
|
||||
const hero = homeHero(db);
|
||||
const slide =
|
||||
hero?.hero_backdrop === "photos"
|
||||
? db
|
||||
.prepare(`SELECT media FROM front_page_slides WHERE page_id = 'home' ORDER BY sort_order LIMIT 1`)
|
||||
.get()
|
||||
hero?.backdrop === "photos"
|
||||
? db.prepare(`SELECT media FROM section_slides WHERE section_id = ? ORDER BY sort_order LIMIT 1`).get(hero.section_id)
|
||||
: null;
|
||||
const slideSrc = slide?.media ? (/^(https?:|\/)/.test(slide.media) ? slide.media : `${UPLOADS}/${slide.media}`) : null;
|
||||
return {
|
||||
...meta,
|
||||
preload: [
|
||||
{ href: "/api/front-page", as: "fetch" },
|
||||
{ href: "/api/site-pages/home", as: "fetch" },
|
||||
...(slideSrc ? [{ href: slideSrc, as: "image" }] : []),
|
||||
],
|
||||
jsonLd: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue