NGU-Web/src/lib/useSitePages.ts
Zaldimmar 9daf7b1a4f Page editors: Retreats, Community, Resources, Organization and History built from sections
Each page is now a list of sections edited in Admin → Pages: a title
(30 characters at most, for the side nav), URL ID, blurb and accent,
its own content blocks, and an optional preset (Community blog, groups
map, region list, partner cards, events, timeline, NGU's details).
Migration 056 seeds every page as the code drew it and moves the
Organization editor's blocks and volunteering into its sections. The
Community blog's settings move into the Community editor. The header,
footer and side nav read each page's sections from the API.

The admin engine reads and writes nested collections to any depth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 00:15:30 -05:00

25 lines
946 B
TypeScript

/* The site's own pages (Community, Retreats, Resources, Organization,
History), built in the admin from sections: GET /site-pages/:id
for one page's sections, GET /site-pages for every page's section
headings (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
blocks: ContentBlock[]
}
export const useSitePage = (id: string): Resource<{ id: string; sections: SitePageSection[] }> =>
useRecord(`/site-pages/${id}`, 'page')
export const useSitePageHeadings = (): Resource<Record<string, Array<{ anchor: string; title: string }>>> =>
useRecord('/site-pages', 'pages')