v1.14.0-profiles: profile accounts, drafts, page management, Planning Center #32
36 changed files with 584 additions and 405 deletions
|
|
@ -62,7 +62,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu
|
||||||
- All pages use `PageShell.tsx` as the wrapper unless explicitly noted otherwise.
|
- All pages use `PageShell.tsx` as the wrapper unless explicitly noted otherwise.
|
||||||
- Pages live in `src/pages/`; section-level components go in `src/pages/sections/`.
|
- Pages live in `src/pages/`; section-level components go in `src/pages/sections/`.
|
||||||
- `src/data/` holds only hardcoded data shared across multiple section files (e.g. `historyDecades.ts`, map grid). Everything else comes from SQLite, through hooks in `src/lib/`.
|
- `src/data/` holds only hardcoded data shared across multiple section files (e.g. `historyDecades.ts`, map grid). Everything else comes from SQLite, through hooks in `src/lib/`.
|
||||||
- Navigation (header and footer links, page titles and intros, hidden pages) is edited in Pages → Navigation (`site_nav*` tables, `server/src/siteNav.js`, read through `src/lib/useSiteNav.ts`). `navConfig.ts` only holds the defaults the app starts from before that loads. Routes are in `App.tsx`; a static page's default title and intro in `site.json`'s `pages`. A hidden page answers Not found below viewer (server and app both).
|
- Pages are rows of `site_pages` (migration 080), edited in Pages → Page management: address, title, intro, Hidden (Not found below viewer) and Disabled (out of the menus, sitemap and search). New pages are made there and are pages of sections; `PageAtPath.tsx` (the `*` route) draws whatever page is at an address, and the few still drawn in code are listed in `src/pages/fixedPages.ts` (and `FIXED_PAGES` in `server/src/admin-schema/sitePages.js`, which can't be deleted). Record routes (`/events/:id`...) stay in `App.tsx`, and their first path segments are reserved. Menu links are Pages → Navigation (`site_nav_links`, `server/src/siteNav.js`, read through `src/lib/useSiteNav.ts`); `navConfig.ts` only holds the defaults the app starts from before that loads.
|
||||||
- `api.ts` is the shared caching client used by frontend data hooks.
|
- `api.ts` is the shared caching client used by frontend data hooks.
|
||||||
- `docs/updating-data-in-code.md`: where content that isn't in the database lives (admin dropdown labels, fixed value lists, nav, banner, decades, map grid) and how to change it. Keep it current when adding a dropdown or code-owned content.
|
- `docs/updating-data-in-code.md`: where content that isn't in the database lives (admin dropdown labels, fixed value lists, nav, banner, decades, map grid) and how to change it. Keep it current when adding a dropdown or code-owned content.
|
||||||
- Images: every record image (logos, photos, backgrounds, block images) is an upload, in a folder by use: `/uploads/logos/`, `/uploads/images/`, `/uploads/thumbnails/` (saved previews), `/uploads/captions/` (videos' .vtt files); a logo or icon image field sets `folder: "logos"` (`docs/media-uploads.md`, Folders). A bare filename resolves to `/uploads/<file>` (`src/lib/media.ts`, and `server/src/pageMeta.js` for previews). Only the site's own chosen assets, the NGU logos in the nav, footer and admin, are bundled from `src/assets/logos/`. Logo images hide themselves on load error (`onError`).
|
- Images: every record image (logos, photos, backgrounds, block images) is an upload, in a folder by use: `/uploads/logos/`, `/uploads/images/`, `/uploads/thumbnails/` (saved previews), `/uploads/captions/` (videos' .vtt files); a logo or icon image field sets `folder: "logos"` (`docs/media-uploads.md`, Folders). A bare filename resolves to `/uploads/<file>` (`src/lib/media.ts`, and `server/src/pageMeta.js` for previews). Only the site's own chosen assets, the NGU logos in the nav, footer and admin, are bundled from `src/assets/logos/`. Logo images hide themselves on load error (`onError`).
|
||||||
|
|
|
||||||
21
TODO.md
21
TODO.md
|
|
@ -43,13 +43,11 @@
|
||||||
|
|
||||||
## Sections
|
## Sections
|
||||||
- [ ] **Hero text that flips**: the headline's word changes (Next, Now, and other words for our generation), or mirrors.
|
- [ ] **Hero text that flips**: the headline's word changes (Next, Now, and other words for our generation), or mirrors.
|
||||||
- [ ] Which words, and are they edited in Front page (a list) or fixed? Answer:
|
- [ ] Which words, and are they edited in Front page (a list) or fixed? Answer: Next cycles through words with an animation, allow us to customize this and the list of words, this should be a text content component that can be used places. also direction from where the words slide in, top or bottom.
|
||||||
- [ ] What motion: a flip like a card, a fade, letters typing, a mirror? Answer:
|
- [ ] What motion: a flip like a card, a fade, letters typing, a mirror? Answer: make all of these.
|
||||||
- [ ] Respect reduced motion by showing one word (the first)? [ ] yes
|
- [ ] Respect reduced motion by showing one word (the first)? [ ] yes
|
||||||
- [ ] "Next generation of New Thought": is that the line it plays on, or a second line under the headline? Answer:
|
- [ ] "Next generation of New Thought": is that the line it plays on, or a second line under the headline? Answer: Unity should also be another one of these animated words that cycles through a list.
|
||||||
- [ ] **NGU and partners**: "How does this partner with An Awakened Path and antn" (from the notes; unclear).
|
- Settled 2026-10-16: words are written inline, {Next|Now|Rising}, in the hero headline, section titles, headings and paragraphs; motion (slide, flip, fade, type, mirror), direction (from top or bottom) and seconds per word have site defaults in Site settings, overridden by the hero or a block.
|
||||||
- [ ] What is "antn" (an organization's name)? Answer:
|
|
||||||
- [ ] Is this a section to build (eg. on Organization or Partners), or a question to answer in a blog post? Answer:
|
|
||||||
|
|
||||||
## Page Features
|
## Page Features
|
||||||
- [ ] **Full profiles**: people get full profile pages. Profile accounts, claiming and visibility are done (Part 2, Accounts); what's left is the page itself.
|
- [ ] **Full profiles**: people get full profile pages. Profile accounts, claiming and visibility are done (Part 2, Accounts); what's left is the page itself.
|
||||||
|
|
@ -78,6 +76,10 @@
|
||||||
## Mobile
|
## Mobile
|
||||||
|
|
||||||
## Page Editing
|
## Page Editing
|
||||||
|
- [ ] **Page management revamp**, in steps (answers from 2026-10-16: disabled means out of the menus, sitemap and search with the address still working; admins can make new pages; the front page, the Community blog's settings, the form and embed pages and Privacy/Terms all become pages of sections; section types like the hero, stats, featured cards, calendar and countdown can go on any page, each with its own content).
|
||||||
|
- [x] Step 1, the page registry (Done, below).
|
||||||
|
- [ ] Step 2: Feedback, Request, Give, QR codes become pages of sections (a section type each for the form, the giving embed and the QR maker); Privacy and Terms become editable blocks (their data request form a section type).
|
||||||
|
- [ ] Step 3: section types with their own settings: the Community blog (its slots, pinned posts and feeds move into the section, so it can go on any page), then the front page's hero, countdown, retreats, calendar, stats, timeline, featured cards and connect, and the front page itself a page of sections.
|
||||||
|
|
||||||
## Admin
|
## Admin
|
||||||
|
|
||||||
|
|
@ -85,10 +87,9 @@
|
||||||
- [ ] **Planning Center sync to People**: Planning Center People into the site's people records.
|
- [ ] **Planning Center sync to People**: Planning Center People into the site's people records.
|
||||||
- [ ] One way (Planning Center → site), or both? Answer: to site only
|
- [ ] One way (Planning Center → site), or both? Answer: to site only
|
||||||
- [ ] Who gets synced: everyone, or a Planning Center list or tag (eg. "Website")? Most people in Planning Center shouldn't have a public page. Answer:a specific list
|
- [ ] Who gets synced: everyone, or a Planning Center list or tag (eg. "Website")? Most people in Planning Center shouldn't have a public page. Answer:a specific list
|
||||||
- [ ] Which fields: name, photo, email, phone, birthday? Which win when both sides differ? Answer:
|
- [ ] Which fields: name, photo, email, phone, birthday? Which win when both sides differ? Answer: planning center. but show the comparasin (reconcile) for each user. Fields (2026-10-16): name, and email and phone into the private fields. Matching: suggested by email or name, an admin confirms, then remembered by Planning Center's id.
|
||||||
- [ ] How often: a button in Data, hourly, nightly? Answer: manually only
|
- [ ] How often: a button in Data, hourly, nightly? Answer: manually only
|
||||||
- [ ] Is there a Planning Center API app (personal access token) we can use, and which account owns it? Answer: use the API
|
- [ ] Is there a Planning Center API app (personal access token) we can use, and which account owns it? Answer: use the API
|
||||||
- Skipped on 2026-10-16 until the fields (and which side wins) are decided.
|
|
||||||
- [ ] **New Thought young adult directory**: the tabs are built (Part 2, Page features). Content: make the People tags (eg. Authors, Creators), tag people, and set Community's Directories section to them.
|
- [ ] **New Thought young adult directory**: the tabs are built (Part 2, Page features). Content: make the People tags (eg. Authors, Creators), tag people, and set Community's Directories section to them.
|
||||||
|
|
||||||
## Navigation
|
## Navigation
|
||||||
|
|
@ -122,6 +123,10 @@
|
||||||
|
|
||||||
|
|
||||||
# Part 2: Done
|
# Part 2: Done
|
||||||
|
## Page management (branch `page-management`, on top of `page-features`, no PR yet; migration 080, back up the database before deploying)
|
||||||
|
- [x] **Page registry** (migration 080): every page of the site is a row in Pages → Page management (admins and up): its address, title, intro, Hidden (Not found below viewer) and Disabled (out of the menus, the sitemap and search; the address still works), and the order of its admin card. New pages are made there, as pages of sections at the address given (any address but the admin's, the API's, the records' and the account pages'). The admin home's Pages group opens with a Page management banner (New page, Menus), then a card per page. The six page editors (Retreats, Community...) are one editor now; site.json's `pages` and Navigation's page list moved into the registry and are gone. The fixed pages (Feedback, Request, Give, QR codes, Privacy, Terms, the front page) take their words from it too and can't be deleted.
|
||||||
|
- [ ] Check in a browser: the admin home's banner and page cards, making a page (address, sections) and opening it, hiding and disabling one (menus, the page signed out), renaming Feedback, the Under page select in Navigation.
|
||||||
|
|
||||||
## v1.14.0-profiles: page features (branch `page-features`, with `nav-access` under it, no PR yet; migrations 078 and 079, back up the database before deploying)
|
## v1.14.0-profiles: page features (branch `page-features`, with `nav-access` under it, no PR yet; migrations 078 and 079, back up the database before deploying)
|
||||||
- [x] **Featured event label** (Mobile): the "Featured event" badge left the headline; from lg up it sits above the event's card it names, and on a phone (the card under the words) it's left out.
|
- [x] **Featured event label** (Mobile): the "Featured event" badge left the headline; from lg up it sits above the event's card it names, and on a phone (the card under the words) it's left out.
|
||||||
- [x] **Site version names**: the tag's words after the number are the version's name, `v1.13.2-region-cards` → "The Region Cards Update" (`src/lib/version.ts`), shown with the number in the site's footer and beside the version in the admin's footer and home.
|
- [x] **Site version names**: the tag's words after the number are the version's name, `v1.13.2-region-cards` → "The Region Cards Update" (`src/lib/version.ts`), shown with the number in the site's footer and beside the version in the admin's footer and home.
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ same build.
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| Site name, address, default description | `site.json`: `title`, `url`, `description` (blank uses the front page's subhead) |
|
| Site name, address, default description | `site.json`: `title`, `url`, `description` (blank uses the front page's subhead) |
|
||||||
| Default preview image | `site.json`: `openGraph.image`, eg. `/uploads/<file>` from Admin → Tools → Media. Blank means pages without their own image have none. |
|
| Default preview image | `site.json`: `openGraph.image`, eg. `/uploads/<file>` from Admin → Tools → Media. Blank means pages without their own image have none. |
|
||||||
| Static pages (Retreats, Community, History…) | `site.json`: `pages`. The page's heading and intro read the same entry, so they can't drift. A new static page needs an entry. |
|
| The site's pages (Retreats, Community, History…) | Admin → Pages → Page management (`site_pages`). The page's heading and intro read the same row, so they can't drift. Disabled pages are `noindex` and out of the sitemap; hidden ones are a 404 to search engines. |
|
||||||
| Records (events, organizations, teams, awards, people, posts) | The database: the record's name, then its tagline or first paragraph; its own image (an event's card background, else its logo; a post's cover; a person's photo; an organization's logo). SVGs aren't used as previews. |
|
| Records (events, organizations, teams, awards, people, posts) | The database: the record's name, then its tagline or first paragraph; its own image (an event's card background, else its logo; a post's cover; a person's photo; an organization's logo). SVGs aren't used as previews. |
|
||||||
| Whether search may list it | `site.json` `robots.index` for the whole site; per record, published and listed is indexed, published but unlisted is `noindex`, anything else is a 404. `/admin` is always `noindex`. |
|
| Whether search may list it | `site.json` `robots.index` for the whole site; per record, published and listed is indexed, published but unlisted is `noindex`, anything else is a 404. `/admin` is always `noindex`. |
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ what a dropdown in the admin editor says.
|
||||||
| The **label** a dropdown shows in the admin | code | [one file](#renaming-what-a-dropdown-shows) |
|
| The **label** a dropdown shows in the admin | code | [one file](#renaming-what-a-dropdown-shows) |
|
||||||
| The **list of allowed values** behind a fixed dropdown | database CHECK + code | [a migration and three files](#adding-removing-or-renaming-a-stored-value) |
|
| The **list of allowed values** behind a fixed dropdown | database CHECK + code | [a migration and three files](#adding-removing-or-renaming-a-stored-value) |
|
||||||
| Navigation, colors, the site banner, history decades, the map grid | code | [the file named below](#other-content-that-lives-in-code) |
|
| Navigation, colors, the site banner, history decades, the map grid | code | [the file named below](#other-content-that-lives-in-code) |
|
||||||
| A static page's title and intro (also its search title and description), the site's name, description, preview image, icons, search indexing, privacy contact email | the database, over `site.json` | Admin → Panel → Site settings (superadmins). Blank uses `site.json`, which also holds the site's address and the pages' defaults. See `docs/seo.md` |
|
| A page's title and intro (also its search title and description), its address, Hidden and Disabled | the database (`site_pages`, 080) | Admin → Pages → Page management (admins and up), where new pages are made too |
|
||||||
|
| The site's name, description, preview image, icons, search indexing, privacy contact email | the database, over `site.json` | Admin → Panel → Site settings (superadmins). Blank uses `site.json`, which also holds the site's address. See `docs/seo.md` |
|
||||||
| Uploaded images | disk + the `media` table | Admin → Tools → Media, or any image field. See `docs/media-uploads.md` |
|
| Uploaded images | disk + the `media` table | Admin → Tools → Media, or any image field. See `docs/media-uploads.md` |
|
||||||
|
|
||||||
The rule of thumb from `CLAUDE.md`: data belongs in the database,
|
The rule of thumb from `CLAUDE.md`: data belongs in the database,
|
||||||
|
|
@ -278,7 +279,7 @@ The numbers band's "Number Source" dropdown works the same way:
|
||||||
|
|
||||||
| What | File | Notes |
|
| What | File | Notes |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| Header and footer navigation, each page's sections (the header dropdowns, mobile menu and footer site map) | Admin → Pages → Navigation (the database, `075_site_nav.sql`); `src/navConfig.ts` is only the defaults the app starts from before it loads | Links: where each shows (header pages, header buttons, footer Get in Touch, footer bottom row), order, label, a header page set under another's menu, a filled button, new tab. Pages: title, intro and Hidden (Not found below viewer, out of the menus and the sitemap; `server/src/siteNav.js`). Each page's sections aren't listed there: they follow the page itself, through `src/lib/navSections.ts` (the site pages' sections from Admin → Pages; the front page's bands it shows, with `src/lib/frontPageBands.ts` giving each band's anchor and default heading). A new static page needs a route in `src/App.tsx` and an entry in `site.json`'s `pages` (its default title and intro, and what Navigation's Page select offers); a new page of sections also needs its id in `site_pages`' CHECK and a descriptor in both admin schemas, like Shop (075). |
|
| Header and footer navigation, each page's sections (the header dropdowns, mobile menu and footer site map) | Admin → Pages → Navigation (the database, `075_site_nav.sql`); `src/navConfig.ts` is only the defaults the app starts from before it loads | Links: where each shows (header pages, header buttons, footer Get in Touch, footer bottom row), order, label, a header page set under another's menu, a filled button, new tab. Each page's sections aren't listed there: they follow the page itself, through `src/lib/navSections.ts` (the site pages' sections from Admin → Pages; the front page's bands it shows, with `src/lib/frontPageBands.ts` giving each band's anchor and default heading). A new page is made in Page management, no code: it's a page of sections at the address given. |
|
||||||
| Section titles, blurbs and colors on Feedback, Privacy, Terms | the page file in `src/pages/` | the `SECTIONS` array at the top. |
|
| Section titles, blurbs and colors on Feedback, Privacy, Terms | the page file in `src/pages/` | the `SECTIONS` array at the top. |
|
||||||
| Site-wide announcement banner | `src/data/bannerConfig.ts` | `enabled: false` hides it. Bump `id` when the message changes, so people who dismissed the old one see the new one. |
|
| Site-wide announcement banner | `src/data/bannerConfig.ts` | `enabled: false` hides it. Bump `id` when the message changes, so people who dismissed the old one see the new one. |
|
||||||
| History page decade headers | `src/data/historyDecades.ts` | Title, tagline and blurb per decade. |
|
| History page decade headers | `src/data/historyDecades.ts` | Title, tagline and blurb per decade. |
|
||||||
|
|
|
||||||
|
|
@ -411,6 +411,10 @@ export function deleteRow(db, entity, rawId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = normalizeId(entity, rawId);
|
const id = normalizeId(entity, rawId);
|
||||||
|
// Records the site can't do without (the pages it draws in code).
|
||||||
|
if (entity.undeletable?.includes(id)) {
|
||||||
|
throw new HttpError(405, "The site needs this one: it can be hidden or disabled, not deleted.");
|
||||||
|
}
|
||||||
const result = wrapDbErrors(() =>
|
const result = wrapDbErrors(() =>
|
||||||
db.prepare(`DELETE FROM ${entity.table} WHERE ${entity.idColumn} = ?`).run(id),
|
db.prepare(`DELETE FROM ${entity.table} WHERE ${entity.idColumn} = ?`).run(id),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@
|
||||||
on an extension (an organization's contacts)
|
on an extension (an organization's contacts)
|
||||||
singleton the one id this entity ever has; the engine
|
singleton the one id this entity ever has; the engine
|
||||||
refuses create and delete (see front_page)
|
refuses create and delete (see front_page)
|
||||||
|
undeletable ids the engine refuses to delete (the pages the
|
||||||
|
site draws in code)
|
||||||
check (db, id) => void, run after a save has written
|
check (db, id) => void, run after a save has written
|
||||||
everything, inside its transaction: throw an
|
everything, inside its transaction: throw an
|
||||||
HttpError to refuse it (site settings' colors)
|
HttpError to refuse it (site settings' colors)
|
||||||
|
|
@ -59,14 +61,7 @@ import { personTagTypes } from "./admin-schema/personTags.js";
|
||||||
import { tags } from "./admin-schema/tags.js";
|
import { tags } from "./admin-schema/tags.js";
|
||||||
import { contactTypes } from "./admin-schema/contactTypes.js";
|
import { contactTypes } from "./admin-schema/contactTypes.js";
|
||||||
import { redirects } from "./admin-schema/redirects.js";
|
import { redirects } from "./admin-schema/redirects.js";
|
||||||
import {
|
import { pages } from "./admin-schema/sitePages.js";
|
||||||
communityPage,
|
|
||||||
retreatsPage,
|
|
||||||
resourcesPage,
|
|
||||||
organizationPage,
|
|
||||||
historyPage,
|
|
||||||
shopPage,
|
|
||||||
} from "./admin-schema/sitePages.js";
|
|
||||||
|
|
||||||
export const ENTITIES = {
|
export const ENTITIES = {
|
||||||
organizations,
|
organizations,
|
||||||
|
|
@ -81,12 +76,7 @@ export const ENTITIES = {
|
||||||
timeline,
|
timeline,
|
||||||
front_page: frontPage,
|
front_page: frontPage,
|
||||||
blog_posts: blogPosts,
|
blog_posts: blogPosts,
|
||||||
community_page: communityPage,
|
pages,
|
||||||
retreats_page: retreatsPage,
|
|
||||||
resources_page: resourcesPage,
|
|
||||||
organization_page: organizationPage,
|
|
||||||
history_page: historyPage,
|
|
||||||
shop_page: shopPage,
|
|
||||||
navigation: siteNav,
|
navigation: siteNav,
|
||||||
site_settings: siteSettings,
|
site_settings: siteSettings,
|
||||||
newsletters,
|
newsletters,
|
||||||
|
|
@ -116,6 +106,8 @@ export const OPTION_QUERIES = {
|
||||||
// Link fields with `redirects: true` pick from these (068).
|
// Link fields with `redirects: true` pick from these (068).
|
||||||
redirects: "SELECT id, id || ' (' || target_url || ')' AS label FROM redirects ORDER BY id",
|
redirects: "SELECT id, id || ' (' || target_url || ')' AS label FROM redirects ORDER BY id",
|
||||||
blog_posts: "SELECT id, title AS label FROM blog_posts ORDER BY published_on DESC, title",
|
blog_posts: "SELECT id, title AS label FROM blog_posts ORDER BY published_on DESC, title",
|
||||||
|
// Navigation's Under page: a page by its address (080).
|
||||||
|
site_pages: "SELECT path AS id, title || ' (' || path || ')' AS label FROM site_pages ORDER BY sort_order, title",
|
||||||
|
|
||||||
// org_id rides along so the affiliation row can filter the list
|
// org_id rides along so the affiliation row can filter the list
|
||||||
// down to teams of the organization it already names.
|
// down to teams of the organization it already names.
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import { text, bool, enumeration } from "./columns.js";
|
import { text, bool, enumeration } from "./columns.js";
|
||||||
|
|
||||||
/* ── Navigation (075_site_nav.sql) ───────────────────────────────
|
/* ── Navigation (075_site_nav.sql) ───────────────────────────────
|
||||||
Pages → Navigation: the header's and footer's links, in order,
|
Pages → Navigation: the header's and footer's links, in order
|
||||||
and each static page's title, intro and whether it's hidden
|
(siteNav.js reads them for the site; the pages themselves are
|
||||||
(siteNav.js reads it for the site). Admins and up: it can take a
|
Page management's, sitePages.js). Admins and up. */
|
||||||
page off the site. */
|
|
||||||
export const siteNav = {
|
export const siteNav = {
|
||||||
key: "navigation",
|
key: "navigation",
|
||||||
table: "site_nav",
|
table: "site_nav",
|
||||||
|
|
@ -33,12 +32,5 @@ export const siteNav = {
|
||||||
bool("new_tab"),
|
bool("new_tab"),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: "pages",
|
|
||||||
table: "site_nav_pages",
|
|
||||||
owner: { column: "nav_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [text("path", { required: true }), text("title"), text("description"), bool("is_hidden")],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,19 @@
|
||||||
import { text, url, int, enumeration, featuredCardsChild, blocksChild } from "./columns.js";
|
import { HttpError } from "../admin-crud.js";
|
||||||
|
import { text, url, int, bool, enumeration, featuredCardsChild, blocksChild } from "./columns.js";
|
||||||
|
|
||||||
/* ── The site's own pages (056_site_pages.sql) ───────────────────
|
/* ── The site's pages (056_site_pages.sql, 080_page_registry.sql) ──
|
||||||
|
|
||||||
Community, Retreats, Resources, Organization, History and Shop
|
Pages → Page management: every page of the site, one site_pages
|
||||||
(075): one
|
row each (its address, title, intro, Hidden and Disabled), with
|
||||||
site_pages row each, edited as its own singleton, with its
|
its sections nested under it and each section's blocks under that
|
||||||
sections nested under it and each section's blocks under that
|
|
||||||
(the blocks' items under them, as on any record). A section is
|
(the blocks' items under them, as on any record). A section is
|
||||||
either its blocks or a preset, a prebuilt part of the site
|
either its blocks or a preset, a prebuilt part of the site
|
||||||
(SitePage.tsx draws both).
|
(SitePage.tsx draws both). New pages are made here.
|
||||||
|
|
||||||
Community also carries the blog section's settings: the
|
Community also carries the blog section's settings: the
|
||||||
community_page row (same id) as an extension, and its pinned
|
community_page row (same id) as an extension, and its pinned
|
||||||
posts, cards and feeds, all owned by that id. */
|
posts, cards and feeds, all owned by that id; only for the page
|
||||||
|
whose id is community. */
|
||||||
|
|
||||||
const sectionsChild = {
|
const sectionsChild = {
|
||||||
key: "sections",
|
key: "sections",
|
||||||
|
|
@ -60,27 +61,62 @@ const sectionsChild = {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const sitePage = (id, more = {}) => ({
|
|
||||||
key: `${id}_page`,
|
/* Pages the site draws in code (src/pages/fixedPages.ts): they can be
|
||||||
|
renamed, moved, hidden or disabled, never deleted. */
|
||||||
|
export const FIXED_PAGES = ["home", "give", "feedback", "request", "qr", "privacy", "terms"];
|
||||||
|
|
||||||
|
/* Addresses a page can't take: the admin, the API, the uploads, the
|
||||||
|
records' own pages and the account pages. */
|
||||||
|
const RESERVED = [
|
||||||
|
"admin", "api", "uploads", "assets", "pa", "go",
|
||||||
|
"events", "regions", "groups", "partners", "organizations", "teams", "awards", "people", "blog", "directory",
|
||||||
|
"sign-in", "account", "sitemap.xml", "robots.txt",
|
||||||
|
];
|
||||||
|
|
||||||
|
/* After a save: the address is one a page may have. */
|
||||||
|
function checkPage(db, id) {
|
||||||
|
const page = db.prepare(`SELECT path FROM site_pages WHERE id = ?`).get(id);
|
||||||
|
const first = page?.path.split("/")[1];
|
||||||
|
if (first && RESERVED.includes(first)) {
|
||||||
|
throw new HttpError(422, "Validation failed", { path: `/${first} belongs to another part of the site. Pick another address.` });
|
||||||
|
}
|
||||||
|
if (id === "home" && page.path !== "/") throw new HttpError(422, "Validation failed", { path: "The front page stays at /." });
|
||||||
|
if (id !== "home" && page.path === "/") throw new HttpError(422, "Validation failed", { path: "/ is the front page." });
|
||||||
|
}
|
||||||
|
|
||||||
|
const isCommunity = { column: "id", value: "community" };
|
||||||
|
|
||||||
|
export const pages = {
|
||||||
|
key: "pages",
|
||||||
table: "site_pages",
|
table: "site_pages",
|
||||||
idColumn: "id",
|
idColumn: "id",
|
||||||
idKind: "slug",
|
idKind: "slug",
|
||||||
singleton: id,
|
|
||||||
concurrency: "updated_at",
|
concurrency: "updated_at",
|
||||||
|
undeletable: FIXED_PAGES,
|
||||||
|
|
||||||
list: { columns: ["id", "updated_at"], filters: [], search: [], order: "id" },
|
list: {
|
||||||
|
columns: ["title", "path", "is_hidden", "is_disabled", "updated_at"],
|
||||||
|
filters: [],
|
||||||
|
search: ["title", "path"],
|
||||||
|
order: "sort_order, title",
|
||||||
|
},
|
||||||
|
|
||||||
columns: [],
|
columns: [
|
||||||
...more,
|
text("path", { required: true }),
|
||||||
children: [sectionsChild, ...(more.children ?? [])],
|
text("title", { required: true }),
|
||||||
});
|
text("description"),
|
||||||
|
bool("is_hidden"),
|
||||||
|
bool("is_disabled"),
|
||||||
|
int("sort_order"),
|
||||||
|
],
|
||||||
|
|
||||||
export const communityPage = sitePage("community", {
|
|
||||||
extensions: [
|
extensions: [
|
||||||
{
|
{
|
||||||
key: "blog",
|
key: "blog",
|
||||||
table: "community_page",
|
table: "community_page",
|
||||||
idColumn: "id",
|
idColumn: "id",
|
||||||
|
when: isCommunity,
|
||||||
columns: [
|
columns: [
|
||||||
text("internal_title"),
|
text("internal_title"),
|
||||||
int("internal_slots"),
|
int("internal_slots"),
|
||||||
|
|
@ -91,27 +127,27 @@ export const communityPage = sitePage("community", {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
|
sectionsChild,
|
||||||
{
|
{
|
||||||
key: "pinned_posts",
|
key: "pinned_posts",
|
||||||
table: "community_page_pinned_posts",
|
table: "community_page_pinned_posts",
|
||||||
owner: { column: "page_id" },
|
owner: { column: "page_id" },
|
||||||
order: "sort_order",
|
order: "sort_order",
|
||||||
|
when: isCommunity,
|
||||||
columns: [text("post_id", { required: true })],
|
columns: [text("post_id", { required: true })],
|
||||||
},
|
},
|
||||||
featuredCardsChild("community_page"),
|
{ ...featuredCardsChild("community_page"), when: isCommunity },
|
||||||
{
|
{
|
||||||
key: "feeds",
|
key: "feeds",
|
||||||
table: "community_page_feeds",
|
table: "community_page_feeds",
|
||||||
owner: { column: "page_id" },
|
owner: { column: "page_id" },
|
||||||
order: "sort_order",
|
order: "sort_order",
|
||||||
|
when: isCommunity,
|
||||||
columns: [url("url", { required: true }), text("label")],
|
columns: [url("url", { required: true }), text("label")],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
|
||||||
|
|
||||||
export const retreatsPage = sitePage("retreats");
|
check: checkPage,
|
||||||
export const resourcesPage = sitePage("resources");
|
};
|
||||||
export const organizationPage = sitePage("organization");
|
|
||||||
export const historyPage = sitePage("history");
|
|
||||||
export const shopPage = sitePage("shop");
|
|
||||||
|
|
|
||||||
93
server/src/migrations/080_page_registry.sql
Normal file
93
server/src/migrations/080_page_registry.sql
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 080 PAGE REGISTRY
|
||||||
|
--
|
||||||
|
-- Every page of the site is a site_pages row: its address, title
|
||||||
|
-- and intro (the page's heading and its search text), and two
|
||||||
|
-- switches, all edited in Pages → Page management, where new pages
|
||||||
|
-- are made too. site.json's "pages" and Navigation's page list
|
||||||
|
-- (site_nav_pages, 075) both move here and go: this is the one
|
||||||
|
-- place a page's words live.
|
||||||
|
--
|
||||||
|
-- path '/retreats'; a new page's own, eg. '/library'.
|
||||||
|
-- Unique; '/' is the front page.
|
||||||
|
-- is_hidden Not found to everyone below viewer, out of the
|
||||||
|
-- menus and sitemap (siteNav.js)
|
||||||
|
-- is_disabled out of the menus, the sitemap and search; the
|
||||||
|
-- address still works
|
||||||
|
-- sort_order the order of the admin home's page cards
|
||||||
|
--
|
||||||
|
-- A page is its sections (page_sections), except the few the site
|
||||||
|
-- still draws in code (src/pages/fixedPages.ts): the front page,
|
||||||
|
-- Feedback, Request, Give, QR codes, Privacy and Terms. Those take
|
||||||
|
-- their title and intro from here all the same, and can't be
|
||||||
|
-- deleted (admin-schema/pages.js).
|
||||||
|
--
|
||||||
|
-- The id stays a slug, as before (page sections, the Community
|
||||||
|
-- blog's settings and the drafts key on it), so an existing page
|
||||||
|
-- keeps its id; its address can change.
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
CREATE TABLE site_pages_new (
|
||||||
|
id TEXT PRIMARY KEY
|
||||||
|
CONSTRAINT "A page's URL ID can use only lowercase letters, numbers and hyphens."
|
||||||
|
CHECK (id <> '' AND id NOT GLOB '*[^a-z0-9-]*'),
|
||||||
|
path TEXT NOT NULL UNIQUE
|
||||||
|
CONSTRAINT "A page's address starts with / and uses only lowercase letters, numbers, hyphens and /, eg. /library."
|
||||||
|
CHECK (path = '/' OR (path GLOB '/[a-z0-9]*' AND path NOT GLOB '*[^a-z0-9/-]*' AND path NOT GLOB '*/')),
|
||||||
|
title TEXT NOT NULL,
|
||||||
|
description TEXT,
|
||||||
|
is_hidden INTEGER NOT NULL DEFAULT 0 CHECK (is_hidden IN (0, 1)),
|
||||||
|
is_disabled INTEGER NOT NULL DEFAULT 0 CHECK (is_disabled IN (0, 1)),
|
||||||
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||||
|
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
INSERT INTO site_pages_new (id, path, title, description, sort_order) VALUES
|
||||||
|
('home', '/', 'Home', NULL, 0),
|
||||||
|
('retreats', '/retreats', 'Retreats', 'Retreats hosted by Next Generation of Unity, our regions, and our partners throughout the year.', 1),
|
||||||
|
('community', '/community', 'Community', 'Groups, regions and the people who make up Next Generation of Unity.', 2),
|
||||||
|
('resources', '/resources', 'Resources', 'Teachings, brand assets, and material for groups and partners.', 3),
|
||||||
|
('organization', '/organization', 'Organization', 'Our mission, vision and values, the people who lead Next Generation of Unity, and how to reach us.', 4),
|
||||||
|
('history', '/history', 'History', 'A near-complete timeline of Next Generation of Unity (NGU), and other Unity Young Adult programs.', 5),
|
||||||
|
('shop', '/shop', 'Shop', 'Shirts, stickers and more from Next Generation of Unity. Every purchase supports our retreats and programs.', 6),
|
||||||
|
('give', '/give', 'Giving', 'Support the work of Next Generation of Unity.', 7),
|
||||||
|
('feedback', '/feedback', 'Feedback', 'Tell us what''s working, what isn''t, and what you''d like to see next.', 8),
|
||||||
|
('request', '/request', 'Request', 'Ask for a blog post, an event, or a new or updated group, region, partner, team, award or person on the site.', 9),
|
||||||
|
('qr', '/qr', 'QR Codes', 'Codes for flyers, slides and signs, pointing at any page on the site or any link, in your choice of colors.', 10),
|
||||||
|
('privacy', '/privacy', 'Privacy Policy', 'How Next Generation of Unity collects, uses, and protects your information.', 11),
|
||||||
|
('terms', '/terms', 'Terms of Service', 'The terms that apply when you use this site and our programs.', 12);
|
||||||
|
|
||||||
|
-- Each page's sections' save time comes along.
|
||||||
|
UPDATE site_pages_new
|
||||||
|
SET updated_at = (SELECT updated_at FROM site_pages WHERE site_pages.id = site_pages_new.id)
|
||||||
|
WHERE id IN (SELECT id FROM site_pages);
|
||||||
|
|
||||||
|
-- What Navigation (or before it Site settings) changed.
|
||||||
|
UPDATE site_pages_new
|
||||||
|
SET title = COALESCE((SELECT n.title FROM site_nav_pages n WHERE n.path = site_pages_new.path), title),
|
||||||
|
description = COALESCE((SELECT n.description FROM site_nav_pages n WHERE n.path = site_pages_new.path), description),
|
||||||
|
is_hidden = COALESCE((SELECT n.is_hidden FROM site_nav_pages n WHERE n.path = site_pages_new.path), is_hidden);
|
||||||
|
|
||||||
|
DROP TABLE site_nav_pages;
|
||||||
|
|
||||||
|
-- The admin edits every page as one entity now ('pages'), so a
|
||||||
|
-- page's draft (077) moves under it.
|
||||||
|
UPDATE drafts
|
||||||
|
SET entity = 'pages', record_id = substr(entity, 1, length(entity) - 5)
|
||||||
|
WHERE entity IN ('community_page', 'retreats_page', 'resources_page', 'organization_page', 'history_page', 'shop_page');
|
||||||
|
|
||||||
|
-- page_sections names site_pages; legacy mode leaves it alone
|
||||||
|
-- through the rename.
|
||||||
|
PRAGMA legacy_alter_table = ON;
|
||||||
|
DROP TABLE site_pages;
|
||||||
|
ALTER TABLE site_pages_new RENAME TO site_pages;
|
||||||
|
PRAGMA legacy_alter_table = OFF;
|
||||||
|
|
||||||
|
CREATE INDEX site_pages_order_idx ON site_pages (sort_order);
|
||||||
|
|
||||||
|
CREATE TRIGGER site_pages_touch
|
||||||
|
AFTER UPDATE ON site_pages
|
||||||
|
FOR EACH ROW WHEN new.updated_at = old.updated_at
|
||||||
|
BEGIN
|
||||||
|
UPDATE site_pages SET updated_at = datetime('now') WHERE id = new.id;
|
||||||
|
END;
|
||||||
|
|
@ -14,10 +14,11 @@
|
||||||
── Where it comes from ──
|
── Where it comes from ──
|
||||||
/site.json (SITE_CONFIG): the site's name, address, default
|
/site.json (SITE_CONFIG): the site's name, address, default
|
||||||
description and image, icons, and each static page's title and
|
description and image, icons, and each static page's title and
|
||||||
description. Laid over it: Panel → Site settings (the
|
default description and image, and icons. Laid over it: Panel →
|
||||||
site_settings table, 035) and Pages → Navigation's page titles
|
Site settings (the site_settings table, 035), where anything set
|
||||||
(site_nav_pages, 075), where anything set wins and anything
|
wins and anything blank falls back to site.json. siteFor(db) does
|
||||||
blank falls back to site.json. siteFor(db) does the merge. The
|
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
|
pages read the same merged values (renderPage writes them into
|
||||||
the HTML as window.__SITE__, see src/lib/site.ts), so a
|
the HTML as window.__SITE__, see src/lib/site.ts), so a
|
||||||
heading and its search title can't drift.
|
heading and its search title can't drift.
|
||||||
|
|
@ -47,7 +48,7 @@ import { fileURLToPath } from "node:url";
|
||||||
import { loadBlocks, paragraphs } from "./shape.js";
|
import { loadBlocks, paragraphs } from "./shape.js";
|
||||||
import { themeCss } from "./theme.js";
|
import { themeCss } from "./theme.js";
|
||||||
import { driveReady } from "./googleService.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));
|
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
|
/* 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
|
there wins, a blank one falls back. indexing 'on' / 'off' overrides
|
||||||
robots.index for this database only. Page overrides (Pages →
|
robots.index for this database only. pages: every page's title
|
||||||
Navigation) apply only to pages site.json knows. */
|
and intro, by path (site_pages). */
|
||||||
export function siteFor(db) {
|
export function siteFor(db) {
|
||||||
const base = loadSite();
|
const base = loadSite();
|
||||||
const row = db.prepare(`SELECT * FROM site_settings WHERE id = 'site'`).get() ?? {};
|
const row = db.prepare(`SELECT * FROM site_settings WHERE id = 'site'`).get() ?? {};
|
||||||
|
|
||||||
const pages = { ...(base.pages ?? {}) };
|
const pages = Object.fromEntries(
|
||||||
const overrides = db
|
allPages(db).map((page) => [page.path, { title: page.title, description: page.description ?? "" }]),
|
||||||
.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,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...base,
|
...base,
|
||||||
|
|
@ -410,10 +402,17 @@ export function metaFor(db, rawPath, user = null) {
|
||||||
// in particular, so never indexed or in the sitemap.
|
// in particular, so never indexed or in the sitemap.
|
||||||
if (ACCOUNT_PAGES[pathname]) return { ...meta, title: titled(site, ACCOUNT_PAGES[pathname]), noindex: true };
|
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 && hiddenFrom(db, user, pathname)) return notFound(meta);
|
||||||
if (page) {
|
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
|
// An event's schedule presentation (SchedulePresent.tsx): the
|
||||||
|
|
@ -558,13 +557,13 @@ export function sitemap(db) {
|
||||||
const site = siteFor(db);
|
const site = siteFor(db);
|
||||||
const base = origin(site);
|
const base = origin(site);
|
||||||
const day = (value) => (value ? String(value).slice(0, 10) : null);
|
const day = (value) => (value ? String(value).slice(0, 10) : null);
|
||||||
const hidden = hiddenPaths(db);
|
|
||||||
|
|
||||||
const entries = [
|
const entries = [
|
||||||
{ loc: "/" },
|
{ loc: "/" },
|
||||||
...Object.keys(site.pages ?? {})
|
// Pages that are neither hidden nor disabled.
|
||||||
.filter((loc) => !hidden.has(loc))
|
...allPages(db)
|
||||||
.map((loc) => ({ loc })),
|
.filter((page) => page.path !== "/" && page.is_hidden !== 1 && page.is_disabled !== 1)
|
||||||
|
.map((page) => ({ loc: page.path })),
|
||||||
...db
|
...db
|
||||||
.prepare(`SELECT id, updated_at FROM events WHERE is_published = 1 AND is_listed = 1`)
|
.prepare(`SELECT id, updated_at FROM events WHERE is_published = 1 AND is_listed = 1`)
|
||||||
.all()
|
.all()
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@
|
||||||
GET /nav this visitor's header and footer links and
|
GET /nav this visitor's header and footer links and
|
||||||
the hidden pages (siteNav.js); not cached,
|
the hidden pages (siteNav.js); not cached,
|
||||||
since it depends on who's signed in
|
since it depends on who's signed in
|
||||||
GET /site-pages every site page's section headings, for
|
GET /site-pages every page's section headings, by the
|
||||||
the header's dropdowns and the side nav
|
page's path, for the header's dropdowns
|
||||||
GET /site-pages/:id one page's sections, in order: heading,
|
and the side nav
|
||||||
|
GET /site-pages/:id one page's title and intro and its
|
||||||
|
sections, in order: heading,
|
||||||
accent, preset (and an events preset's
|
accent, preset (and an events preset's
|
||||||
filter and view), and its blocks; Not
|
filter and view), and its blocks; Not
|
||||||
found for a hidden page, below viewer
|
found for a hidden page, below viewer
|
||||||
|
|
@ -18,7 +20,7 @@
|
||||||
|
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
import { currentUser } from "../auth.js";
|
import { currentUser } from "../auth.js";
|
||||||
import { hiddenPaths, navFor, seesHidden } from "../siteNav.js";
|
import { navFor, seesHidden } from "../siteNav.js";
|
||||||
import { NO_STORE, json, loadBlocks } from "../shape.js";
|
import { NO_STORE, json, loadBlocks } from "../shape.js";
|
||||||
|
|
||||||
const sitePages = new Hono();
|
const sitePages = new Hono();
|
||||||
|
|
@ -31,19 +33,23 @@ sitePages.get("/nav", (c) => {
|
||||||
sitePages.get("/site-pages", (c) => {
|
sitePages.get("/site-pages", (c) => {
|
||||||
const rows = c
|
const rows = c
|
||||||
.get("db")
|
.get("db")
|
||||||
.prepare(`SELECT page_id, anchor, title FROM page_sections ORDER BY page_id, sort_order, id`)
|
.prepare(
|
||||||
|
`SELECT p.path, s.anchor, s.title FROM page_sections s JOIN site_pages p ON p.id = s.page_id
|
||||||
|
ORDER BY p.path, s.sort_order, s.id`,
|
||||||
|
)
|
||||||
.all();
|
.all();
|
||||||
|
|
||||||
const pages = {};
|
const pages = {};
|
||||||
for (const row of rows) (pages[row.page_id] ??= []).push({ anchor: row.anchor, title: row.title });
|
for (const row of rows) (pages[row.path] ??= []).push({ anchor: row.anchor, title: row.title });
|
||||||
return json(c, { pages });
|
return json(c, { pages });
|
||||||
});
|
});
|
||||||
|
|
||||||
sitePages.get("/site-pages/:id", (c) => {
|
sitePages.get("/site-pages/:id", (c) => {
|
||||||
const db = c.get("db");
|
const db = c.get("db");
|
||||||
const id = c.req.param("id");
|
const id = c.req.param("id");
|
||||||
const hidden = hiddenPaths(db).has(`/${id}`);
|
const found = db.prepare(`SELECT title, description, is_hidden FROM site_pages WHERE id = ?`).get(id);
|
||||||
if (!db.prepare(`SELECT 1 FROM site_pages WHERE id = ?`).get(id) || (hidden && !seesHidden(currentUser(db, c)))) {
|
const hidden = found?.is_hidden === 1;
|
||||||
|
if (!found || (hidden && !seesHidden(currentUser(db, c)))) {
|
||||||
return c.json({ error: "No such page." }, 404);
|
return c.json({ error: "No such page." }, 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,6 +87,8 @@ sitePages.get("/site-pages/:id", (c) => {
|
||||||
return send({
|
return send({
|
||||||
page: {
|
page: {
|
||||||
id,
|
id,
|
||||||
|
title: found.title,
|
||||||
|
description: found.description,
|
||||||
sections: rows.map(({ id: sectionId, ...section }) => ({
|
sections: rows.map(({ id: sectionId, ...section }) => ({
|
||||||
...section,
|
...section,
|
||||||
blocks: blocks.get(String(sectionId)) ?? [],
|
blocks: blocks.get(String(sectionId)) ?? [],
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,21 @@
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
SITE NAVIGATION
|
SITE NAVIGATION AND PAGES
|
||||||
|
|
||||||
Pages → Navigation (075_site_nav.sql): the header's and footer's
|
The site's pages (site_pages, 080_page_registry.sql: Pages →
|
||||||
links, and which static pages are hidden. Read by pageMeta.js
|
Page management) and the header's and footer's links (Pages →
|
||||||
(window.__SITE__, the page's status, the sitemap) and served as
|
Navigation, 075). Read by pageMeta.js (window.__SITE__, each
|
||||||
GET /api/nav for the app (routes/sitePages.js).
|
page's status and title, the sitemap) and served as GET /api/nav
|
||||||
|
for the app (routes/sitePages.js).
|
||||||
|
|
||||||
A hidden page answers Not found to anyone below viewer, and its
|
hidden Not found to anyone below viewer, and left out of
|
||||||
links are left out of what they're sent; a viewer and up sees
|
what they're sent, links included; a viewer and up
|
||||||
both, and the page says it's hidden (Layout.tsx). Who's asking
|
sees it, and the page says it's hidden (Layout.tsx)
|
||||||
is the session cookie, so the same page can be hidden from one
|
disabled out of the menus, the sitemap and search, for
|
||||||
visitor and shown to the next: the HTML is no-cache already.
|
everyone; its address still works
|
||||||
|
|
||||||
|
Who's asking is the session cookie, so the same page can be
|
||||||
|
hidden from one visitor and shown to the next: the HTML is
|
||||||
|
no-cache already.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { hasRole } from "./auth.js";
|
import { hasRole } from "./auth.js";
|
||||||
|
|
@ -20,38 +25,63 @@ export const SEES_HIDDEN = "viewer";
|
||||||
|
|
||||||
export const seesHidden = (user) => hasRole(user, SEES_HIDDEN);
|
export const seesHidden = (user) => hasRole(user, SEES_HIDDEN);
|
||||||
|
|
||||||
|
/* A link's page: its path without the #section or ?query, or null
|
||||||
|
for an address off the site. */
|
||||||
|
export const pageOf = (href) =>
|
||||||
|
/^\//.test(href) ? href.split(/[?#]/)[0].replace(/(.)\/+$/, "$1") || "/" : null;
|
||||||
|
|
||||||
|
/* Every page, in the admin's order. */
|
||||||
|
export function allPages(db) {
|
||||||
|
return db
|
||||||
|
.prepare(
|
||||||
|
`SELECT id, path, title, description, is_hidden, is_disabled
|
||||||
|
FROM site_pages ORDER BY sort_order, title`,
|
||||||
|
)
|
||||||
|
.all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The page at this path, or null. */
|
||||||
|
export function pageAt(db, path) {
|
||||||
|
return (
|
||||||
|
db
|
||||||
|
.prepare(`SELECT id, path, title, description, is_hidden, is_disabled FROM site_pages WHERE path = ?`)
|
||||||
|
.get(pageOf(path) ?? path) ?? null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/* The paths whose pages are hidden, eg. '/shop'. */
|
/* The paths whose pages are hidden, eg. '/shop'. */
|
||||||
export function hiddenPaths(db) {
|
export function hiddenPaths(db) {
|
||||||
return new Set(
|
return new Set(
|
||||||
db
|
db
|
||||||
.prepare(`SELECT path FROM site_nav_pages WHERE nav_id = 'site' AND is_hidden = 1`)
|
.prepare(`SELECT path FROM site_pages WHERE is_hidden = 1`)
|
||||||
.all()
|
.all()
|
||||||
.map((row) => row.path),
|
.map((row) => row.path),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A link's page: its path without the #section or ?query, or null
|
|
||||||
for an address off the site. */
|
|
||||||
const pageOf = (href) => (/^\//.test(href) ? href.split(/[?#]/)[0].replace(/(.)\/+$/, "$1") : null);
|
|
||||||
|
|
||||||
/* Whether this path's page is one the user can't see. */
|
/* Whether this path's page is one the user can't see. */
|
||||||
export function hiddenFrom(db, user, pathname) {
|
export function hiddenFrom(db, user, pathname) {
|
||||||
return !seesHidden(user) && hiddenPaths(db).has(pageOf(pathname));
|
return !seesHidden(user) && hiddenPaths(db).has(pageOf(pathname));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* What the app draws its menus from: every link this user may
|
/* What the app draws its menus and pages from: every page this user
|
||||||
follow, and the hidden pages' paths (so the app can answer Not
|
may open, every link they may follow (none to a disabled page),
|
||||||
found, or say a page is hidden, without asking again). */
|
and which pages are hidden (so the app can say so). */
|
||||||
export function navFor(db, user) {
|
export function navFor(db, user) {
|
||||||
const hidden = hiddenPaths(db);
|
|
||||||
const sees = seesHidden(user);
|
const sees = seesHidden(user);
|
||||||
|
const pages = allPages(db).filter((page) => sees || page.is_hidden !== 1);
|
||||||
|
const hidden = new Set(allPages(db).filter((p) => p.is_hidden === 1).map((p) => p.path));
|
||||||
|
const disabled = new Set(pages.filter((p) => p.is_disabled === 1).map((p) => p.path));
|
||||||
const links = db
|
const links = db
|
||||||
.prepare(
|
.prepare(
|
||||||
`SELECT place, label, path, parent_path, style, new_tab
|
`SELECT place, label, path, parent_path, style, new_tab
|
||||||
FROM site_nav_links WHERE nav_id = 'site' ORDER BY sort_order, id`,
|
FROM site_nav_links WHERE nav_id = 'site' ORDER BY sort_order, id`,
|
||||||
)
|
)
|
||||||
.all()
|
.all()
|
||||||
.filter((link) => sees || !hidden.has(pageOf(link.path)))
|
.filter((link) => {
|
||||||
|
const page = pageOf(link.path);
|
||||||
|
return !disabled.has(page) && (sees || !hidden.has(page));
|
||||||
|
})
|
||||||
.map((link) => ({
|
.map((link) => ({
|
||||||
place: link.place,
|
place: link.place,
|
||||||
label: link.label,
|
label: link.label,
|
||||||
|
|
@ -61,5 +91,17 @@ export function navFor(db, user) {
|
||||||
newTab: link.new_tab === 1,
|
newTab: link.new_tab === 1,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return { links, hidden: [...hidden], seesHidden: sees };
|
return {
|
||||||
|
links,
|
||||||
|
pages: pages.map((page) => ({
|
||||||
|
id: page.id,
|
||||||
|
path: page.path,
|
||||||
|
title: page.title,
|
||||||
|
description: page.description,
|
||||||
|
hidden: page.is_hidden === 1,
|
||||||
|
disabled: page.is_disabled === 1,
|
||||||
|
})),
|
||||||
|
hidden: sees ? [...hidden] : [],
|
||||||
|
seesHidden: sees,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
50
site.json
50
site.json
|
|
@ -12,55 +12,5 @@
|
||||||
"accessibility": {
|
"accessibility": {
|
||||||
"addBypassLinks": false,
|
"addBypassLinks": false,
|
||||||
"ignoreReducedMotion": false
|
"ignoreReducedMotion": false
|
||||||
},
|
|
||||||
"pages": {
|
|
||||||
"/retreats": {
|
|
||||||
"title": "Retreats",
|
|
||||||
"description": "Retreats hosted by Next Generation of Unity, our regions, and our partners throughout the year."
|
|
||||||
},
|
|
||||||
"/community": {
|
|
||||||
"title": "Community",
|
|
||||||
"description": "Groups, regions and the people who make up Next Generation of Unity."
|
|
||||||
},
|
|
||||||
"/organization": {
|
|
||||||
"title": "Organization",
|
|
||||||
"description": "Our mission, vision and values, the people who lead Next Generation of Unity, and how to reach us."
|
|
||||||
},
|
|
||||||
"/resources": {
|
|
||||||
"title": "Resources",
|
|
||||||
"description": "Teachings, brand assets, and material for groups and partners."
|
|
||||||
},
|
|
||||||
"/history": {
|
|
||||||
"title": "History",
|
|
||||||
"description": "A near-complete timeline of Next Generation of Unity (NGU), and other Unity Young Adult programs."
|
|
||||||
},
|
|
||||||
"/feedback": {
|
|
||||||
"title": "Feedback",
|
|
||||||
"description": "Tell us what's working, what isn't, and what you'd like to see next."
|
|
||||||
},
|
|
||||||
"/request": {
|
|
||||||
"title": "Request",
|
|
||||||
"description": "Ask for a blog post, an event, or a new or updated group, region, partner, team, award or person on the site."
|
|
||||||
},
|
|
||||||
"/qr": {
|
|
||||||
"title": "QR Codes",
|
|
||||||
"description": "Codes for flyers, slides and signs, pointing at any page on the site or any link, in your choice of colors."
|
|
||||||
},
|
|
||||||
"/give": {
|
|
||||||
"title": "Giving",
|
|
||||||
"description": "Support the work of Next Generation of Unity."
|
|
||||||
},
|
|
||||||
"/privacy": {
|
|
||||||
"title": "Privacy Policy",
|
|
||||||
"description": "How Next Generation of Unity collects, uses, and protects your information."
|
|
||||||
},
|
|
||||||
"/shop": {
|
|
||||||
"title": "Shop",
|
|
||||||
"description": "Shirts, stickers and more from Next Generation of Unity. Every purchase supports our retreats and programs."
|
|
||||||
},
|
|
||||||
"/terms": {
|
|
||||||
"title": "Terms of Service",
|
|
||||||
"description": "The terms that apply when you use this site and our programs."
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
28
src/App.tsx
28
src/App.tsx
|
|
@ -49,16 +49,9 @@ const lazyPage = (load) =>
|
||||||
throw err
|
throw err
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
// Community, Retreats, Resources, Organization, History and Shop:
|
// Every page at its address (Pages → Page management): its sections,
|
||||||
// each built in the admin from sections.
|
// or one of the few the site draws in code (fixedPages.ts).
|
||||||
const SitePage = lazyPage(() => import("./pages/SitePage.tsx"))
|
const PageAtPath = lazyPage(() => import("./pages/PageAtPath.tsx"))
|
||||||
const Feedback = lazyPage(() => import("./pages/Feedback.tsx"))
|
|
||||||
const Request = lazyPage(() => import("./pages/Request.tsx"))
|
|
||||||
const Giving = lazyPage(() => import("./pages/Giving.tsx"))
|
|
||||||
const QrCodes = lazyPage(() => import("./pages/QrCodes.tsx"))
|
|
||||||
const Privacy = lazyPage(() => import("./pages/Privacy.tsx"))
|
|
||||||
const Terms = lazyPage(() => import("./pages/Terms.tsx"))
|
|
||||||
const NotFound = lazyPage(() => import("./pages/NotFound.tsx"))
|
|
||||||
// Profile accounts (076): signing in, an invite's welcome, the profile.
|
// Profile accounts (076): signing in, an invite's welcome, the profile.
|
||||||
const SignIn = lazyPage(() => import("./pages/SignIn.tsx"))
|
const SignIn = lazyPage(() => import("./pages/SignIn.tsx"))
|
||||||
const AccountWelcome = lazyPage(() => import("./pages/AccountWelcome.tsx"))
|
const AccountWelcome = lazyPage(() => import("./pages/AccountWelcome.tsx"))
|
||||||
|
|
@ -100,9 +93,7 @@ export default function App() {
|
||||||
{/* Layout renders the nav once and swaps page content into <Outlet /> */}
|
{/* Layout renders the nav once and swaps page content into <Outlet /> */}
|
||||||
<Route element={<Layout />}>
|
<Route element={<Layout />}>
|
||||||
<Route index element={<Home />} />
|
<Route index element={<Home />} />
|
||||||
<Route path="retreats" element={<SitePage key="retreats" id="retreats" />} />
|
|
||||||
<Route path="/events/:id" element={<EventDetail />} />
|
<Route path="/events/:id" element={<EventDetail />} />
|
||||||
<Route path="community" element={<SitePage key="community" id="community" />} />
|
|
||||||
<Route path="/regions/:id" element={<OrganizationDetail />} />
|
<Route path="/regions/:id" element={<OrganizationDetail />} />
|
||||||
<Route path="/groups/:id" element={<OrganizationDetail />} />
|
<Route path="/groups/:id" element={<OrganizationDetail />} />
|
||||||
<Route path="/partners/:id" element={<OrganizationDetail />} />
|
<Route path="/partners/:id" element={<OrganizationDetail />} />
|
||||||
|
|
@ -112,20 +103,11 @@ export default function App() {
|
||||||
<Route path="/people/:id" element={<PersonDetail />} />
|
<Route path="/people/:id" element={<PersonDetail />} />
|
||||||
<Route path="/blog/:id" element={<BlogPost />} />
|
<Route path="/blog/:id" element={<BlogPost />} />
|
||||||
<Route path="/directory/:id" element={<DirectoryPage />} />
|
<Route path="/directory/:id" element={<DirectoryPage />} />
|
||||||
<Route path="organization" element={<SitePage key="organization" id="organization" />} />
|
|
||||||
<Route path="resources" element={<SitePage key="resources" id="resources" />} />
|
|
||||||
<Route path="history" element={<SitePage key="history" id="history" />} />
|
|
||||||
<Route path="shop" element={<SitePage key="shop" id="shop" />} />
|
|
||||||
<Route path="feedback" element={<Feedback />} />
|
|
||||||
<Route path="request" element={<Request />} />
|
|
||||||
<Route path="qr" element={<QrCodes />} />
|
|
||||||
<Route path="give" element={<Giving />} />
|
|
||||||
<Route path="privacy" element={<Privacy />} />
|
|
||||||
<Route path="terms" element={<Terms />} />
|
|
||||||
<Route path="sign-in" element={<SignIn />} />
|
<Route path="sign-in" element={<SignIn />} />
|
||||||
<Route path="account" element={<Account />} />
|
<Route path="account" element={<Account />} />
|
||||||
<Route path="account/welcome" element={<AccountWelcome />} />
|
<Route path="account/welcome" element={<AccountWelcome />} />
|
||||||
<Route path="*" element={<NotFound />} />
|
{/* Every page of the site: Pages → Page management (PageAtPath). */}
|
||||||
|
<Route path="*" element={<PageAtPath />} />
|
||||||
</Route>
|
</Route>
|
||||||
{/* A schedule as a slideshow for a screen: full screen, no Layout. */}
|
{/* A schedule as a slideshow for a screen: full screen, no Layout. */}
|
||||||
<Route
|
<Route
|
||||||
|
|
|
||||||
|
|
@ -33,14 +33,7 @@ import { personTagTypes } from "./adminSchema/personTags.ts";
|
||||||
import { tags } from "./adminSchema/tags.ts";
|
import { tags } from "./adminSchema/tags.ts";
|
||||||
import { contactTypes } from "./adminSchema/contactTypes.ts";
|
import { contactTypes } from "./adminSchema/contactTypes.ts";
|
||||||
import { redirects } from "./adminSchema/redirects.ts";
|
import { redirects } from "./adminSchema/redirects.ts";
|
||||||
import {
|
import { pages } from "./adminSchema/sitePages.ts";
|
||||||
communityPage,
|
|
||||||
retreatsPage,
|
|
||||||
resourcesPage,
|
|
||||||
organizationPage,
|
|
||||||
historyPage,
|
|
||||||
shopPage,
|
|
||||||
} from "./adminSchema/sitePages.ts";
|
|
||||||
|
|
||||||
export const ADMIN_ENTITIES: Record<string, any> = {
|
export const ADMIN_ENTITIES: Record<string, any> = {
|
||||||
organizations,
|
organizations,
|
||||||
|
|
@ -55,12 +48,7 @@ export const ADMIN_ENTITIES: Record<string, any> = {
|
||||||
timeline,
|
timeline,
|
||||||
front_page: frontPage,
|
front_page: frontPage,
|
||||||
blog_posts: blogPosts,
|
blog_posts: blogPosts,
|
||||||
community_page: communityPage,
|
pages,
|
||||||
retreats_page: retreatsPage,
|
|
||||||
resources_page: resourcesPage,
|
|
||||||
organization_page: organizationPage,
|
|
||||||
history_page: historyPage,
|
|
||||||
shop_page: shopPage,
|
|
||||||
navigation: siteNav,
|
navigation: siteNav,
|
||||||
site_settings: siteSettings,
|
site_settings: siteSettings,
|
||||||
};
|
};
|
||||||
|
|
@ -79,12 +67,7 @@ export const PREVIEW_PATHS: Record<string, (row: any) => string | null> = {
|
||||||
timeline: () => "/history",
|
timeline: () => "/history",
|
||||||
front_page: () => "/",
|
front_page: () => "/",
|
||||||
blog_posts: (row) => blogHref(row.id),
|
blog_posts: (row) => blogHref(row.id),
|
||||||
community_page: () => "/community",
|
pages: (row) => row.path || null,
|
||||||
retreats_page: () => "/retreats",
|
|
||||||
resources_page: () => "/resources",
|
|
||||||
organization_page: () => "/organization",
|
|
||||||
history_page: () => "/history",
|
|
||||||
shop_page: () => "/shop",
|
|
||||||
// The menus are on every page.
|
// The menus are on every page.
|
||||||
navigation: () => "/",
|
navigation: () => "/",
|
||||||
site_settings: () => "/",
|
site_settings: () => "/",
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,10 @@
|
||||||
import siteConfiguration from "../../../site.json";
|
|
||||||
|
|
||||||
/* ── Navigation (075_site_nav.sql) ───────────────────────────────
|
/* ── Navigation (075_site_nav.sql) ───────────────────────────────
|
||||||
Pages → Navigation: the header's and footer's links, and each
|
Pages → Navigation: the header's and footer's links. The pages
|
||||||
static page's title, intro and whether it's hidden. Admins and up
|
themselves (titles, intros, Hidden, Disabled) are Page
|
||||||
save it, since hiding takes a page off the site. Server side:
|
management's (sitePages.ts). Admins and up. Server side:
|
||||||
server/src/admin-schema/siteNav.js; the site reads it through
|
server/src/admin-schema/siteNav.js; the site reads it through
|
||||||
server/src/siteNav.js and src/lib/useSiteNav.ts. */
|
server/src/siteNav.js and src/lib/useSiteNav.ts. */
|
||||||
|
|
||||||
const SITE_PAGES: [string, string][] = Object.entries(siteConfiguration.pages).map(
|
|
||||||
([path, page]) => [path, `${page.title} (${path})`],
|
|
||||||
);
|
|
||||||
|
|
||||||
const PLACES: [string, string][] = [
|
const PLACES: [string, string][] = [
|
||||||
["main", "Header: pages"],
|
["main", "Header: pages"],
|
||||||
["action", "Header: buttons"],
|
["action", "Header: buttons"],
|
||||||
|
|
@ -36,7 +30,7 @@ export const siteNav = {
|
||||||
{
|
{
|
||||||
key: "links",
|
key: "links",
|
||||||
label: "Links",
|
label: "Links",
|
||||||
note: "Top to bottom, in the order each place shows them. A link to a hidden page is only shown to signed-in admin accounts. A header page lists its sections under it by itself (Pages → the page).",
|
note: "Top to bottom, in the order each place shows them. A link to a hidden page is only shown to signed-in admin accounts, and one to a disabled page to no one. A header page lists its sections under it by itself (Pages → the page).",
|
||||||
addLabel: "Add link",
|
addLabel: "Add link",
|
||||||
title: (row) => (row.label ? `${row.label} · ${placeLabel(row.place) ?? "No place"}` : "New link"),
|
title: (row) => (row.label ? `${row.label} · ${placeLabel(row.place) ?? "No place"}` : "New link"),
|
||||||
blank: { place: "", label: "", path: "", parent_path: "", style: "", new_tab: 0 },
|
blank: { place: "", label: "", path: "", parent_path: "", style: "", new_tab: 0 },
|
||||||
|
|
@ -54,7 +48,7 @@ export const siteNav = {
|
||||||
path: "parent_path",
|
path: "parent_path",
|
||||||
label: "Under page",
|
label: "Under page",
|
||||||
widget: "select",
|
widget: "select",
|
||||||
options: [["/", "Home (/)"], ...SITE_PAGES],
|
optionsFrom: "site_pages",
|
||||||
blankLabel: "Default: its own place in the header",
|
blankLabel: "Default: its own place in the header",
|
||||||
help: "Lists it in that page's menu, after its sections, instead of in the header's row",
|
help: "Lists it in that page's menu, after its sections, instead of in the header's row",
|
||||||
when: { path: "place", value: "main" },
|
when: { path: "place", value: "main" },
|
||||||
|
|
@ -70,35 +64,5 @@ export const siteNav = {
|
||||||
{ path: "new_tab", label: "Opens in a new tab", widget: "checkbox" },
|
{ path: "new_tab", label: "Opens in a new tab", widget: "checkbox" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: "pages",
|
|
||||||
label: "Pages",
|
|
||||||
note: "A page's heading and intro (also its search title and description), and whether it's hidden. A hidden page is out of the menus and the sitemap and says Not found to everyone but signed-in admin accounts, who see it with a bar saying it's hidden. Blank fields keep site.json's. A page not listed here shows as site.json has it.",
|
|
||||||
addLabel: "Add page",
|
|
||||||
title: (row) =>
|
|
||||||
`${SITE_PAGES.find(([path]) => path === row.path)?.[1] ?? "New page"}${row.is_hidden ? " · Hidden" : ""}`,
|
|
||||||
blank: { path: "", title: "", description: "", is_hidden: 0 },
|
|
||||||
fields: [
|
|
||||||
{ path: "path", label: "Page", widget: "select", options: SITE_PAGES, required: true },
|
|
||||||
{
|
|
||||||
path: "is_hidden",
|
|
||||||
label: "Hidden",
|
|
||||||
widget: "checkbox",
|
|
||||||
help: "Not found to everyone but signed-in admin accounts, eg. a page that isn't done",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "title",
|
|
||||||
label: "Title",
|
|
||||||
help: (row) => (row?.path ? `Default: ${siteConfiguration.pages[row.path]?.title ?? ""}` : undefined),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "description",
|
|
||||||
label: "Intro",
|
|
||||||
widget: "textarea",
|
|
||||||
full: true,
|
|
||||||
help: (row) => (row?.path ? `Default: ${siteConfiguration.pages[row.path]?.description ?? ""}` : undefined),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* ── The site's own pages (056_site_pages.sql) ───────────────────
|
/* ── The site's pages (056_site_pages.sql, 080_page_registry.sql) ──
|
||||||
Pages → Community, Retreats, Resources, Organization, History,
|
Pages → Page management: every page, its address, title, intro,
|
||||||
Shop (075):
|
Hidden and Disabled, and new pages made here.
|
||||||
each page is its sections, in order, and each section is its
|
each page is its sections, in order, and each section is its
|
||||||
heading and its own content blocks, then a preset if it has one
|
heading and its own content blocks, then a preset if it has one
|
||||||
(a prebuilt part of the site, drawn under the blocks). Server
|
(a prebuilt part of the site, drawn under the blocks). Server
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
src/pages/SitePage.tsx.
|
src/pages/SitePage.tsx.
|
||||||
|
|
||||||
The preset values are the CHECK list on page_sections.preset;
|
The preset values are the CHECK list on page_sections.preset;
|
||||||
each page offers the ones that belong on it. */
|
every page offers them all. The Community blog's settings show on
|
||||||
|
the Community page only (its id), for now. */
|
||||||
|
|
||||||
import { FEATURED_KINDS, featuredCardsChild, blocksChild } from "./shared.ts";
|
import { FEATURED_KINDS, featuredCardsChild, blocksChild } from "./shared.ts";
|
||||||
|
|
||||||
|
|
@ -162,26 +163,77 @@ const sectionsChild = (presets: string[]) => ({
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const sitePage = (id: string, label: string, presets: string[], more: Record<string, any> = {}) => ({
|
const COMMUNITY = { path: "id", value: "community" };
|
||||||
key: `${id}_page`,
|
const ALL_PRESETS = Object.keys(PRESETS);
|
||||||
label,
|
|
||||||
singular: label.toLowerCase(),
|
|
||||||
idLabel: "Page",
|
|
||||||
singleton: id,
|
|
||||||
|
|
||||||
list: { columns: [], filters: [] },
|
/* The pages the site draws in code (src/pages/fixedPages.ts, and the
|
||||||
|
front page): no sections of their own yet. */
|
||||||
|
export const FIXED_PAGE_IDS = ["home", "give", "feedback", "request", "qr", "privacy", "terms"];
|
||||||
|
const isFixed = (row) => FIXED_PAGE_IDS.includes(row?.id);
|
||||||
|
|
||||||
groups: [],
|
const communityGroups = (groups) => groups.map((group) => ({ ...group, when: COMMUNITY }));
|
||||||
...more,
|
const communityChildren = (children) => children.map((child) => ({ ...child, when: COMMUNITY }));
|
||||||
children: [sectionsChild(presets), ...(more.children ?? [])],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const communityPage = sitePage(
|
export const pages = {
|
||||||
"community",
|
key: "pages",
|
||||||
"Community page",
|
label: "Page management",
|
||||||
["community_blog", "group_map", "region_list", "partner_list", "people_directory"],
|
singular: "page",
|
||||||
{
|
idLabel: "URL ID",
|
||||||
groups: [
|
slugFrom: "title",
|
||||||
|
// Every page's address, title, intro and switches, then its own
|
||||||
|
// sections. The fixed pages (and the front page, edited in Front
|
||||||
|
// page) have no sections here.
|
||||||
|
list: {
|
||||||
|
columns: [
|
||||||
|
{ key: "title", label: "Page", primary: true },
|
||||||
|
{ key: "path", label: "Address" },
|
||||||
|
{ key: "is_hidden", label: "Hidden", widget: "bool" },
|
||||||
|
{ key: "is_disabled", label: "Disabled", widget: "bool" },
|
||||||
|
],
|
||||||
|
filters: [],
|
||||||
|
},
|
||||||
|
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
legend: "The page",
|
||||||
|
fields: [
|
||||||
|
{ path: "title", label: "Title", required: true, help: "The page's heading, and its title in search and the browser tab, eg. Library" },
|
||||||
|
{
|
||||||
|
path: "path",
|
||||||
|
label: "Address",
|
||||||
|
required: true,
|
||||||
|
help: "Where it lives on the site, eg. /library. Lowercase letters, numbers, hyphens and /. Changing it breaks old links: update Navigation's too.",
|
||||||
|
},
|
||||||
|
{ path: "description", label: "Intro", widget: "textarea", full: true, help: "The line under the title, and its description in search." },
|
||||||
|
{
|
||||||
|
path: "is_hidden",
|
||||||
|
label: "Hidden",
|
||||||
|
widget: "checkbox",
|
||||||
|
help: "Not found to everyone but signed-in admin accounts, eg. a page that isn't done. Out of the menus and the sitemap.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "is_disabled",
|
||||||
|
label: "Disabled",
|
||||||
|
widget: "checkbox",
|
||||||
|
help: "Out of the menus, the sitemap and search; its address still works for anyone with the link.",
|
||||||
|
},
|
||||||
|
{ path: "sort_order", label: "Order", widget: "number", help: "Where its card sits on the admin home, lowest first. Default: 0" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
legend: "Its content",
|
||||||
|
note: "The front page's content is edited in Pages → Front page: its hero, and the bands it shows.",
|
||||||
|
when: { test: (row) => row?.id === "home" },
|
||||||
|
fields: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
legend: "Its content",
|
||||||
|
note: "This page's content is built into the site (a form, an embed or set text), so it has no sections to edit here yet. Its title, intro, address and switches above are yours.",
|
||||||
|
when: { test: (row) => isFixed(row) && row?.id !== "home" },
|
||||||
|
fields: [],
|
||||||
|
},
|
||||||
|
...communityGroups(
|
||||||
|
[
|
||||||
{
|
{
|
||||||
legend: "Community blog: our posts",
|
legend: "Community blog: our posts",
|
||||||
note: "For the Community blog preset. Pinned posts first, then the newest published, listed posts, up to the number of slots.",
|
note: "For the Community blog preset. Pinned posts first, then the newest published, listed posts, up to the number of slots.",
|
||||||
|
|
@ -200,8 +252,14 @@ export const communityPage = sitePage(
|
||||||
{ path: "blog.external_label", label: "Button text", help: "Default: Read more on Substack" },
|
{ path: "blog.external_label", label: "Button text", help: "Default: Read more on Substack" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
]
|
||||||
children: [
|
),
|
||||||
|
],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
{ ...sectionsChild(ALL_PRESETS), when: { test: (row) => !isFixed(row) } },
|
||||||
|
...communityChildren(
|
||||||
|
[
|
||||||
{
|
{
|
||||||
key: "pinned_posts",
|
key: "pinned_posts",
|
||||||
label: "Community blog: pinned posts (ours)",
|
label: "Community blog: pinned posts (ours)",
|
||||||
|
|
@ -244,12 +302,7 @@ export const communityPage = sitePage(
|
||||||
{ path: "label", label: "Source name", help: "Shown on its cards. Default: the feed's own title" },
|
{ path: "label", label: "Source name", help: "Shown on its cards. Default: the feed's own title" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
]
|
||||||
},
|
),
|
||||||
);
|
],
|
||||||
|
};
|
||||||
export const retreatsPage = sitePage("retreats", "Retreats page", ["events"]);
|
|
||||||
export const resourcesPage = sitePage("resources", "Resources page", ["people_directory"]);
|
|
||||||
export const organizationPage = sitePage("organization", "Organization page", ["people_directory"]);
|
|
||||||
export const historyPage = sitePage("history", "History page", ["timeline"]);
|
|
||||||
export const shopPage = sitePage("shop", "Shop page", []);
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ export function useNavSections(): (path: string) => NavSection[] {
|
||||||
return useCallback(
|
return useCallback(
|
||||||
(path: string) => {
|
(path: string) => {
|
||||||
if (path !== '/') {
|
if (path !== '/') {
|
||||||
return (sitePages?.[path.slice(1)] ?? []).map((section) => ({
|
return (sitePages?.[path] ?? []).map((section) => ({
|
||||||
label: section.title,
|
label: section.title,
|
||||||
hash: `#${section.anchor}`,
|
hash: `#${section.anchor}`,
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,9 @@
|
||||||
serves the plain index.html, it isn't there and site.json alone
|
serves the plain index.html, it isn't there and site.json alone
|
||||||
applies.
|
applies.
|
||||||
|
|
||||||
A page's visible heading and intro and its search title and
|
A page's heading and intro are its site_pages row's (Pages → Page
|
||||||
description come from the same values, so they can't drift.
|
management), which also give its search title and description, so
|
||||||
|
they can't drift: useSiteNav and the page's own data carry them.
|
||||||
|
|
||||||
SITE_ORIGIN is the public address of the live site. It's used
|
SITE_ORIGIN is the public address of the live site. It's used
|
||||||
where a URL has to leave the browser and still work: a printed QR
|
where a URL has to leave the browser and still work: a printed QR
|
||||||
|
|
@ -22,9 +23,7 @@
|
||||||
|
|
||||||
import siteConfiguration from '../../site.json'
|
import siteConfiguration from '../../site.json'
|
||||||
|
|
||||||
type PageText = { title: string; description: string }
|
type SiteText = { title?: string; privacyEmail?: string; requestFiles?: boolean }
|
||||||
|
|
||||||
type SiteText = { title?: string; pages?: Record<string, PageText>; privacyEmail?: string; requestFiles?: boolean }
|
|
||||||
|
|
||||||
/* What the server wrote into the page, if it did. */
|
/* What the server wrote into the page, if it did. */
|
||||||
const fromServer: SiteText =
|
const fromServer: SiteText =
|
||||||
|
|
@ -46,18 +45,6 @@ export const REQUEST_FILES: boolean = fromServer.requestFiles ?? true
|
||||||
/** A site path as a full URL on the live site. */
|
/** A site path as a full URL on the live site. */
|
||||||
export const siteUrl = (path: string): string => new URL(path, SITE_ORIGIN).href
|
export const siteUrl = (path: string): string => new URL(path, SITE_ORIGIN).href
|
||||||
|
|
||||||
const PAGES: Record<string, PageText> = { ...siteConfiguration.pages, ...fromServer.pages }
|
|
||||||
|
|
||||||
/* Every static page's path and text, for the not-found page's suggestions. */
|
|
||||||
export const SITE_PAGES: Readonly<Record<string, PageText>> = PAGES
|
|
||||||
|
|
||||||
/** A static page's title and intro, from site.json's "pages". */
|
|
||||||
export function sitePage(path: string): PageText {
|
|
||||||
const page = PAGES[path]
|
|
||||||
if (!page) throw new Error(`site.json has no "pages" entry for ${path}`)
|
|
||||||
return page
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The browser tab's title for a page: "Retreats | Next Generation
|
/** The browser tab's title for a page: "Retreats | Next Generation
|
||||||
* of Unity", or the site name alone for the home page. */
|
* of Unity", or the site name alone for the home page. */
|
||||||
export const documentTitle = (title?: string | null): string =>
|
export const documentTitle = (title?: string | null): string =>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
SITE NAV: the header's and footer's links, and the hidden pages
|
SITE NAV: the site's pages, the header's and footer's links, and
|
||||||
|
the hidden pages
|
||||||
|
|
||||||
Pages → Navigation, for this visitor (server/src/siteNav.js): a
|
Pages → Page management and Pages → Navigation, for this visitor
|
||||||
link to a hidden page is only sent to a viewer and up. The page
|
(server/src/siteNav.js): a hidden page, and links to it, are only
|
||||||
HTML carries it (window.__SITE__.nav), so the menus draw on the
|
sent to a viewer and up; a disabled page's links to no one. The
|
||||||
first paint; GET /api/nav asks again, which is also how the dev
|
page HTML carries it (window.__SITE__.nav), so the menus draw on
|
||||||
server (no page metadata) and a sign-in in another tab get it.
|
the first paint; GET /api/nav asks again, which is also how the
|
||||||
Until either answers, navConfig.ts's defaults.
|
dev server (no page metadata) and a sign-in in another tab get it.
|
||||||
|
Until either answers, navConfig.ts's links, and no pages yet
|
||||||
|
(`ready` false).
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
|
|
@ -14,9 +17,20 @@ import { useMemo } from 'react'
|
||||||
import { NAV_DEFAULTS, type NavLink } from '../navConfig.ts'
|
import { NAV_DEFAULTS, type NavLink } from '../navConfig.ts'
|
||||||
import { useRecord } from './useRecord.ts'
|
import { useRecord } from './useRecord.ts'
|
||||||
|
|
||||||
|
/** A page of the site (site_pages). */
|
||||||
|
export type SitePageInfo = {
|
||||||
|
id: string
|
||||||
|
path: string
|
||||||
|
title: string
|
||||||
|
description: string | null
|
||||||
|
hidden: boolean
|
||||||
|
disabled: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export type SiteNav = {
|
export type SiteNav = {
|
||||||
links: NavLink[]
|
links: NavLink[]
|
||||||
/** Paths of hidden pages, eg. '/shop'. */
|
pages: SitePageInfo[]
|
||||||
|
/** Paths of hidden pages, eg. '/shop' (sent to a viewer and up only). */
|
||||||
hidden: string[]
|
hidden: string[]
|
||||||
/** This visitor sees hidden pages (signed in, viewer and up). */
|
/** This visitor sees hidden pages (signed in, viewer and up). */
|
||||||
seesHidden: boolean
|
seesHidden: boolean
|
||||||
|
|
@ -25,7 +39,7 @@ export type SiteNav = {
|
||||||
const fromPage: SiteNav | undefined =
|
const fromPage: SiteNav | undefined =
|
||||||
typeof window !== 'undefined' ? (window as unknown as { __SITE__?: { nav?: SiteNav } }).__SITE__?.nav : undefined
|
typeof window !== 'undefined' ? (window as unknown as { __SITE__?: { nav?: SiteNav } }).__SITE__?.nav : undefined
|
||||||
|
|
||||||
const DEFAULTS: SiteNav = { links: NAV_DEFAULTS, hidden: [], seesHidden: false }
|
const DEFAULTS: SiteNav = { links: NAV_DEFAULTS, pages: [], hidden: [], seesHidden: false }
|
||||||
|
|
||||||
/** A path's page: no #section or ?query, no trailing slash. */
|
/** A path's page: no #section or ?query, no trailing slash. */
|
||||||
export const pageOf = (path: string): string => path.split(/[?#]/)[0].replace(/(.)\/+$/, '$1') || '/'
|
export const pageOf = (path: string): string => path.split(/[?#]/)[0].replace(/(.)\/+$/, '$1') || '/'
|
||||||
|
|
@ -38,19 +52,24 @@ export function useSiteNav() {
|
||||||
const main = nav.links.filter((l) => l.place === 'main')
|
const main = nav.links.filter((l) => l.place === 'main')
|
||||||
const top = main.filter((l) => !l.parent)
|
const top = main.filter((l) => !l.parent)
|
||||||
const tops = new Set(top.map((l) => pageOf(l.path)))
|
const tops = new Set(top.map((l) => pageOf(l.path)))
|
||||||
|
const byPath = new Map(nav.pages.map((page) => [page.path, page]))
|
||||||
return {
|
return {
|
||||||
...nav,
|
...nav,
|
||||||
|
/** Whether the pages have arrived (else a page can't be told from a missing one). */
|
||||||
|
ready: Boolean(data ?? fromPage),
|
||||||
/** The header's pages, each with the links set under it. */
|
/** The header's pages, each with the links set under it. */
|
||||||
main: top.map((page) => ({
|
main: top.map((page) => ({
|
||||||
...page,
|
...page,
|
||||||
children: main.filter((l) => l.parent && l.parent === pageOf(page.path)),
|
children: main.filter((l) => l.parent && l.parent === pageOf(page.path)),
|
||||||
})),
|
})),
|
||||||
/** Every main link, children included, for lists of the site's pages. */
|
/** Every main link, children included, for lists of the site's pages. */
|
||||||
pages: main.filter((l) => !l.parent || tops.has(l.parent)),
|
pageLinks: main.filter((l) => !l.parent || tops.has(l.parent)),
|
||||||
actions: nav.links.filter((l) => l.place === 'action'),
|
actions: nav.links.filter((l) => l.place === 'action'),
|
||||||
footer: nav.links.filter((l) => l.place === 'footer'),
|
footer: nav.links.filter((l) => l.place === 'footer'),
|
||||||
legal: nav.links.filter((l) => l.place === 'legal'),
|
legal: nav.links.filter((l) => l.place === 'legal'),
|
||||||
isHidden: (path: string) => nav.hidden.includes(pageOf(path)),
|
isHidden: (path: string) => nav.hidden.includes(pageOf(path)),
|
||||||
|
/** The page at this path, or null. */
|
||||||
|
pageAt: (path: string): SitePageInfo | null => byPath.get(pageOf(path)) ?? null,
|
||||||
}
|
}
|
||||||
}, [nav])
|
}, [nav, data])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/* The site's own pages (Community, Retreats, Resources, Organization,
|
/* The site's pages of sections (Pages → Page management): GET
|
||||||
History), built in the admin from sections: GET /site-pages/:id
|
/site-pages/:id for one page's title, intro and sections, GET
|
||||||
for one page's sections, GET /site-pages for every page's section
|
/site-pages for every page's section headings by the page's path
|
||||||
headings (the header's dropdowns, the footer, the side nav). */
|
(the header's dropdowns, the footer, the side nav). */
|
||||||
|
|
||||||
import { useRecord, type Resource } from './useRecord.ts'
|
import { useRecord, type Resource } from './useRecord.ts'
|
||||||
import type { ContentBlock } from './useContent.ts'
|
import type { ContentBlock } from './useContent.ts'
|
||||||
|
|
@ -24,7 +24,7 @@ export type SitePageSection = {
|
||||||
blocks: ContentBlock[]
|
blocks: ContentBlock[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSitePage = (id: string): Resource<{ id: string; sections: SitePageSection[] }> =>
|
export const useSitePage = (id: string): Resource<{ id: string; title: string; description: string | null; sections: SitePageSection[] }> =>
|
||||||
useRecord(`/site-pages/${id}`, 'page')
|
useRecord(`/site-pages/${id}`, 'page')
|
||||||
|
|
||||||
export const useSitePageHeadings = (): Resource<Record<string, Array<{ anchor: string; title: string }>>> =>
|
export const useSitePageHeadings = (): Resource<Record<string, Array<{ anchor: string; title: string }>>> =>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import PageShell from "../components/PageShell.tsx";
|
import PageShell from "../components/PageShell.tsx";
|
||||||
import { sitePage } from "../lib/site.ts";
|
import type { PageText } from "./fixedPages.ts";
|
||||||
import FeedbackForm from "./sections/FeedbackForm.tsx";
|
import FeedbackForm from "./sections/FeedbackForm.tsx";
|
||||||
import { BRAND } from "../lib/color.ts"
|
import { BRAND } from "../lib/color.ts"
|
||||||
|
|
||||||
/* Title and intro: site.json, which also gives the search metadata. */
|
|
||||||
const PAGE = sitePage("/feedback");
|
|
||||||
|
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
Feedback page.
|
Feedback page.
|
||||||
|
|
@ -36,11 +34,12 @@ const SECTIONS = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function Feedback() {
|
/* Its title and intro: its site_pages row (Pages → Page management). */
|
||||||
|
export default function Feedback({ page: PAGE }: { page: PageText }) {
|
||||||
return (
|
return (
|
||||||
<PageShell
|
<PageShell
|
||||||
title={PAGE.title}
|
title={PAGE.title}
|
||||||
intro={PAGE.description}
|
intro={PAGE.description ?? undefined}
|
||||||
sections={SECTIONS}
|
sections={SECTIONS}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import PageShell from "../components/PageShell.tsx";
|
import PageShell from "../components/PageShell.tsx";
|
||||||
import { sitePage } from "../lib/site.ts";
|
import type { PageText } from "./fixedPages.ts";
|
||||||
import { BRAND } from "../lib/color.ts"
|
import { BRAND } from "../lib/color.ts"
|
||||||
|
|
||||||
/* Title and intro: site.json, which also gives the search metadata. */
|
|
||||||
const PAGE = sitePage("/give");
|
|
||||||
|
|
||||||
const GIVING_URL =
|
const GIVING_URL =
|
||||||
"https://ngu.churchcenteronline.com/giving?open-in-church-center-modal=true";
|
"https://ngu.churchcenteronline.com/giving?open-in-church-center-modal=true";
|
||||||
|
|
@ -72,7 +70,8 @@ function GivingPanel() {
|
||||||
PAGE
|
PAGE
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
export default function GivingPage() {
|
/* Its title and intro: its site_pages row (Pages → Page management). */
|
||||||
|
export default function GivingPage({ page: PAGE }: { page: PageText }) {
|
||||||
useChurchCenterModal();
|
useChurchCenterModal();
|
||||||
|
|
||||||
const sections = [
|
const sections = [
|
||||||
|
|
@ -89,7 +88,7 @@ export default function GivingPage() {
|
||||||
return (
|
return (
|
||||||
<PageShell
|
<PageShell
|
||||||
title={PAGE.title}
|
title={PAGE.title}
|
||||||
intro={PAGE.description}
|
intro={PAGE.description ?? undefined}
|
||||||
sections={sections}
|
sections={sections}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
NOT FOUND: any address no route matches
|
NOT FOUND: any address no route matches
|
||||||
|
|
||||||
Rather than a dead end, the closest pages to the address that
|
Rather than a dead end, the closest pages to the address that
|
||||||
failed: the static pages (site.json's) and every public, listed
|
failed: the site's pages (Page management's) and every public, listed
|
||||||
record (GET /directory), scored by suggest.ts against the
|
record (GET /directory), scored by suggest.ts against the
|
||||||
address. So /organisation offers Organization, /retreat offers
|
address. So /organisation offers Organization, /retreat offers
|
||||||
Retreats, and an old /chapters/lynnwood offers the Lynnwood group.
|
Retreats, and an old /chapters/lynnwood offers the Lynnwood group.
|
||||||
|
|
@ -18,8 +18,7 @@ import { useMemo } from 'react'
|
||||||
import { Link, useLocation } from 'react-router-dom'
|
import { Link, useLocation } from 'react-router-dom'
|
||||||
|
|
||||||
import PageShell from '../components/PageShell.tsx'
|
import PageShell from '../components/PageShell.tsx'
|
||||||
import { useSiteNav } from '../lib/useSiteNav.ts'
|
import { useSiteNav, type SitePageInfo } from '../lib/useSiteNav.ts'
|
||||||
import { SITE_PAGES } from '../lib/site.ts'
|
|
||||||
import { useDirectory, type Directory } from '../lib/useContent.ts'
|
import { useDirectory, type Directory } from '../lib/useContent.ts'
|
||||||
import { blogHref, eventHref, orgHref, personHref, teamHref, awardHref } from '../lib/hrefs.ts'
|
import { blogHref, eventHref, orgHref, personHref, teamHref, awardHref } from '../lib/hrefs.ts'
|
||||||
import { suggest, type Candidate } from '../lib/suggest.ts'
|
import { suggest, type Candidate } from '../lib/suggest.ts'
|
||||||
|
|
@ -36,12 +35,12 @@ const ORG_KIND_LABEL: Record<string, string> = {
|
||||||
/* Everything an address could have meant: the static pages (not the
|
/* Everything an address could have meant: the static pages (not the
|
||||||
hidden ones), then each kind of record, with the words to match
|
hidden ones), then each kind of record, with the words to match
|
||||||
it by. */
|
it by. */
|
||||||
function candidates(directory: Directory | null, isHidden: (path: string) => boolean): Candidate[] {
|
function candidates(directory: Directory | null, sitePages: SitePageInfo[]): Candidate[] {
|
||||||
const pages: Candidate[] = Object.entries(SITE_PAGES).filter(([path]) => !isHidden(path)).map(([path, page]) => ({
|
const pages: Candidate[] = sitePages.filter((page) => !page.hidden && page.path !== '/').map((page) => ({
|
||||||
href: path,
|
href: page.path,
|
||||||
label: page.title,
|
label: page.title,
|
||||||
detail: 'Page',
|
detail: 'Page',
|
||||||
keys: [path.slice(1), page.title],
|
keys: [page.path.slice(1), page.title],
|
||||||
}))
|
}))
|
||||||
if (!directory) return pages
|
if (!directory) return pages
|
||||||
|
|
||||||
|
|
@ -66,10 +65,10 @@ function candidates(directory: Directory | null, isHidden: (path: string) => boo
|
||||||
export default function NotFound() {
|
export default function NotFound() {
|
||||||
const { pathname } = useLocation()
|
const { pathname } = useLocation()
|
||||||
const { data: directory, loading } = useDirectory()
|
const { data: directory, loading } = useDirectory()
|
||||||
const { main: pages, isHidden } = useSiteNav()
|
const { main: pages, pages: sitePages } = useSiteNav()
|
||||||
const matches = useMemo(
|
const matches = useMemo(
|
||||||
() => suggest(pathname, candidates(directory ?? null, isHidden)),
|
() => suggest(pathname, candidates(directory ?? null, sitePages)),
|
||||||
[pathname, directory, isHidden],
|
[pathname, directory, sitePages],
|
||||||
)
|
)
|
||||||
const reading = useReadingMode()
|
const reading = useReadingMode()
|
||||||
|
|
||||||
|
|
|
||||||
31
src/pages/PageAtPath.tsx
Normal file
31
src/pages/PageAtPath.tsx
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
PAGE AT PATH: any address the record routes don't take
|
||||||
|
|
||||||
|
Pages → Page management decides what's where: the site_pages row
|
||||||
|
at this path (useSiteNav) is drawn by its code when it's one of
|
||||||
|
the fixed pages (fixedPages.ts), or as its sections (SitePage).
|
||||||
|
No page there (or a hidden one, below viewer, which isn't sent):
|
||||||
|
Not found.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { useLocation } from 'react-router-dom'
|
||||||
|
|
||||||
|
import { useSiteNav } from '../lib/useSiteNav.ts'
|
||||||
|
import { FIXED_PAGES } from './fixedPages.ts'
|
||||||
|
import NotFound from './NotFound.tsx'
|
||||||
|
import SitePage from './SitePage.tsx'
|
||||||
|
|
||||||
|
export default function PageAtPath() {
|
||||||
|
const { pathname } = useLocation()
|
||||||
|
const { ready, pageAt } = useSiteNav()
|
||||||
|
// Before the pages arrive (the dev server's first moment), nothing
|
||||||
|
// rather than a Not found that turns into the page.
|
||||||
|
if (!ready) return null
|
||||||
|
|
||||||
|
const page = pageAt(pathname)
|
||||||
|
if (!page || page.path === '/') return <NotFound />
|
||||||
|
|
||||||
|
const Fixed = FIXED_PAGES[page.id]
|
||||||
|
if (Fixed) return <Fixed key={page.id} page={page} />
|
||||||
|
return <SitePage key={page.id} id={page.id} />
|
||||||
|
}
|
||||||
|
|
@ -3,12 +3,11 @@ import { Link } from "react-router-dom";
|
||||||
import LegalText, { type LegalPart } from "../components/LegalText.tsx";
|
import LegalText, { type LegalPart } from "../components/LegalText.tsx";
|
||||||
import PageShell from "../components/PageShell.tsx";
|
import PageShell from "../components/PageShell.tsx";
|
||||||
import { DATA_REQUEST } from "../data/feedbackTypes.ts";
|
import { DATA_REQUEST } from "../data/feedbackTypes.ts";
|
||||||
import { PRIVACY_EMAIL, sitePage } from "../lib/site.ts";
|
import { PRIVACY_EMAIL } from "../lib/site.ts";
|
||||||
|
import type { PageText } from "./fixedPages.ts";
|
||||||
import FeedbackForm from "./sections/FeedbackForm.tsx";
|
import FeedbackForm from "./sections/FeedbackForm.tsx";
|
||||||
import { BRAND } from "../lib/color.ts"
|
import { BRAND } from "../lib/color.ts"
|
||||||
|
|
||||||
/* Title and intro: site.json, which also gives the search metadata. */
|
|
||||||
const PAGE = sitePage("/privacy");
|
|
||||||
|
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
Privacy policy, cookie notice included.
|
Privacy policy, cookie notice included.
|
||||||
|
|
@ -210,6 +209,7 @@ const SECTIONS = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function PrivacyPage() {
|
/* Its title and intro: its site_pages row (Pages → Page management). */
|
||||||
return <PageShell title={PAGE.title} intro={PAGE.description} sections={SECTIONS} />;
|
export default function PrivacyPage({ page: PAGE }: { page: PageText }) {
|
||||||
|
return <PageShell title={PAGE.title} intro={PAGE.description ?? undefined} sections={SECTIONS} />;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import PageShell from '../components/PageShell.tsx'
|
import PageShell from '../components/PageShell.tsx'
|
||||||
import { sitePage } from '../lib/site.ts'
|
import type { PageText } from './fixedPages.ts'
|
||||||
import QrCodeMaker from './sections/QrCodeMaker.tsx'
|
import QrCodeMaker from './sections/QrCodeMaker.tsx'
|
||||||
import { BRAND } from '../lib/color.ts'
|
import { BRAND } from '../lib/color.ts'
|
||||||
|
|
||||||
/* Title and intro: site.json, which also gives the search metadata. */
|
|
||||||
const PAGE = sitePage('/qr')
|
|
||||||
|
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
QR CODES PAGE: /qr
|
QR CODES PAGE: /qr
|
||||||
|
|
@ -30,11 +28,12 @@ const SECTIONS = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
export default function QrCodes() {
|
/* Its title and intro: its site_pages row (Pages → Page management). */
|
||||||
|
export default function QrCodes({ page: PAGE }: { page: PageText }) {
|
||||||
return (
|
return (
|
||||||
<PageShell
|
<PageShell
|
||||||
title={PAGE.title}
|
title={PAGE.title}
|
||||||
intro={PAGE.description}
|
intro={PAGE.description ?? undefined}
|
||||||
sections={SECTIONS}
|
sections={SECTIONS}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import PageShell from "../components/PageShell.tsx";
|
import PageShell from "../components/PageShell.tsx";
|
||||||
import { sitePage } from "../lib/site.ts";
|
import type { PageText } from "./fixedPages.ts";
|
||||||
import RequestForm from "./sections/RequestForm.tsx";
|
import RequestForm from "./sections/RequestForm.tsx";
|
||||||
import { BRAND } from "../lib/color.ts";
|
import { BRAND } from "../lib/color.ts";
|
||||||
|
|
||||||
/* Title and intro: site.json, which also gives the search metadata. */
|
|
||||||
const PAGE = sitePage("/request");
|
|
||||||
|
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
Request page: ask for something to be added to the site or
|
Request page: ask for something to be added to the site or
|
||||||
|
|
@ -27,6 +25,7 @@ const SECTIONS = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function Request() {
|
/* Its title and intro: its site_pages row (Pages → Page management). */
|
||||||
return <PageShell title={PAGE.title} intro={PAGE.description} sections={SECTIONS} />;
|
export default function Request({ page: PAGE }: { page: PageText }) {
|
||||||
|
return <PageShell title={PAGE.title} intro={PAGE.description ?? undefined} sections={SECTIONS} />;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
the site, from PRESETS below. A section with neither says it's
|
the site, from PRESETS below. A section with neither says it's
|
||||||
coming (ComingSoon) rather than showing a heading over nothing.
|
coming (ComingSoon) rather than showing a heading over nothing.
|
||||||
|
|
||||||
The title and intro are site.json's, which also gives the search
|
The title and intro are its site_pages row's (Pages → Page
|
||||||
metadata.
|
management), which also give the search metadata.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
|
|
@ -18,7 +18,7 @@ import { useLocation } from 'react-router-dom'
|
||||||
import PageShell from '../components/PageShell.tsx'
|
import PageShell from '../components/PageShell.tsx'
|
||||||
import ComingSoon from '../components/ComingSoon.tsx'
|
import ComingSoon from '../components/ComingSoon.tsx'
|
||||||
import ContentBlocks from '../components/ContentBlocks.tsx'
|
import ContentBlocks from '../components/ContentBlocks.tsx'
|
||||||
import { sitePage } from '../lib/site.ts'
|
import { useSiteNav } from '../lib/useSiteNav.ts'
|
||||||
import { useSectionManifest } from '../lib/sections.tsx'
|
import { useSectionManifest } from '../lib/sections.tsx'
|
||||||
import { useSitePage, type SitePageSection } from '../lib/useSitePages.ts'
|
import { useSitePage, type SitePageSection } from '../lib/useSitePages.ts'
|
||||||
import { useHistory } from '../lib/useHistory.ts'
|
import { useHistory } from '../lib/useHistory.ts'
|
||||||
|
|
@ -97,10 +97,12 @@ const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function SitePage({ id }: { id: string }) {
|
export default function SitePage({ id }: { id: string }) {
|
||||||
const PAGE = sitePage(`/${id}`)
|
|
||||||
const { data: page, loading, error } = useSitePage(id)
|
const { data: page, loading, error } = useSitePage(id)
|
||||||
|
// Its title and intro: its own data, or the nav's until that comes.
|
||||||
|
const known = useSiteNav().pages.find((p) => p.id === id)
|
||||||
|
const PAGE = { title: page?.title ?? known?.title ?? '', description: page?.description ?? known?.description ?? undefined }
|
||||||
|
|
||||||
if (page) return <Sections title={PAGE.title} intro={PAGE.description} sections={page.sections} />
|
if (page) return <Sections title={PAGE.title} intro={PAGE.description ?? undefined} sections={page.sections} />
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,9 @@ import { Link } from "react-router-dom";
|
||||||
|
|
||||||
import LegalText, { type LegalPart } from "../components/LegalText.tsx";
|
import LegalText, { type LegalPart } from "../components/LegalText.tsx";
|
||||||
import PageShell from "../components/PageShell.tsx";
|
import PageShell from "../components/PageShell.tsx";
|
||||||
import { sitePage } from "../lib/site.ts";
|
import type { PageText } from "./fixedPages.ts";
|
||||||
import { BRAND } from "../lib/color.ts"
|
import { BRAND } from "../lib/color.ts"
|
||||||
|
|
||||||
/* Title and intro: site.json, which also gives the search metadata. */
|
|
||||||
const PAGE = sitePage("/terms");
|
|
||||||
|
|
||||||
/* Change the date when the wording changes. */
|
/* Change the date when the wording changes. */
|
||||||
const LAST_UPDATED = "September 28, 2026";
|
const LAST_UPDATED = "September 28, 2026";
|
||||||
|
|
@ -88,6 +86,7 @@ const SECTIONS = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function TermsPage() {
|
/* Its title and intro: its site_pages row (Pages → Page management). */
|
||||||
return <PageShell title={PAGE.title} intro={PAGE.description} sections={SECTIONS} />;
|
export default function TermsPage({ page: PAGE }: { page: PageText }) {
|
||||||
|
return <PageShell title={PAGE.title} intro={PAGE.description ?? undefined} sections={SECTIONS} />;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,9 @@
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { ArrowRight, ArrowUpRight } from "@phosphor-icons/react";
|
import { ArrowRight, ArrowUpRight } from "@phosphor-icons/react";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
import { get } from "../../lib/api.ts";
|
||||||
import { useAuth } from "../../lib/auth.tsx";
|
import { useAuth } from "../../lib/auth.tsx";
|
||||||
import { useWideAdminPage } from "../../lib/adminWidth.tsx";
|
import { useWideAdminPage } from "../../lib/adminWidth.tsx";
|
||||||
import { SITE_VERSION, VERSION_NAME } from "../../lib/version.ts";
|
import { SITE_VERSION, VERSION_NAME } from "../../lib/version.ts";
|
||||||
|
|
@ -40,6 +42,8 @@ const tintOf = (color: string) => `color-mix(in srgb, ${color} 12%, var(--color-
|
||||||
|
|
||||||
function NavCard({ item, color }) {
|
function NavCard({ item, color }) {
|
||||||
const to = target(item);
|
const to = target(item);
|
||||||
|
// The group's banner (Page management): the whole row, a stronger fill.
|
||||||
|
const banner = Boolean(item.banner);
|
||||||
|
|
||||||
// Drop the child that just repeats the card's own destination:
|
// Drop the child that just repeats the card's own destination:
|
||||||
// "All organizations" under Organizations.
|
// "All organizations" under Organizations.
|
||||||
|
|
@ -47,11 +51,13 @@ function NavCard({ item, color }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="group relative flex flex-col border-l-4 p-5 shadow-sm transition-shadow hover:shadow-md"
|
className={`group relative flex flex-col border-l-4 p-5 shadow-sm transition-shadow hover:shadow-md ${
|
||||||
style={{ borderColor: color, background: tintOf(color) }}
|
banner ? "sm:col-span-2 xl:col-span-3" : ""
|
||||||
|
}`}
|
||||||
|
style={{ borderColor: color, background: banner ? `color-mix(in srgb, ${color} 22%, var(--color-surface))` : tintOf(color) }}
|
||||||
>
|
>
|
||||||
<div className="flex items-baseline gap-3">
|
<div className="flex items-baseline gap-3">
|
||||||
<h3 className="text-base font-bold text-link">
|
<h3 className={`font-bold text-link ${banner ? "text-lg" : "text-base"}`}>
|
||||||
<Link
|
<Link
|
||||||
to={to}
|
to={to}
|
||||||
className="after:absolute after:inset-0 after:content-['']"
|
className="after:absolute after:inset-0 after:content-['']"
|
||||||
|
|
@ -127,10 +133,33 @@ const QUICK_ADD = [
|
||||||
{ to: "/admin/timeline/new", label: "New timeline entry" },
|
{ to: "/admin/timeline/new", label: "New timeline entry" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/* A card per page (Pages → Page management), in its order: the
|
||||||
|
front page's opens Front page, the others their page. */
|
||||||
|
function usePageCards() {
|
||||||
|
const [cards, setCards] = useState<any[]>([]);
|
||||||
|
useEffect(() => {
|
||||||
|
get("/admin/pages?limit=200", { ttl: 0 })
|
||||||
|
.then((list) =>
|
||||||
|
setCards(
|
||||||
|
list.rows.map((page) => ({
|
||||||
|
to: page.id === "home" ? "/admin/front_page" : `/admin/pages/${page.id}`,
|
||||||
|
label: page.title,
|
||||||
|
blurb: [page.path, page.is_hidden ? "Hidden" : null, page.is_disabled ? "Disabled" : null]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" · "),
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.catch(() => setCards([]));
|
||||||
|
}, []);
|
||||||
|
return cards;
|
||||||
|
}
|
||||||
|
|
||||||
export default function AdminHome() {
|
export default function AdminHome() {
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const role = ROLE_LABELS[user?.role] ?? user?.role;
|
const role = ROLE_LABELS[user?.role] ?? user?.role;
|
||||||
useWideAdminPage();
|
useWideAdminPage();
|
||||||
|
const pageCards = usePageCards();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid gap-8 lg:grid-cols-[1fr_17rem] lg:items-start">
|
<div className="grid gap-8 lg:grid-cols-[1fr_17rem] lg:items-start">
|
||||||
|
|
@ -142,9 +171,16 @@ export default function AdminHome() {
|
||||||
|
|
||||||
{GROUPS.map(({ nav, color }) => (
|
{GROUPS.map(({ nav, color }) => (
|
||||||
<CardBlock key={nav.label} title={nav.label} blurb={nav.blurb} color={color}>
|
<CardBlock key={nav.label} title={nav.label} blurb={nav.blurb} color={color}>
|
||||||
{visibleItems(nav.children, user).map((item) => (
|
{visibleItems(nav.children, user)
|
||||||
<NavCard key={item.to} item={item} color={color} />
|
.filter((item) => !item.menuOnly)
|
||||||
))}
|
.flatMap((item) =>
|
||||||
|
// Every page gets a card of its own after the banner.
|
||||||
|
item.banner
|
||||||
|
? [<NavCard key={item.to} item={item} color={color} />, ...pageCards.map((card) => (
|
||||||
|
<NavCard key={card.to} item={card} color={color} />
|
||||||
|
))]
|
||||||
|
: [<NavCard key={item.to} item={item} color={color} />],
|
||||||
|
)}
|
||||||
</CardBlock>
|
</CardBlock>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,9 @@ export default function EntityEdit() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const visible = (when) => !when || getPath(form, when.path) === when.value;
|
// A gate is a field's value, or a test of the whole form (a page's
|
||||||
|
// id deciding it has sections: sitePages.ts).
|
||||||
|
const visible = (when) => !when || (when.test ? when.test(form) : getPath(form, when.path) === when.value);
|
||||||
|
|
||||||
const groups = manifest.groups.filter((group) => visible(group.when));
|
const groups = manifest.groups.filter((group) => visible(group.when));
|
||||||
const shownChildren = children.filter((child) => visible(child.when));
|
const shownChildren = children.filter((child) => visible(child.when));
|
||||||
|
|
|
||||||
|
|
@ -120,49 +120,30 @@ export const PAGES_NAV = {
|
||||||
label: "Pages",
|
label: "Pages",
|
||||||
blurb: "What a page shows and in what order.",
|
blurb: "What a page shows and in what order.",
|
||||||
children: [
|
children: [
|
||||||
// The header's and footer's links, page titles and hidden pages.
|
// The banner on the admin home: every page, new ones, the menus.
|
||||||
|
// Each page's own card follows it there (AdminHome.tsx).
|
||||||
{
|
{
|
||||||
to: "/admin/navigation",
|
to: "/admin/pages",
|
||||||
label: "Navigation",
|
label: "Page management",
|
||||||
blurb: "The header's pages and buttons, the footer's links, each page's title and intro, and which pages are hidden.",
|
blurb: "Every page of the site: make new ones, change an address, title or intro, and hide or disable any of them. Then each page's sections.",
|
||||||
|
banner: true,
|
||||||
|
children: [
|
||||||
|
{ to: "/admin/pages/new", label: "New page" },
|
||||||
|
{ to: "/admin/navigation", label: "Menus (Navigation)" },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
// One record, not a list: the item opens it directly.
|
// One record, not a list: the item opens it directly. On the
|
||||||
|
// admin home, the Home page's own card goes here instead.
|
||||||
{
|
{
|
||||||
to: "/admin/front_page",
|
to: "/admin/front_page",
|
||||||
label: "Front page",
|
label: "Front page",
|
||||||
blurb: "The hero, its photos or livestream, and which bands the home page draws.",
|
blurb: "The hero, its photos or livestream, and which bands the home page draws.",
|
||||||
},
|
menuOnly: true,
|
||||||
// The site's own pages, in the header's order: each is its
|
|
||||||
// sections, built in the editor (sitePages.ts).
|
|
||||||
{
|
|
||||||
to: "/admin/retreats_page",
|
|
||||||
label: "Retreats",
|
|
||||||
blurb: "Its sections: the event carousels and grids, and anything else written for it.",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
to: "/admin/community_page",
|
to: "/admin/navigation",
|
||||||
label: "Community",
|
label: "Navigation",
|
||||||
blurb: "Its sections: the blog (and its pinned posts and feeds), groups map, regions and partners.",
|
blurb: "The header's pages and buttons and the footer's links.",
|
||||||
},
|
|
||||||
{
|
|
||||||
to: "/admin/resources_page",
|
|
||||||
label: "Resources",
|
|
||||||
blurb: "Its sections and their content.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
to: "/admin/organization_page",
|
|
||||||
label: "Organization",
|
|
||||||
blurb: "Mission, vision and values, the leadership teams and volunteering, details and contact.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
to: "/admin/history_page",
|
|
||||||
label: "History",
|
|
||||||
blurb: "Its sections: the timeline (its entries are under Data), and anything else.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
to: "/admin/shop_page",
|
|
||||||
label: "Shop",
|
|
||||||
blurb: "The shop's intro page: its sections and the links out to the store.",
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
23
src/pages/fixedPages.ts
Normal file
23
src/pages/fixedPages.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
FIXED PAGES
|
||||||
|
|
||||||
|
The pages the site still draws in code, by their site_pages id
|
||||||
|
(Pages → Page management can rename, move, hide or disable them,
|
||||||
|
not delete them: server/src/admin-schema/sitePages.js,
|
||||||
|
FIXED_PAGES). Every other page is its sections (SitePage.tsx).
|
||||||
|
Each takes its title and intro from its row. The front page is
|
||||||
|
the index route of its own (Home.tsx).
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { lazy, type ComponentType } from 'react'
|
||||||
|
|
||||||
|
export type PageText = { title: string; description: string | null }
|
||||||
|
|
||||||
|
export const FIXED_PAGES: Record<string, ComponentType<{ page: PageText }>> = {
|
||||||
|
give: lazy(() => import('./Giving.tsx')),
|
||||||
|
feedback: lazy(() => import('./Feedback.tsx')),
|
||||||
|
request: lazy(() => import('./Request.tsx')),
|
||||||
|
qr: lazy(() => import('./QrCodes.tsx')),
|
||||||
|
privacy: lazy(() => import('./Privacy.tsx')),
|
||||||
|
terms: lazy(() => import('./Terms.tsx')),
|
||||||
|
}
|
||||||
|
|
@ -186,7 +186,7 @@ export function TilePicker({
|
||||||
|
|
||||||
function LocationPicker({ page, section, onPageChange, onSectionChange }) {
|
function LocationPicker({ page, section, onPageChange, onSectionChange }) {
|
||||||
const sectionsOf = useNavSections();
|
const sectionsOf = useNavSections();
|
||||||
const { pages } = useSiteNav();
|
const { pageLinks: pages } = useSiteNav();
|
||||||
const sections = page === SITE_WIDE ? [] : sectionsOf(page);
|
const sections = page === SITE_WIDE ? [] : sectionsOf(page);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -253,7 +253,7 @@ function describeLocation(page, section, sectionsOf: (path: string) => NavSectio
|
||||||
|
|
||||||
export default function FeedbackForm({ fixedType }: { fixedType?: string } = {}) {
|
export default function FeedbackForm({ fixedType }: { fixedType?: string } = {}) {
|
||||||
const sectionsOf = useNavSections();
|
const sectionsOf = useNavSections();
|
||||||
const { pages } = useSiteNav();
|
const { pageLinks: pages } = useSiteNav();
|
||||||
const request = fixedType === DATA_REQUEST.id;
|
const request = fixedType === DATA_REQUEST.id;
|
||||||
const [type, setType] = useState<any>(fixedType ?? null);
|
const [type, setType] = useState<any>(fixedType ?? null);
|
||||||
const [page, setPage] = useState(SITE_WIDE);
|
const [page, setPage] = useState(SITE_WIDE);
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ type Group = { label?: string; choices: Choice[] }
|
||||||
on the site rather than an anchor on one of them (Give, not
|
on the site rather than an anchor on one of them (Give, not
|
||||||
Contact Us). */
|
Contact Us). */
|
||||||
function mainPages(nav: ReturnType<typeof useSiteNav>): Choice[] {
|
function mainPages(nav: ReturnType<typeof useSiteNav>): Choice[] {
|
||||||
const pages = nav.pages.map((p) => ({ path: p.path, label: p.label }))
|
const pages = nav.pageLinks.map((p) => ({ path: p.path, label: p.label }))
|
||||||
const known = new Set(pages.map((p) => p.path))
|
const known = new Set(pages.map((p) => p.path))
|
||||||
for (const action of nav.actions) {
|
for (const action of nav.actions) {
|
||||||
if (!action.path.startsWith('/') || action.path.includes('#') || known.has(action.path)) continue
|
if (!action.path.startsWith('/') || action.path.includes('#') || known.has(action.path)) continue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue