NGU-Web/src/lib/useSitePages.ts
Aidan Dona 1342691f49 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>
2026-10-16 23:19:54 -05:00

31 lines
1.3 KiB
TypeScript

/* The site's pages of sections (Pages → Page management): GET
/site-pages/:id for one page's title, intro and sections, GET
/site-pages for every page's section headings by the page's path
(the header's dropdowns, the footer, the side nav). */
import { useRecord, type Resource } from './useRecord.ts'
import type { ContentBlock } from './useContent.ts'
export type SitePageSection = {
anchor: string
title: string
blurb?: string | null
accent?: 'teal' | 'deep' | 'green' | 'amber' | null
preset?: string | null
scope_id?: string | null
event_type?: string | null
view?: string | null
/** A people_directory preset's tags (Data → People tags), a tab each, in order. */
tag_ids: string[]
/** Organization cards: the kinds listed ('partner', 'ministry' or both, comma separated). */
org_kinds?: string | null
/** Organization cards: a hand-picked list, in order, shown instead. */
org_ids: string[]
blocks: ContentBlock[]
}
export const useSitePage = (id: string): Resource<{ id: string; title: string; description: string | null; sections: SitePageSection[] }> =>
useRecord(`/site-pages/${id}`, 'page')
export const useSitePageHeadings = (): Resource<Record<string, Array<{ anchor: string; title: string }>>> =>
useRecord('/site-pages', 'pages')