Compare commits
4 commits
45b422641a
...
af58e8fab5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af58e8fab5 | ||
|
|
e8ac242e6d | ||
|
|
9daf7b1a4f | ||
|
|
4a1d6fd6e9 |
38 changed files with 1605 additions and 1022 deletions
|
|
@ -29,10 +29,11 @@ what a dropdown in the admin editor says.
|
||||||
| ------------------------------------------------------------ | ---------------- | ------------------------------------ |
|
| ------------------------------------------------------------ | ---------------- | ------------------------------------ |
|
||||||
| A record: an event, organization, person, team, award, timeline entry | the database | editing it in the admin |
|
| A record: an event, organization, person, team, award, timeline entry | the database | editing it in the admin |
|
||||||
| The front page's words, photos, bands, stats and paths | the database | Admin → Pages → Front page |
|
| The front page's words, photos, bands, stats and paths | the database | Admin → Pages → Front page |
|
||||||
| Blog posts, and the Community page's blog section (headings, pins, feeds) | the database | Admin → Data → Blog posts, and Admin → Pages → Community blog section |
|
| Blog posts, and the Community page's blog settings (headings, pins, feeds) | the database | Admin → Data → Blog posts, and Admin → Pages → Community |
|
||||||
|
| The sections of Retreats, Community, Resources, Organization and History: titles, blurbs, accents, their content blocks and presets (the blog, groups map, regions, partners, events, timeline, NGU's details) | the database | Admin → Pages → the page. A section title is 30 characters at most (it's listed in the side nav); a front page heading fits about 60. Preset names: `PRESETS` in `src/lib/adminSchema/sitePages.ts`, what each draws: `PRESETS` in `src/pages/SitePage.tsx` |
|
||||||
| 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, page section titles, 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 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` |
|
||||||
| 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` |
|
||||||
|
|
||||||
|
|
@ -185,7 +186,7 @@ also in `server/src/admin-schema/` and a CHECK):
|
||||||
| Front page → Feature | none, livestream, video, event | **yes** | `HeroStage.tsx`; the event is picked in `server/src/routes/home.js` |
|
| Front page → Feature | none, livestream, video, event | **yes** | `HeroStage.tsx`; the event is picked in `server/src/routes/home.js` |
|
||||||
| Front page → Sections → Section | countdown, retreats, calendar, stats, timeline, connect, featured | **yes**, `FRONT_PAGE_SECTIONS` | `SECTIONS` in `src/pages/Home.tsx`; see [below](#front-page-section-names) |
|
| Front page → Sections → Section | countdown, retreats, calendar, stats, timeline, connect, featured | **yes**, `FRONT_PAGE_SECTIONS` | `SECTIONS` in `src/pages/Home.tsx`; see [below](#front-page-section-names) |
|
||||||
| Front page → Stats → Number Source | manual, years_since, regions, … | **yes**, `STAT_SOURCES` | `STAT_QUERIES` in `server/src/routes/home.js`; see [below](#front-page-stat-sources) |
|
| Front page → Stats → Number Source | manual, years_since, regions, … | **yes**, `STAT_SOURCES` | `STAT_QUERIES` in `server/src/routes/home.js`; see [below](#front-page-stat-sources) |
|
||||||
| Front page → Featured cards → Card type (Community blog section → Pinned community posts offers link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` |
|
| Front page → Featured cards → Card type (Community → Community blog: pinned community posts offers link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` |
|
||||||
| Front page → Featured cards → Record type | event, organization, person, team, award | no | `FEATURED_REFS` in `server/src/shape.js` (what each fills the card with); the triggers in `030_featured_cards.sql` |
|
| Front page → Featured cards → Record type | event, organization, person, team, award | no | `FEATURED_REFS` in `server/src/shape.js` (what each fills the card with); the triggers in `030_featured_cards.sql` |
|
||||||
| Every list → Published / Listed / Featured filter | 1, 0 | **yes** | n/a |
|
| Every list → Published / Listed / Featured filter | 1, 0 | **yes** | n/a |
|
||||||
|
|
||||||
|
|
@ -201,7 +202,7 @@ code):
|
||||||
| Event → Scope (+ list filter); Front page → Countdown → Only this scope | `event_scopes` | the `event_scopes` table (migration only) |
|
| Event → Scope (+ list filter); Front page → Countdown → Only this scope | `event_scopes` | the `event_scopes` table (migration only) |
|
||||||
| Event hosts → Organization; affiliations; team and award "Organization" / "Awarded by"; person → Home organization | `organizations` | organizations, labeled by name |
|
| Event hosts → Organization; affiliations; team and award "Organization" / "Awarded by"; person → Home organization | `organizations` | organizations, labeled by name |
|
||||||
| Event hosts / event people / team members / timeline people → Person | `people` | people |
|
| Event hosts / event people / team members / timeline people → Person | `people` | people |
|
||||||
| Community blog section → Pinned posts → Post | `blog_posts` | blog posts, newest first |
|
| Community → Community blog: pinned posts (ours) → Post | `blog_posts` | blog posts, newest first |
|
||||||
| Timeline → Record; Featured cards → Record | `record_refs` | every event, organization, award, person and team, narrowed by the type picked beside it |
|
| Timeline → Record; Featured cards → Record | `record_refs` | every event, organization, award, person and team, narrowed by the type picked beside it |
|
||||||
| Affiliations → Team | `teams` | teams, filtered to the chosen organization |
|
| Affiliations → Team | `teams` | teams, filtered to the chosen organization |
|
||||||
| Person awards → Award | `awards` | awards, labeled "Award (Organization)" |
|
| Person awards → Award | `awards` | awards, labeled "Award (Organization)" |
|
||||||
|
|
@ -219,7 +220,7 @@ each is changed in a different place:
|
||||||
| **The heading on the page** ("National Retreats", "What's on") | **Admin → Pages → Front page → Page sections → Heading.** Blank uses the default below. |
|
| **The heading on the page** ("National Retreats", "What's on") | **Admin → Pages → Front page → Page sections → Heading.** Blank uses the default below. |
|
||||||
| The default heading when that field is blank | `SECTIONS` in `src/pages/Home.tsx`, the `title` of each entry |
|
| The default heading when that field is blank | `SECTIONS` in `src/pages/Home.tsx`, the `title` of each entry |
|
||||||
| **The name in the admin's Section dropdown** ("Events Carousel (National Retreats)") | `FRONT_PAGE_SECTIONS` in `src/lib/adminSchema/frontPage.ts` |
|
| **The name in the admin's Section dropdown** ("Events Carousel (National Retreats)") | `FRONT_PAGE_SECTIONS` in `src/lib/adminSchema/frontPage.ts` |
|
||||||
| The subnav links under the header ("#Retreats", "#Calendar") | `PAGE_SECTIONS["/"]` in `src/navConfig.ts` |
|
| The links in the header's Home dropdown | the bands shown, under their headings (`src/lib/navSections.ts`) |
|
||||||
|
|
||||||
To rename a band **for visitors**, use the admin. To rename how it
|
To rename a band **for visitors**, use the admin. To rename how it
|
||||||
reads **in the editor's dropdown**, edit `FRONT_PAGE_SECTIONS`:
|
reads **in the editor's dropdown**, edit `FRONT_PAGE_SECTIONS`:
|
||||||
|
|
@ -267,8 +268,8 @@ 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) | `src/navConfig.ts` | `PAGE_LINKS` (order), `PAGE_SECTIONS`, `NAV_ACTIONS`. The front page's sections aren't listed there: they follow the bands it shows (Front page → Sections), through `src/lib/navSections.ts` and `src/lib/frontPageBands.ts` (each band's anchor and default heading). A new page also needs a route in `src/App.tsx`. |
|
| Header and footer navigation, each page's sections (the header dropdowns, mobile menu and footer site map) | `src/navConfig.ts` | `PAGE_LINKS` (order), `NAV_ACTIONS`. 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 also needs a route in `src/App.tsx`. |
|
||||||
| Section titles, blurbs and colors on Retreats, Community, Organization, Resources, Feedback, Privacy, Terms | the page file in `src/pages/` | the `SECTIONS` array at the top. A section's `id` must match its subnav `hash`. |
|
| 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. |
|
||||||
| Group map tiles and area names | `src/data/mapGrid.ts` | `AREAS` (tile positions) and `AREA_NAMES`. Which region paints which tile is in the database (Admin → Data → Organizations → a region → Map areas). |
|
| Group map tiles and area names | `src/data/mapGrid.ts` | `AREAS` (tile positions) and `AREA_NAMES`. Which region paints which tile is in the database (Admin → Data → Organizations → a region → Map areas). |
|
||||||
|
|
|
||||||
|
|
@ -189,8 +189,9 @@ export function readRow(db, entity, rawId) {
|
||||||
row[ext.key] = readExtension(db, ext, id);
|
row[ext.key] = readExtension(db, ext, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// As text, for the reason readChildren gives its nested ids.
|
||||||
for (const child of entity.children ?? []) {
|
for (const child of entity.children ?? []) {
|
||||||
row[child.key] = readChildren(db, child, id);
|
row[child.key] = readChildren(db, child, String(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
|
|
@ -236,15 +237,13 @@ function readChildren(db, child, ownerId) {
|
||||||
)
|
)
|
||||||
.all(...params);
|
.all(...params);
|
||||||
|
|
||||||
|
// Nested collections, to any depth: a page's sections, each
|
||||||
|
// section's blocks, each block's items. The id goes as text: a JS
|
||||||
|
// number binds as REAL, which a TEXT owner column (a section's
|
||||||
|
// blocks) holds as '13.0'; text suits an INTEGER owner just as well.
|
||||||
for (const child2 of child.children ?? []) {
|
for (const child2 of child.children ?? []) {
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
row[child2.key] = db
|
row[child2.key] = readChildren(db, child2, String(row.id));
|
||||||
.prepare(
|
|
||||||
`SELECT * FROM ${child2.table}
|
|
||||||
WHERE ${child2.owner.column} = ?
|
|
||||||
ORDER BY ${child2.order}`,
|
|
||||||
)
|
|
||||||
.all(row.id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -378,6 +377,14 @@ export function updateRow(db, entity, rawId, payload) {
|
||||||
`UPDATE ${entity.table} SET ${sets.join(", ")}
|
`UPDATE ${entity.table} SET ${sets.join(", ")}
|
||||||
WHERE ${entity.idColumn} = ?`,
|
WHERE ${entity.idColumn} = ?`,
|
||||||
).run(...Object.values(values), id);
|
).run(...Object.values(values), id);
|
||||||
|
} else if (entity.concurrency) {
|
||||||
|
// A row that is only its collections (a site page and its
|
||||||
|
// sections) still marks the save, or the next stale save
|
||||||
|
// would pass the check above.
|
||||||
|
db.prepare(
|
||||||
|
`UPDATE ${entity.table} SET ${entity.concurrency} = datetime('now')
|
||||||
|
WHERE ${entity.idColumn} = ?`,
|
||||||
|
).run(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeExtensions(db, entity, id, payload, merged);
|
writeExtensions(db, entity, id, payload, merged);
|
||||||
|
|
@ -507,7 +514,10 @@ function keyedDbErrors(prefix, fn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeChildren(db, entity, id, payload, parentValues) {
|
function writeChildren(db, entity, rawId, payload, parentValues) {
|
||||||
|
// As text: an auto id is a JS number, which binds as REAL and
|
||||||
|
// lands in a TEXT owner column (a newsletter's blocks) as '1.0'.
|
||||||
|
const id = String(rawId);
|
||||||
for (const child of entity.children ?? []) {
|
for (const child of entity.children ?? []) {
|
||||||
if (!applies(child.when, parentValues)) {
|
if (!applies(child.when, parentValues)) {
|
||||||
deleteChildren(db, child, id);
|
deleteChildren(db, child, id);
|
||||||
|
|
@ -516,8 +526,17 @@ function writeChildren(db, entity, id, payload, parentValues) {
|
||||||
if (payload[child.key] === undefined) continue; // not sent, not touched
|
if (payload[child.key] === undefined) continue; // not sent, not touched
|
||||||
|
|
||||||
deleteChildren(db, child, id);
|
deleteChildren(db, child, id);
|
||||||
|
writeRows(db, child, id, payload[child.key], `${child.key}.`, parentValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const incoming = Array.isArray(payload[child.key]) ? payload[child.key] : [];
|
/* One collection's rows under one owner, then each row's own nested
|
||||||
|
collections under it, to any depth. Only the top level is deleted
|
||||||
|
first (writeChildren): a nested row goes with its owner, by a
|
||||||
|
foreign key's cascade or, for a polymorphic owner like a section's
|
||||||
|
blocks, by the owner table's cleanup trigger. */
|
||||||
|
function writeRows(db, child, ownerId, incomingRaw, prefix, parentValues) {
|
||||||
|
const incoming = Array.isArray(incomingRaw) ? incomingRaw : [];
|
||||||
|
|
||||||
// index is the row's place in what the client sent, so a
|
// index is the row's place in what the client sent, so a
|
||||||
// validation error still points at the row the user is looking
|
// validation error still points at the row the user is looking
|
||||||
|
|
@ -528,15 +547,14 @@ function writeChildren(db, entity, id, payload, parentValues) {
|
||||||
.filter(({ raw }) => child.allowBlank || !isBlankChildRow(child, raw));
|
.filter(({ raw }) => child.allowBlank || !isBlankChildRow(child, raw));
|
||||||
|
|
||||||
rows.forEach(({ raw, index }, position) => {
|
rows.forEach(({ raw, index }, position) => {
|
||||||
const { values, errors } = coerceRow(child.columns, raw, {
|
const rowPrefix = `${prefix}${index}.`;
|
||||||
prefix: `${child.key}.${index}.`,
|
const { values, errors } = coerceRow(child.columns, raw, { prefix: rowPrefix });
|
||||||
});
|
|
||||||
if (Object.keys(errors).length) {
|
if (Object.keys(errors).length) {
|
||||||
throw new HttpError(422, "Validation failed", errors);
|
throw new HttpError(422, "Validation failed", errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
const names = [child.owner.column, ...Object.keys(values)];
|
const names = [child.owner.column, ...Object.keys(values)];
|
||||||
const params = [id, ...Object.values(values)];
|
const params = [ownerId, ...Object.values(values)];
|
||||||
|
|
||||||
if (child.owner.kindColumn) {
|
if (child.owner.kindColumn) {
|
||||||
names.push(child.owner.kindColumn);
|
names.push(child.owner.kindColumn);
|
||||||
|
|
@ -545,14 +563,14 @@ function writeChildren(db, entity, id, payload, parentValues) {
|
||||||
for (const [column, from] of Object.entries(child.owner.inherit ?? {})) {
|
for (const [column, from] of Object.entries(child.owner.inherit ?? {})) {
|
||||||
if (names.includes(column)) continue;
|
if (names.includes(column)) continue;
|
||||||
names.push(column);
|
names.push(column);
|
||||||
params.push(parentValues[from] ?? id);
|
params.push(parentValues[from] ?? ownerId);
|
||||||
}
|
}
|
||||||
if (child.order === "sort_order" && !names.includes("sort_order")) {
|
if (child.order === "sort_order" && !names.includes("sort_order")) {
|
||||||
names.push("sort_order");
|
names.push("sort_order");
|
||||||
params.push(position);
|
params.push(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = keyedDbErrors(`${child.key}.${index}.`, () =>
|
const result = keyedDbErrors(rowPrefix, () =>
|
||||||
db
|
db
|
||||||
.prepare(
|
.prepare(
|
||||||
`INSERT INTO ${child.table} (${names.join(", ")})
|
`INSERT INTO ${child.table} (${names.join(", ")})
|
||||||
|
|
@ -562,34 +580,9 @@ function writeChildren(db, entity, id, payload, parentValues) {
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const child2 of child.children ?? []) {
|
for (const child2 of child.children ?? []) {
|
||||||
const incomingNested = Array.isArray(raw[child2.key]) ? raw[child2.key] : [];
|
writeRows(db, child2, String(result.lastInsertRowid), raw[child2.key], `${rowPrefix}${child2.key}.`, values);
|
||||||
const nested = incomingNested
|
|
||||||
.map((rawItem, i) => ({ rawItem, i }))
|
|
||||||
.filter(({ rawItem }) => child2.allowBlank || !isBlankChildRow(child2, rawItem));
|
|
||||||
|
|
||||||
nested.forEach(({ rawItem, i }, nestedPosition) => {
|
|
||||||
const item = coerceRow(child2.columns, rawItem, {
|
|
||||||
prefix: `${child.key}.${index}.${child2.key}.${i}.`,
|
|
||||||
});
|
|
||||||
if (Object.keys(item.errors).length) {
|
|
||||||
throw new HttpError(422, "Validation failed", item.errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
const itemNames = [child2.owner.column, ...Object.keys(item.values)];
|
|
||||||
const itemParams = [result.lastInsertRowid, ...Object.values(item.values)];
|
|
||||||
if (!itemNames.includes("sort_order")) {
|
|
||||||
itemNames.push("sort_order");
|
|
||||||
itemParams.push(nestedPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
db.prepare(
|
|
||||||
`INSERT INTO ${child2.table} (${itemNames.join(", ")})
|
|
||||||
VALUES (${itemNames.map(() => "?").join(", ")})`,
|
|
||||||
).run(...itemParams);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteChildren(db, child, ownerId) {
|
function deleteChildren(db, child, ownerId) {
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,16 @@ import { teams } from "./admin-schema/teams.js";
|
||||||
import { awards } from "./admin-schema/awards.js";
|
import { awards } from "./admin-schema/awards.js";
|
||||||
import { timeline } from "./admin-schema/timeline.js";
|
import { timeline } from "./admin-schema/timeline.js";
|
||||||
import { frontPage } from "./admin-schema/frontPage.js";
|
import { frontPage } from "./admin-schema/frontPage.js";
|
||||||
import { blogPosts, communityPage } from "./admin-schema/blog.js";
|
import { blogPosts } from "./admin-schema/blog.js";
|
||||||
import { siteSettings } from "./admin-schema/siteSettings.js";
|
import { siteSettings } from "./admin-schema/siteSettings.js";
|
||||||
import { organizationPage } from "./admin-schema/organizationPage.js";
|
import { newsletters } from "./admin-schema/newsletters.js";
|
||||||
|
import {
|
||||||
|
communityPage,
|
||||||
|
retreatsPage,
|
||||||
|
resourcesPage,
|
||||||
|
organizationPage,
|
||||||
|
historyPage,
|
||||||
|
} from "./admin-schema/sitePages.js";
|
||||||
|
|
||||||
export const ENTITIES = {
|
export const ENTITIES = {
|
||||||
organizations,
|
organizations,
|
||||||
|
|
@ -63,8 +70,12 @@ export const ENTITIES = {
|
||||||
front_page: frontPage,
|
front_page: frontPage,
|
||||||
blog_posts: blogPosts,
|
blog_posts: blogPosts,
|
||||||
community_page: communityPage,
|
community_page: communityPage,
|
||||||
|
retreats_page: retreatsPage,
|
||||||
|
resources_page: resourcesPage,
|
||||||
organization_page: organizationPage,
|
organization_page: organizationPage,
|
||||||
|
history_page: historyPage,
|
||||||
site_settings: siteSettings,
|
site_settings: siteSettings,
|
||||||
|
newsletters,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ── Options for the form's select inputs ────────────────────── */
|
/* ── Options for the form's select inputs ────────────────────── */
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
import { text, url, int, bool, date, featuredCardsChild, blocksChild } from "./columns.js";
|
import { text, bool, date, blocksChild } from "./columns.js";
|
||||||
|
|
||||||
/* ── Blog (031_blog.sql) ─────────────────────────────────────────
|
/* ── Blog (031_blog.sql) ─────────────────────────────────────────
|
||||||
|
|
||||||
Posts of our own, with a content-block body and people as
|
Posts of our own, with a content-block body and people as
|
||||||
authors, and the Community page's blog section, a singleton like
|
authors. The Community page's blog section is edited with that
|
||||||
the front page. The section's community posts are featured cards
|
page (sitePages.js). ──────────────────────────────────────── */
|
||||||
owned by 'community_page'. ─────────────────────────────────── */
|
|
||||||
|
|
||||||
export const blogPosts = {
|
export const blogPosts = {
|
||||||
key: "blog_posts",
|
key: "blog_posts",
|
||||||
|
|
@ -46,48 +45,3 @@ export const blogPosts = {
|
||||||
blocksChild("blog_post"),
|
blocksChild("blog_post"),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const communityPage = {
|
|
||||||
key: "community_page",
|
|
||||||
table: "community_page",
|
|
||||||
idColumn: "id",
|
|
||||||
idKind: "slug",
|
|
||||||
singleton: "community",
|
|
||||||
concurrency: "updated_at",
|
|
||||||
|
|
||||||
list: {
|
|
||||||
columns: ["id", "blog_title", "updated_at"],
|
|
||||||
filters: [],
|
|
||||||
search: [],
|
|
||||||
order: "id",
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
text("blog_title"),
|
|
||||||
text("blog_blurb"),
|
|
||||||
text("internal_title"),
|
|
||||||
int("internal_slots"),
|
|
||||||
text("external_title"),
|
|
||||||
int("external_slots"),
|
|
||||||
url("external_url"),
|
|
||||||
text("external_label"),
|
|
||||||
],
|
|
||||||
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: "pinned_posts",
|
|
||||||
table: "community_page_pinned_posts",
|
|
||||||
owner: { column: "page_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [text("post_id", { required: true })],
|
|
||||||
},
|
|
||||||
featuredCardsChild("community_page"),
|
|
||||||
{
|
|
||||||
key: "feeds",
|
|
||||||
table: "community_page_feeds",
|
|
||||||
owner: { column: "page_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [url("url", { required: true }), text("label")],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
|
||||||
27
server/src/admin-schema/newsletters.js
Normal file
27
server/src/admin-schema/newsletters.js
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { text, blocksChild } from "./columns.js";
|
||||||
|
|
||||||
|
/* ── Newsletter drafts (057_newsletters.sql) ─────────────────────
|
||||||
|
|
||||||
|
Saved from Tools → Newsletter (AdminNewsletter.tsx), which is
|
||||||
|
their only editor: there is no list or form for them in Data.
|
||||||
|
`picks` is the builder's JSON of what's ticked. Deleting a draft
|
||||||
|
takes its blocks with it (newsletters_cleanup). */
|
||||||
|
|
||||||
|
export const newsletters = {
|
||||||
|
key: "newsletters",
|
||||||
|
table: "newsletters",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "auto",
|
||||||
|
concurrency: "updated_at",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: ["id", "title", "updated_at"],
|
||||||
|
filters: [],
|
||||||
|
search: ["title"],
|
||||||
|
order: "updated_at DESC, id DESC",
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [text("title"), text("intro"), text("footer"), text("picks")],
|
||||||
|
|
||||||
|
children: [blocksChild("newsletter")],
|
||||||
|
};
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
/* The Organization page (/organization): one row, its blocks and its
|
|
||||||
volunteering links (055_organization_page.sql). Two block
|
|
||||||
collections, each its own owner kind, so the editor shows them
|
|
||||||
apart: the Mission, Vision & Values section, and the Leadership
|
|
||||||
section (a People block per team, in order). */
|
|
||||||
|
|
||||||
import { text, url, blocksChild } from "./columns.js";
|
|
||||||
|
|
||||||
export const organizationPage = {
|
|
||||||
key: "organization_page",
|
|
||||||
table: "organization_page",
|
|
||||||
idColumn: "id",
|
|
||||||
idKind: "slug",
|
|
||||||
singleton: "organization",
|
|
||||||
concurrency: "updated_at",
|
|
||||||
|
|
||||||
list: {
|
|
||||||
columns: ["id", "updated_at"],
|
|
||||||
filters: [],
|
|
||||||
search: [],
|
|
||||||
order: "id",
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
text("mission_title"),
|
|
||||||
text("leadership_title"),
|
|
||||||
text("leadership_blurb"),
|
|
||||||
text("volunteer_title"),
|
|
||||||
text("volunteer_blurb"),
|
|
||||||
],
|
|
||||||
|
|
||||||
children: [
|
|
||||||
{ ...blocksChild("org_page_mission"), key: "mission_blocks" },
|
|
||||||
{ ...blocksChild("org_page_leadership"), key: "leadership_blocks" },
|
|
||||||
{
|
|
||||||
key: "volunteer_links",
|
|
||||||
table: "organization_page_links",
|
|
||||||
owner: { column: "page_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [text("label", { required: true }), url("url", { required: true })],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
95
server/src/admin-schema/sitePages.js
Normal file
95
server/src/admin-schema/sitePages.js
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
import { text, url, int, enumeration, featuredCardsChild, blocksChild } from "./columns.js";
|
||||||
|
|
||||||
|
/* ── The site's own pages (056_site_pages.sql) ───────────────────
|
||||||
|
|
||||||
|
Community, Retreats, Resources, Organization and History: one
|
||||||
|
site_pages row each, edited as its own singleton, with its
|
||||||
|
sections nested under it and each section's blocks under that
|
||||||
|
(the blocks' items under them, as on any record). A section is
|
||||||
|
either its blocks or a preset, a prebuilt part of the site
|
||||||
|
(SitePage.tsx draws both).
|
||||||
|
|
||||||
|
Community also carries the blog section's settings: the
|
||||||
|
community_page row (same id) as an extension, and its pinned
|
||||||
|
posts, cards and feeds, all owned by that id. */
|
||||||
|
|
||||||
|
const sectionsChild = {
|
||||||
|
key: "sections",
|
||||||
|
table: "page_sections",
|
||||||
|
owner: { column: "page_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [
|
||||||
|
text("anchor", { required: true }),
|
||||||
|
text("title", { required: true }),
|
||||||
|
text("blurb"),
|
||||||
|
enumeration("accent", ["teal", "deep", "green", "amber"]),
|
||||||
|
enumeration("preset", [
|
||||||
|
"community_blog",
|
||||||
|
"group_map",
|
||||||
|
"region_list",
|
||||||
|
"partner_list",
|
||||||
|
"events",
|
||||||
|
"timeline",
|
||||||
|
"organization_details",
|
||||||
|
]),
|
||||||
|
text("scope_id"),
|
||||||
|
enumeration("event_type", ["retreat", "class", "workshop", "meeting", "other"]),
|
||||||
|
enumeration("view", ["carousel", "grid", "map"]),
|
||||||
|
],
|
||||||
|
children: [blocksChild("page_section")],
|
||||||
|
};
|
||||||
|
|
||||||
|
const sitePage = (id, more = {}) => ({
|
||||||
|
key: `${id}_page`,
|
||||||
|
table: "site_pages",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "slug",
|
||||||
|
singleton: id,
|
||||||
|
concurrency: "updated_at",
|
||||||
|
|
||||||
|
list: { columns: ["id", "updated_at"], filters: [], search: [], order: "id" },
|
||||||
|
|
||||||
|
columns: [],
|
||||||
|
...more,
|
||||||
|
children: [sectionsChild, ...(more.children ?? [])],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const communityPage = sitePage("community", {
|
||||||
|
extensions: [
|
||||||
|
{
|
||||||
|
key: "blog",
|
||||||
|
table: "community_page",
|
||||||
|
idColumn: "id",
|
||||||
|
columns: [
|
||||||
|
text("internal_title"),
|
||||||
|
int("internal_slots"),
|
||||||
|
text("external_title"),
|
||||||
|
int("external_slots"),
|
||||||
|
url("external_url"),
|
||||||
|
text("external_label"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: "pinned_posts",
|
||||||
|
table: "community_page_pinned_posts",
|
||||||
|
owner: { column: "page_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [text("post_id", { required: true })],
|
||||||
|
},
|
||||||
|
featuredCardsChild("community_page"),
|
||||||
|
{
|
||||||
|
key: "feeds",
|
||||||
|
table: "community_page_feeds",
|
||||||
|
owner: { column: "page_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [url("url", { required: true }), text("label")],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const retreatsPage = sitePage("retreats");
|
||||||
|
export const resourcesPage = sitePage("resources");
|
||||||
|
export const organizationPage = sitePage("organization");
|
||||||
|
export const historyPage = sitePage("history");
|
||||||
|
|
@ -26,7 +26,7 @@ import history from "./routes/history.js";
|
||||||
import home from "./routes/home.js";
|
import home from "./routes/home.js";
|
||||||
import directory from "./routes/directory.js";
|
import directory from "./routes/directory.js";
|
||||||
import blog from "./routes/blog.js";
|
import blog from "./routes/blog.js";
|
||||||
import organizationPage from "./routes/organizationPage.js";
|
import sitePages from "./routes/sitePages.js";
|
||||||
import pages from "./routes/pages.js";
|
import pages from "./routes/pages.js";
|
||||||
import feedback from "./routes/feedback.js";
|
import feedback from "./routes/feedback.js";
|
||||||
import requests from "./routes/requests.js";
|
import requests from "./routes/requests.js";
|
||||||
|
|
@ -170,7 +170,7 @@ app.route("/api", history);
|
||||||
app.route("/api", home);
|
app.route("/api", home);
|
||||||
app.route("/api", directory);
|
app.route("/api", directory);
|
||||||
app.route("/api", blog);
|
app.route("/api", blog);
|
||||||
app.route("/api", organizationPage);
|
app.route("/api", sitePages);
|
||||||
|
|
||||||
// Tighter limit on the write path than anything else gets.
|
// Tighter limit on the write path than anything else gets.
|
||||||
app.use("/api/feedback", rateLimit({ windowMs: 60_000, max: 5 }));
|
app.use("/api/feedback", rateLimit({ windowMs: 60_000, max: 5 }));
|
||||||
|
|
|
||||||
221
server/src/migrations/056_site_pages.sql
Normal file
221
server/src/migrations/056_site_pages.sql
Normal file
|
|
@ -0,0 +1,221 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 056 PAGE EDITORS: SECTIONS FOR THE SITE'S OWN PAGES
|
||||||
|
--
|
||||||
|
-- Community, Retreats, Resources, Organization and History are
|
||||||
|
-- built in the admin (Pages → each page) as a list of sections. A
|
||||||
|
-- section is its title (30 characters at most: it's listed in the
|
||||||
|
-- page's side nav), an optional blurb, an accent and the anchor it
|
||||||
|
-- sits at, and then either
|
||||||
|
--
|
||||||
|
-- its own content blocks content_blocks owned 'page_section',
|
||||||
|
-- owner_id the section's id
|
||||||
|
-- a preset a prebuilt part of the site, drawn by
|
||||||
|
-- the page (SitePage.tsx): the Community
|
||||||
|
-- blog, the group map, the region list,
|
||||||
|
-- the partner cards, an event list (scope,
|
||||||
|
-- type and the view it opens in), the
|
||||||
|
-- timeline, NGU's address and tax details
|
||||||
|
--
|
||||||
|
-- Every page's sections are seeded as the code drew them, so nothing
|
||||||
|
-- moves on the site. Organization takes what 055's editor held: its
|
||||||
|
-- Mission and Leadership blocks, with the Volunteering title, blurb
|
||||||
|
-- and links appended to the Leadership section as a heading, a
|
||||||
|
-- paragraph and link buttons; 055's tables go.
|
||||||
|
--
|
||||||
|
-- The Community blog's own settings (its slots, pinned posts, feeds)
|
||||||
|
-- stay in community_page, now edited inside the Community page
|
||||||
|
-- editor; its heading and blurb become the blog section's own, so
|
||||||
|
-- community_page loses blog_title and blog_blurb.
|
||||||
|
--
|
||||||
|
-- content_blocks is rebuilt for its owner_kind CHECK (as 055 did),
|
||||||
|
-- moving 055's blocks across on the way. A section deleted (every
|
||||||
|
-- save rewrites them) takes its blocks with it, by trigger, since
|
||||||
|
-- the owner is polymorphic and can't be a foreign key.
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
CREATE TABLE site_pages (
|
||||||
|
id TEXT PRIMARY KEY
|
||||||
|
CHECK (id IN ('community', 'retreats', 'resources', 'organization', 'history')),
|
||||||
|
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
INSERT INTO site_pages (id) VALUES ('community'), ('retreats'), ('resources'), ('organization'), ('history');
|
||||||
|
|
||||||
|
CREATE TABLE page_sections (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
page_id TEXT NOT NULL REFERENCES site_pages (id) ON DELETE CASCADE,
|
||||||
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||||
|
anchor TEXT NOT NULL
|
||||||
|
CONSTRAINT "A section's URL ID can use only lowercase letters, numbers and hyphens, eg. leadership."
|
||||||
|
CHECK (anchor <> '' AND anchor NOT GLOB '*[^a-z0-9-]*'),
|
||||||
|
title TEXT NOT NULL
|
||||||
|
CONSTRAINT "A section title can be 30 characters at most (it's listed in the page's side nav)."
|
||||||
|
CHECK (length(title) <= 30),
|
||||||
|
blurb TEXT,
|
||||||
|
accent TEXT CHECK (accent IN ('teal', 'deep', 'green', 'amber')),
|
||||||
|
preset TEXT CHECK (preset IN ('community_blog', 'group_map', 'region_list', 'partner_list',
|
||||||
|
'events', 'timeline', 'organization_details')),
|
||||||
|
-- An events preset's filter and first view.
|
||||||
|
scope_id TEXT REFERENCES event_scopes (id) ON DELETE SET NULL,
|
||||||
|
event_type TEXT CHECK (event_type IN ('retreat', 'class', 'workshop', 'meeting', 'other')),
|
||||||
|
view TEXT CHECK (view IN ('carousel', 'grid', 'map')),
|
||||||
|
UNIQUE (page_id, anchor)
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
CREATE INDEX page_sections_page_idx ON page_sections (page_id, sort_order);
|
||||||
|
|
||||||
|
INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view)
|
||||||
|
SELECT 'community', 0, 'blog', COALESCE(blog_title, 'Community Blog'), blog_blurb, 'teal', 'community_blog', NULL, NULL, NULL
|
||||||
|
FROM community_page WHERE id = 'community';
|
||||||
|
|
||||||
|
INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view) VALUES
|
||||||
|
('community', 1, 'groups', 'Local Groups',
|
||||||
|
'Young adult groups meeting in person and online across the movement.', 'teal', 'group_map', NULL, NULL, 'map'),
|
||||||
|
('community', 2, 'regions', 'Unity Regions',
|
||||||
|
'The regional organizations that support groups and host their own gatherings.', 'deep', 'region_list', NULL, NULL, NULL),
|
||||||
|
('community', 3, 'partners', 'Partner Organizations',
|
||||||
|
'Organizations we collaborate with across the Unity movement and beyond.', 'amber', 'partner_list', NULL, NULL, NULL),
|
||||||
|
|
||||||
|
('retreats', 0, 'national', 'National Retreats',
|
||||||
|
'Our flagship gatherings, open to young adults across the country.', 'teal', 'events', 'national', 'retreat', 'carousel'),
|
||||||
|
('retreats', 1, 'regional', 'Regional Retreats',
|
||||||
|
'Smaller gatherings hosted by regions throughout the year.', 'green', 'events', 'regional', 'retreat', 'grid'),
|
||||||
|
('retreats', 2, 'partner', 'Partner Events',
|
||||||
|
'Retreats hosted by organizations we collaborate with.', 'amber', 'events', 'partner', 'retreat', 'grid'),
|
||||||
|
|
||||||
|
('resources', 0, 'unity', 'Unity Teachings',
|
||||||
|
'Core principles, readings, and study material from the Unity movement.', 'teal', NULL, NULL, NULL, NULL),
|
||||||
|
('resources', 1, 'branding', 'Branding & Marketing',
|
||||||
|
'Logos, colors, templates, and guidelines for representing NGU.', 'green', NULL, NULL, NULL, NULL),
|
||||||
|
('resources', 2, 'partner', 'Partner Resources',
|
||||||
|
'Material for the organizations we collaborate with.', 'amber', NULL, NULL, NULL, NULL),
|
||||||
|
|
||||||
|
('history', 0, 'timeline', 'NGU Timeline', 'Open a year to see what happened.', 'teal', 'timeline', NULL, NULL, NULL),
|
||||||
|
|
||||||
|
('organization', 2, 'contact', 'Details & Contact', NULL, 'deep', 'organization_details', NULL, NULL, NULL);
|
||||||
|
|
||||||
|
INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, accent)
|
||||||
|
SELECT 'organization', 0, 'mission', substr(COALESCE(mission_title, 'Mission, Vision & Values'), 1, 30), NULL, 'teal'
|
||||||
|
FROM organization_page WHERE id = 'organization';
|
||||||
|
|
||||||
|
INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, accent)
|
||||||
|
SELECT 'organization', 1, 'leadership', substr(COALESCE(leadership_title, 'Leadership'), 1, 30), leadership_blurb, 'green'
|
||||||
|
FROM organization_page WHERE id = 'organization';
|
||||||
|
|
||||||
|
ALTER TABLE community_page DROP COLUMN blog_title;
|
||||||
|
ALTER TABLE community_page DROP COLUMN blog_blurb;
|
||||||
|
|
||||||
|
|
||||||
|
-- ── Blocks: the new owner kind, 055's blocks moved across ──────
|
||||||
|
|
||||||
|
CREATE TABLE content_blocks_new (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
owner_kind TEXT NOT NULL
|
||||||
|
CHECK (owner_kind IN ('organization', 'event', 'person', 'team', 'blog_post', 'page_section')),
|
||||||
|
owner_id TEXT NOT NULL,
|
||||||
|
slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body')),
|
||||||
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||||
|
|
||||||
|
type TEXT NOT NULL
|
||||||
|
CHECK (type IN ('heading', 'subheading', 'paragraph',
|
||||||
|
'list', 'links', 'quote', 'image', 'divider',
|
||||||
|
'video', 'button', 'callout', 'schedule', 'table', 'cards',
|
||||||
|
'people')),
|
||||||
|
text TEXT,
|
||||||
|
media TEXT,
|
||||||
|
href TEXT,
|
||||||
|
alt TEXT,
|
||||||
|
cite TEXT,
|
||||||
|
team_id TEXT REFERENCES teams (id) ON DELETE SET NULL
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
INSERT INTO content_blocks_new
|
||||||
|
(id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id)
|
||||||
|
SELECT b.id,
|
||||||
|
CASE WHEN b.owner_kind IN ('org_page_mission', 'org_page_leadership') THEN 'page_section' ELSE b.owner_kind END,
|
||||||
|
CASE b.owner_kind
|
||||||
|
WHEN 'org_page_mission' THEN
|
||||||
|
(SELECT CAST(s.id AS TEXT) FROM page_sections s WHERE s.page_id = 'organization' AND s.anchor = 'mission')
|
||||||
|
WHEN 'org_page_leadership' THEN
|
||||||
|
(SELECT CAST(s.id AS TEXT) FROM page_sections s WHERE s.page_id = 'organization' AND s.anchor = 'leadership')
|
||||||
|
ELSE b.owner_id
|
||||||
|
END,
|
||||||
|
b.slot, b.sort_order, b.type, b.text, b.media, b.href, b.alt, b.cite, b.team_id
|
||||||
|
FROM content_blocks b;
|
||||||
|
|
||||||
|
PRAGMA legacy_alter_table = ON;
|
||||||
|
DROP TABLE content_blocks;
|
||||||
|
ALTER TABLE content_blocks_new RENAME TO content_blocks;
|
||||||
|
PRAGMA legacy_alter_table = OFF;
|
||||||
|
|
||||||
|
CREATE INDEX content_blocks_owner_idx
|
||||||
|
ON content_blocks (owner_kind, owner_id, slot, sort_order);
|
||||||
|
|
||||||
|
-- Volunteering, appended to the Leadership section where 055 had it.
|
||||||
|
INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text)
|
||||||
|
SELECT 'page_section', CAST(s.id AS TEXT), 'body', 1000, 'heading', COALESCE(p.volunteer_title, 'Volunteering')
|
||||||
|
FROM organization_page p
|
||||||
|
JOIN page_sections s ON s.page_id = 'organization' AND s.anchor = 'leadership'
|
||||||
|
WHERE p.volunteer_title IS NOT NULL OR p.volunteer_blurb IS NOT NULL
|
||||||
|
OR EXISTS (SELECT 1 FROM organization_page_links);
|
||||||
|
|
||||||
|
INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text)
|
||||||
|
SELECT 'page_section', CAST(s.id AS TEXT), 'body', 1001, 'paragraph', p.volunteer_blurb
|
||||||
|
FROM organization_page p
|
||||||
|
JOIN page_sections s ON s.page_id = 'organization' AND s.anchor = 'leadership'
|
||||||
|
WHERE p.volunteer_blurb IS NOT NULL;
|
||||||
|
|
||||||
|
INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type)
|
||||||
|
SELECT 'page_section', CAST(s.id AS TEXT), 'body', 1002, 'links'
|
||||||
|
FROM page_sections s
|
||||||
|
WHERE s.page_id = 'organization' AND s.anchor = 'leadership'
|
||||||
|
AND EXISTS (SELECT 1 FROM organization_page_links);
|
||||||
|
|
||||||
|
INSERT INTO content_block_items (block_id, sort_order, text, url)
|
||||||
|
SELECT b.id, l.sort_order, l.label, l.url
|
||||||
|
FROM organization_page_links l
|
||||||
|
JOIN content_blocks b ON b.owner_kind = 'page_section' AND b.type = 'links' AND b.sort_order = 1002;
|
||||||
|
|
||||||
|
DROP TABLE organization_page_links;
|
||||||
|
DROP TABLE organization_page;
|
||||||
|
|
||||||
|
|
||||||
|
-- ── Triggers last (see CLAUDE.md, Migrations) ──
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
CREATE TRIGGER page_sections_cleanup
|
||||||
|
AFTER DELETE ON page_sections
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM content_blocks WHERE owner_kind = 'page_section' AND owner_id = CAST(old.id AS TEXT);
|
||||||
|
END;
|
||||||
|
|
||||||
|
CREATE TRIGGER content_blocks_owner_exists
|
||||||
|
BEFORE INSERT ON content_blocks
|
||||||
|
BEGIN
|
||||||
|
SELECT CASE
|
||||||
|
WHEN new.owner_kind = 'event'
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.owner_id)
|
||||||
|
THEN RAISE(ABORT, 'content_blocks: no such event')
|
||||||
|
WHEN new.owner_kind = 'organization'
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.owner_id)
|
||||||
|
THEN RAISE(ABORT, 'content_blocks: no such organization')
|
||||||
|
WHEN new.owner_kind = 'person'
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.owner_id)
|
||||||
|
THEN RAISE(ABORT, 'content_blocks: no such person')
|
||||||
|
WHEN new.owner_kind = 'team'
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.owner_id)
|
||||||
|
THEN RAISE(ABORT, 'content_blocks: no such team')
|
||||||
|
WHEN new.owner_kind = 'blog_post'
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM blog_posts WHERE id = new.owner_id)
|
||||||
|
THEN RAISE(ABORT, 'content_blocks: no such blog post')
|
||||||
|
WHEN new.owner_kind = 'page_section'
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM page_sections WHERE CAST(id AS TEXT) = new.owner_id)
|
||||||
|
THEN RAISE(ABORT, 'content_blocks: no such page section')
|
||||||
|
END;
|
||||||
|
END;
|
||||||
111
server/src/migrations/057_newsletters.sql
Normal file
111
server/src/migrations/057_newsletters.sql
Normal file
|
|
@ -0,0 +1,111 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 057 NEWSLETTER DRAFTS
|
||||||
|
--
|
||||||
|
-- Tools → Newsletter saves what it builds as a draft, to come back
|
||||||
|
-- to, copy into Mailchimp again, or post as a blog post:
|
||||||
|
--
|
||||||
|
-- title, intro the email's heading and opening lines
|
||||||
|
-- footer the closing lines (blank: the site's name and
|
||||||
|
-- address); no unsubscribe link, since Mailchimp
|
||||||
|
-- adds its own
|
||||||
|
-- picks what's ticked, as JSON: event ids, blog post
|
||||||
|
-- ids, and the front page cards by their link
|
||||||
|
-- ({"events": [...], "posts": [...], "cards": [...]})
|
||||||
|
-- blocks content_blocks owned 'newsletter': whatever is
|
||||||
|
-- written for this issue, under the intro
|
||||||
|
--
|
||||||
|
-- content_blocks is rebuilt for its owner_kind CHECK (as 056 did). A
|
||||||
|
-- draft deleted takes its blocks with it, by trigger.
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
CREATE TABLE newsletters (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
title TEXT,
|
||||||
|
intro TEXT,
|
||||||
|
footer TEXT,
|
||||||
|
picks TEXT NOT NULL DEFAULT '{}' CHECK (json_valid(picks)),
|
||||||
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||||
|
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
|
||||||
|
-- ── Blocks: the new owner kind ─────────────────────────────────
|
||||||
|
|
||||||
|
CREATE TABLE content_blocks_new (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
owner_kind TEXT NOT NULL
|
||||||
|
CHECK (owner_kind IN ('organization', 'event', 'person', 'team', 'blog_post', 'page_section',
|
||||||
|
'newsletter')),
|
||||||
|
owner_id TEXT NOT NULL,
|
||||||
|
slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body')),
|
||||||
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||||
|
|
||||||
|
type TEXT NOT NULL
|
||||||
|
CHECK (type IN ('heading', 'subheading', 'paragraph',
|
||||||
|
'list', 'links', 'quote', 'image', 'divider',
|
||||||
|
'video', 'button', 'callout', 'schedule', 'table', 'cards',
|
||||||
|
'people')),
|
||||||
|
text TEXT,
|
||||||
|
media TEXT,
|
||||||
|
href TEXT,
|
||||||
|
alt TEXT,
|
||||||
|
cite TEXT,
|
||||||
|
team_id TEXT REFERENCES teams (id) ON DELETE SET NULL
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
INSERT INTO content_blocks_new
|
||||||
|
(id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id)
|
||||||
|
SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id
|
||||||
|
FROM content_blocks;
|
||||||
|
|
||||||
|
PRAGMA legacy_alter_table = ON;
|
||||||
|
DROP TABLE content_blocks;
|
||||||
|
ALTER TABLE content_blocks_new RENAME TO content_blocks;
|
||||||
|
PRAGMA legacy_alter_table = OFF;
|
||||||
|
|
||||||
|
CREATE INDEX content_blocks_owner_idx
|
||||||
|
ON content_blocks (owner_kind, owner_id, slot, sort_order);
|
||||||
|
|
||||||
|
|
||||||
|
-- ── Triggers last (see CLAUDE.md, Migrations) ──
|
||||||
|
|
||||||
|
CREATE TRIGGER newsletters_touch
|
||||||
|
AFTER UPDATE ON newsletters
|
||||||
|
FOR EACH ROW WHEN new.updated_at = old.updated_at
|
||||||
|
BEGIN
|
||||||
|
UPDATE newsletters SET updated_at = datetime('now') WHERE id = new.id;
|
||||||
|
END;
|
||||||
|
|
||||||
|
CREATE TRIGGER newsletters_cleanup
|
||||||
|
AFTER DELETE ON newsletters
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM content_blocks WHERE owner_kind = 'newsletter' AND owner_id = CAST(old.id AS TEXT);
|
||||||
|
END;
|
||||||
|
|
||||||
|
CREATE TRIGGER content_blocks_owner_exists
|
||||||
|
BEFORE INSERT ON content_blocks
|
||||||
|
BEGIN
|
||||||
|
SELECT CASE
|
||||||
|
WHEN new.owner_kind = 'event'
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.owner_id)
|
||||||
|
THEN RAISE(ABORT, 'content_blocks: no such event')
|
||||||
|
WHEN new.owner_kind = 'organization'
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.owner_id)
|
||||||
|
THEN RAISE(ABORT, 'content_blocks: no such organization')
|
||||||
|
WHEN new.owner_kind = 'person'
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.owner_id)
|
||||||
|
THEN RAISE(ABORT, 'content_blocks: no such person')
|
||||||
|
WHEN new.owner_kind = 'team'
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.owner_id)
|
||||||
|
THEN RAISE(ABORT, 'content_blocks: no such team')
|
||||||
|
WHEN new.owner_kind = 'blog_post'
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM blog_posts WHERE id = new.owner_id)
|
||||||
|
THEN RAISE(ABORT, 'content_blocks: no such blog post')
|
||||||
|
WHEN new.owner_kind = 'page_section'
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM page_sections WHERE CAST(id AS TEXT) = new.owner_id)
|
||||||
|
THEN RAISE(ABORT, 'content_blocks: no such page section')
|
||||||
|
WHEN new.owner_kind = 'newsletter'
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM newsletters WHERE CAST(id AS TEXT) = new.owner_id)
|
||||||
|
THEN RAISE(ABORT, 'content_blocks: no such newsletter')
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
|
@ -191,8 +191,6 @@ blog.get("/community-blog", async (c) => {
|
||||||
|
|
||||||
return json(c, {
|
return json(c, {
|
||||||
community_blog: {
|
community_blog: {
|
||||||
title: page.blog_title,
|
|
||||||
blurb: page.blog_blurb,
|
|
||||||
internal: {
|
internal: {
|
||||||
title: page.internal_title,
|
title: page.internal_title,
|
||||||
posts: posts.map((row) =>
|
posts: posts.map((row) =>
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
|
||||||
ORGANIZATION PAGE ROUTE: read-only, mounted under /api
|
|
||||||
|
|
||||||
GET /organization-page the Organization page's own content:
|
|
||||||
its section titles, the Mission and
|
|
||||||
Leadership blocks, and Volunteering
|
|
||||||
(title, blurb, links)
|
|
||||||
|
|
||||||
Edited in the admin as Pages → Organization page
|
|
||||||
(admin-schema/organizationPage.js). The blocks are shaped as on
|
|
||||||
any record page (loadBlocks), so ContentBlocks draws them.
|
|
||||||
═══════════════════════════════════════════════════════════════ */
|
|
||||||
|
|
||||||
import { Hono } from "hono";
|
|
||||||
import { json, loadBlocks } from "../shape.js";
|
|
||||||
|
|
||||||
const ID = "organization";
|
|
||||||
const organizationPage = new Hono();
|
|
||||||
|
|
||||||
organizationPage.get("/organization-page", (c) => {
|
|
||||||
const db = c.get("db");
|
|
||||||
const row = db.prepare(`SELECT * FROM organization_page WHERE id = ?`).get(ID) ?? {};
|
|
||||||
const links = db
|
|
||||||
.prepare(`SELECT label, url FROM organization_page_links WHERE page_id = ? ORDER BY sort_order, id`)
|
|
||||||
.all(ID);
|
|
||||||
|
|
||||||
return json(c, {
|
|
||||||
page: {
|
|
||||||
mission_title: row.mission_title ?? null,
|
|
||||||
mission_blocks: loadBlocks(db, "org_page_mission", [ID]).get(ID) ?? [],
|
|
||||||
leadership_title: row.leadership_title ?? null,
|
|
||||||
leadership_blurb: row.leadership_blurb ?? null,
|
|
||||||
leadership_blocks: loadBlocks(db, "org_page_leadership", [ID]).get(ID) ?? [],
|
|
||||||
volunteer: {
|
|
||||||
title: row.volunteer_title ?? null,
|
|
||||||
blurb: row.volunteer_blurb ?? null,
|
|
||||||
links,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
export default organizationPage;
|
|
||||||
57
server/src/routes/sitePages.js
Normal file
57
server/src/routes/sitePages.js
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
SITE PAGE ROUTES: read-only, mounted under /api
|
||||||
|
|
||||||
|
GET /site-pages every site page's section headings, for
|
||||||
|
the header's dropdowns and the side nav
|
||||||
|
GET /site-pages/:id one page's sections, in order: heading,
|
||||||
|
accent, preset (and an events preset's
|
||||||
|
filter and view), and its blocks
|
||||||
|
|
||||||
|
Edited in the admin as Pages → each page
|
||||||
|
(admin-schema/sitePages.js). Blocks are shaped as on any record
|
||||||
|
page (loadBlocks), so ContentBlocks draws them.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { Hono } from "hono";
|
||||||
|
import { json, loadBlocks } from "../shape.js";
|
||||||
|
|
||||||
|
const sitePages = new Hono();
|
||||||
|
|
||||||
|
sitePages.get("/site-pages", (c) => {
|
||||||
|
const rows = c
|
||||||
|
.get("db")
|
||||||
|
.prepare(`SELECT page_id, anchor, title FROM page_sections ORDER BY page_id, sort_order, id`)
|
||||||
|
.all();
|
||||||
|
|
||||||
|
const pages = {};
|
||||||
|
for (const row of rows) (pages[row.page_id] ??= []).push({ anchor: row.anchor, title: row.title });
|
||||||
|
return json(c, { pages });
|
||||||
|
});
|
||||||
|
|
||||||
|
sitePages.get("/site-pages/:id", (c) => {
|
||||||
|
const db = c.get("db");
|
||||||
|
const id = c.req.param("id");
|
||||||
|
if (!db.prepare(`SELECT 1 FROM site_pages WHERE id = ?`).get(id)) {
|
||||||
|
return c.json({ error: "No such page." }, 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
const rows = db
|
||||||
|
.prepare(
|
||||||
|
`SELECT id, anchor, title, blurb, accent, preset, scope_id, event_type, view
|
||||||
|
FROM page_sections WHERE page_id = ? ORDER BY sort_order, id`,
|
||||||
|
)
|
||||||
|
.all(id);
|
||||||
|
const blocks = loadBlocks(db, "page_section", rows.map((row) => String(row.id)));
|
||||||
|
|
||||||
|
return json(c, {
|
||||||
|
page: {
|
||||||
|
id,
|
||||||
|
sections: rows.map(({ id: sectionId, ...section }) => ({
|
||||||
|
...section,
|
||||||
|
blocks: blocks.get(String(sectionId)) ?? [],
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
export default sitePages;
|
||||||
18
src/App.tsx
18
src/App.tsx
|
|
@ -49,11 +49,9 @@ const lazyPage = (load) =>
|
||||||
throw err
|
throw err
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
const Retreats = lazyPage(() => import("./pages/Retreats.tsx"))
|
// Community, Retreats, Resources, Organization and History: each
|
||||||
const Community = lazyPage(() => import("./pages/Community.tsx"))
|
// built in the admin from sections.
|
||||||
const Organization = lazyPage(() => import("./pages/Organization.tsx"))
|
const SitePage = lazyPage(() => import("./pages/SitePage.tsx"))
|
||||||
const Resources = lazyPage(() => import("./pages/Resources.tsx"))
|
|
||||||
const History = lazyPage(() => import("./pages/History.tsx"))
|
|
||||||
const Feedback = lazyPage(() => import("./pages/Feedback.tsx"))
|
const Feedback = lazyPage(() => import("./pages/Feedback.tsx"))
|
||||||
const Request = lazyPage(() => import("./pages/Request.tsx"))
|
const Request = lazyPage(() => import("./pages/Request.tsx"))
|
||||||
const Giving = lazyPage(() => import("./pages/Giving.tsx"))
|
const Giving = lazyPage(() => import("./pages/Giving.tsx"))
|
||||||
|
|
@ -91,9 +89,9 @@ 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={<Retreats />} />
|
<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={<Community />} />
|
<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 />} />
|
||||||
|
|
@ -102,9 +100,9 @@ export default function App() {
|
||||||
<Route path="/awards/:id" element={<AwardDetail />} />
|
<Route path="/awards/:id" element={<AwardDetail />} />
|
||||||
<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="organization" element={<Organization />} />
|
<Route path="organization" element={<SitePage key="organization" id="organization" />} />
|
||||||
<Route path="resources" element={<Resources />} />
|
<Route path="resources" element={<SitePage key="resources" id="resources" />} />
|
||||||
<Route path="history" element={<History />} />
|
<Route path="history" element={<SitePage key="history" id="history" />} />
|
||||||
<Route path="feedback" element={<Feedback />} />
|
<Route path="feedback" element={<Feedback />} />
|
||||||
<Route path="request" element={<Request />} />
|
<Route path="request" element={<Request />} />
|
||||||
<Route path="qr" element={<QrCodes />} />
|
<Route path="qr" element={<QrCodes />} />
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ export default function Footer() {
|
||||||
<footer className="py-16 px-6" style={{ background: "#001011" }}>
|
<footer className="py-16 px-6" style={{ background: "#001011" }}>
|
||||||
<div className="max-w-6xl mx-auto">
|
<div className="max-w-6xl mx-auto">
|
||||||
<div className="grid grid-cols-1 md:grid-cols-12 gap-10 md:gap-8 mb-12">
|
<div className="grid grid-cols-1 md:grid-cols-12 gap-10 md:gap-8 mb-12">
|
||||||
{/* Brand and details on top, the site map across the full
|
{/* Brand and details, beside the socials and contact links;
|
||||||
width below them. */}
|
the site map spans the full width below them all. */}
|
||||||
<div className="md:col-span-9 text-center md:text-left">
|
<div className="md:col-span-9 text-center md:text-left">
|
||||||
{/* The logo, and Give beside it. */}
|
{/* The logo, and Give beside it. */}
|
||||||
<div className="flex flex-wrap items-center justify-center gap-6 md:justify-start">
|
<div className="flex flex-wrap items-center justify-center gap-6 md:justify-start">
|
||||||
|
|
@ -82,37 +82,6 @@ export default function Footer() {
|
||||||
{Organization_Details.nonprofit} Tax ID: {Organization_Details.taxId}.
|
{Organization_Details.nonprofit} Tax ID: {Organization_Details.taxId}.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{/* Site map: mirrors both nav tiers */}
|
|
||||||
<nav aria-label="Site map" className="mt-10">
|
|
||||||
<h2 className={headingClass}>Site Map</h2>
|
|
||||||
<ul className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-x-6 gap-y-6">
|
|
||||||
{PAGE_LINKS.map((page) => {
|
|
||||||
const sections = sectionsOf(page.path);
|
|
||||||
return (
|
|
||||||
<li key={page.path}>
|
|
||||||
<Link to={page.path} className={pageLinkClass}>
|
|
||||||
{page.label}
|
|
||||||
</Link>
|
|
||||||
|
|
||||||
{sections.length > 0 && (
|
|
||||||
<ul className="mt-1 flex flex-col">
|
|
||||||
{sections.map((section) => (
|
|
||||||
<li key={section.hash}>
|
|
||||||
<Link
|
|
||||||
to={`${page.path}${section.hash}`}
|
|
||||||
className={sectionLinkClass}
|
|
||||||
>
|
|
||||||
{section.label.replace(/^#/, "")}
|
|
||||||
</Link>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
)}
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -158,6 +127,38 @@ export default function Footer() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Site map: every page and its sections, across the full width. */}
|
||||||
|
<nav aria-label="Site map" className="mb-12 border-t border-white/10 pt-10">
|
||||||
|
<h2 className={headingClass}>Site Map</h2>
|
||||||
|
<ul className="grid grid-cols-2 gap-x-6 gap-y-6 sm:grid-cols-3 lg:grid-cols-6">
|
||||||
|
{PAGE_LINKS.map((page) => {
|
||||||
|
const sections = sectionsOf(page.path);
|
||||||
|
return (
|
||||||
|
<li key={page.path}>
|
||||||
|
<Link to={page.path} className={pageLinkClass}>
|
||||||
|
{page.label}
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
{sections.length > 0 && (
|
||||||
|
<ul className="mt-1 flex flex-col">
|
||||||
|
{sections.map((section) => (
|
||||||
|
<li key={section.hash}>
|
||||||
|
<Link
|
||||||
|
to={`${page.path}${section.hash}`}
|
||||||
|
className={sectionLinkClass}
|
||||||
|
>
|
||||||
|
{section.label.replace(/^#/, "")}
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
<div className="border-t border-white/10 pt-8 flex flex-col md:flex-row items-center justify-between gap-4">
|
<div className="border-t border-white/10 pt-8 flex flex-col md:flex-row items-center justify-between gap-4">
|
||||||
<p className="text-white/65 text-sm">© 2026 Next Generation of Unity. All rights reserved.</p>
|
<p className="text-white/65 text-sm">© 2026 Next Generation of Unity. All rights reserved.</p>
|
||||||
<div className="flex gap-6">
|
<div className="flex gap-6">
|
||||||
|
|
|
||||||
|
|
@ -166,10 +166,12 @@ export default function Layout() {
|
||||||
|
|
||||||
{/* Each page, and under it on hover or keyboard focus its
|
{/* Each page, and under it on hover or keyboard focus its
|
||||||
sections (navSections.ts): the sections live in these
|
sections (navSections.ts): the sections live in these
|
||||||
dropdowns rather than a strip of their own. */}
|
dropdowns rather than a strip of their own. Home has
|
||||||
|
none: it's the logo's link too, and its bands are one
|
||||||
|
scroll away. */}
|
||||||
<div className="hidden lg:flex items-center gap-6">
|
<div className="hidden lg:flex items-center gap-6">
|
||||||
{PAGE_LINKS.map((page) => {
|
{PAGE_LINKS.map((page) => {
|
||||||
const pageSections = sectionsOf(page.path);
|
const pageSections = page.path === "/" ? [] : sectionsOf(page.path);
|
||||||
return (
|
return (
|
||||||
<div key={page.path} className="group relative">
|
<div key={page.path} className="group relative">
|
||||||
<NavLink
|
<NavLink
|
||||||
|
|
|
||||||
|
|
@ -105,12 +105,17 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
|
||||||
if (typeof title === "string") document.title = documentTitle(title);
|
if (typeof title === "string") document.title = documentTitle(title);
|
||||||
}, [title]);
|
}, [title]);
|
||||||
|
|
||||||
|
// The thin solid banner between sections. With the side nav it runs
|
||||||
|
// the page's full width, under the nav column, rather than stopping
|
||||||
|
// at the content's edge.
|
||||||
|
const banner = (accent: string) => (
|
||||||
|
<div className={`h-2 ${sideNav ? "lg:-ml-[var(--side-nav-w)]" : ""}`} style={{ background: accent }} />
|
||||||
|
);
|
||||||
const bands = sections.map((section, i) => (
|
const bands = sections.map((section, i) => (
|
||||||
<div key={section.id}>
|
<div key={section.id}>
|
||||||
{/* Thin solid banner between sections */}
|
{banner(section.accent)}
|
||||||
<div className="h-2" style={{ background: section.accent }} />
|
|
||||||
<Section section={section} />
|
<Section section={section} />
|
||||||
{i === sections.length - 1 && <div className="h-2" style={{ background: section.accent }} />}
|
{i === sections.length - 1 && banner(section.accent)}
|
||||||
</div>
|
</div>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
@ -127,10 +132,10 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{sideNav ? (
|
{sideNav ? (
|
||||||
<div className="lg:grid lg:grid-cols-[13rem_minmax(0,1fr)]">
|
<div className="[--side-nav-w:16rem] lg:grid lg:grid-cols-[var(--side-nav-w)_minmax(0,1fr)]">
|
||||||
<aside className="hidden lg:block">
|
<aside className="relative z-10 hidden lg:block">
|
||||||
<div className="sticky pt-8 pl-6" style={{ top: "calc(var(--header-h, 5rem) + 1rem)" }}>
|
<div className="sticky pt-8 pl-6 pr-2" style={{ top: "calc(var(--header-h, 5rem) + 1rem)" }}>
|
||||||
<SectionNav sections={sections.map((s) => ({ id: s.id, label: s.title }))} />
|
<SectionNav sections={sections.map((s) => ({ id: s.id, label: s.title }))} wrap />
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
<div className="min-w-0">{bands}</div>
|
<div className="min-w-0">{bands}</div>
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,10 @@ function jump(id: string) {
|
||||||
document.getElementById(id)?.scrollIntoView({ behavior: scrollBehavior(), block: "start" });
|
document.getElementById(id)?.scrollIntoView({ behavior: scrollBehavior(), block: "start" });
|
||||||
}
|
}
|
||||||
|
|
||||||
function Label({ section }: { section: EditorSection }) {
|
function Label({ section, wrap }: { section: EditorSection; wrap?: boolean }) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span className="truncate">{section.label}</span>
|
<span className={wrap ? "" : "truncate"}>{section.label}</span>
|
||||||
{section.count != null && (
|
{section.count != null && (
|
||||||
<span className="text-xs text-muted/70">({section.count})</span>
|
<span className="text-xs text-muted/70">({section.count})</span>
|
||||||
)}
|
)}
|
||||||
|
|
@ -84,7 +84,9 @@ function Label({ section }: { section: EditorSection }) {
|
||||||
|
|
||||||
/* The desktop column. Place it in the grid's first track, in a cell
|
/* The desktop column. Place it in the grid's first track, in a cell
|
||||||
that is itself sticky (see EntityEdit). */
|
that is itself sticky (see EntityEdit). */
|
||||||
export function SectionNav({ sections }: { sections: EditorSection[] }) {
|
/* `wrap` lets a long label run onto a second line instead of being
|
||||||
|
cut short (the public pages' section titles, up to 30 characters). */
|
||||||
|
export function SectionNav({ sections, wrap = false }: { sections: EditorSection[]; wrap?: boolean }) {
|
||||||
const active = useActiveSection(sections);
|
const active = useActiveSection(sections);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -107,7 +109,7 @@ export function SectionNav({ sections }: { sections: EditorSection[] }) {
|
||||||
: "border-transparent text-muted hover:border-brand/40 hover:text-link"
|
: "border-transparent text-muted hover:border-brand/40 hover:text-link"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<Label section={section} />
|
<Label section={section} wrap={wrap} />
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,15 @@ import { teams } from "./adminSchema/teams.ts";
|
||||||
import { awards } from "./adminSchema/awards.ts";
|
import { awards } from "./adminSchema/awards.ts";
|
||||||
import { timeline } from "./adminSchema/timeline.ts";
|
import { timeline } from "./adminSchema/timeline.ts";
|
||||||
import { frontPage } from "./adminSchema/frontPage.ts";
|
import { frontPage } from "./adminSchema/frontPage.ts";
|
||||||
import { blogPosts, communityPage } from "./adminSchema/blog.ts";
|
import { blogPosts } from "./adminSchema/blog.ts";
|
||||||
import { siteSettings } from "./adminSchema/siteSettings.ts";
|
import { siteSettings } from "./adminSchema/siteSettings.ts";
|
||||||
import { organizationPage } from "./adminSchema/organizationPage.ts";
|
import {
|
||||||
|
communityPage,
|
||||||
|
retreatsPage,
|
||||||
|
resourcesPage,
|
||||||
|
organizationPage,
|
||||||
|
historyPage,
|
||||||
|
} from "./adminSchema/sitePages.ts";
|
||||||
|
|
||||||
export const ADMIN_ENTITIES: Record<string, any> = {
|
export const ADMIN_ENTITIES: Record<string, any> = {
|
||||||
organizations,
|
organizations,
|
||||||
|
|
@ -39,7 +45,10 @@ export const ADMIN_ENTITIES: Record<string, any> = {
|
||||||
front_page: frontPage,
|
front_page: frontPage,
|
||||||
blog_posts: blogPosts,
|
blog_posts: blogPosts,
|
||||||
community_page: communityPage,
|
community_page: communityPage,
|
||||||
|
retreats_page: retreatsPage,
|
||||||
|
resources_page: resourcesPage,
|
||||||
organization_page: organizationPage,
|
organization_page: organizationPage,
|
||||||
|
history_page: historyPage,
|
||||||
site_settings: siteSettings,
|
site_settings: siteSettings,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
import { preview } from "../text.ts";
|
|
||||||
import { mediaUrl } from "../media.ts";
|
import { mediaUrl } from "../media.ts";
|
||||||
import { PUBLISHED_FIELD, LISTED_FIELD, FEATURED_KINDS, featuredCardsChild, blocksChild } from "./shared.ts";
|
import { PUBLISHED_FIELD, LISTED_FIELD, blocksChild } from "./shared.ts";
|
||||||
|
|
||||||
/* ── Blog (031_blog.sql) ─────────────────────────────────────────
|
/* ── Blog (031_blog.sql) ─────────────────────────────────────────
|
||||||
Posts at /blog/:id, and the Community page's blog section. The
|
Posts at /blog/:id. The Community page's blog section is edited
|
||||||
section's community posts reuse the featured cards, limited to
|
with that page (sitePages.ts). */
|
||||||
links: a pinned Substack post is a link card, and Fetch preview
|
|
||||||
fills it from the post. */
|
|
||||||
|
|
||||||
/* A post's body is the content blocks without the card/body choice:
|
/* A post's body is the content blocks without the card/body choice:
|
||||||
a post only has a body. */
|
a post only has a body. */
|
||||||
|
|
@ -106,87 +103,3 @@ export const blogPosts = {
|
||||||
blogBlocksChild,
|
blogBlocksChild,
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const communityPage = {
|
|
||||||
key: "community_page",
|
|
||||||
label: "Community blog section",
|
|
||||||
singular: "community blog section",
|
|
||||||
idLabel: "Page",
|
|
||||||
singleton: "community",
|
|
||||||
|
|
||||||
list: { columns: [], filters: [] },
|
|
||||||
|
|
||||||
groups: [
|
|
||||||
{
|
|
||||||
legend: "Section",
|
|
||||||
note: "The first section of the Community page.",
|
|
||||||
fields: [
|
|
||||||
{ path: "blog_title", label: "Heading", help: "Default: Community Blog" },
|
|
||||||
{ path: "blog_blurb", label: "Blurb", widget: "textarea", full: true },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
legend: "Our posts",
|
|
||||||
note: "Pinned posts first, then the newest published, listed posts, up to the number of slots.",
|
|
||||||
fields: [
|
|
||||||
{ path: "internal_title", label: "Heading", help: "Default: From NGU" },
|
|
||||||
{ path: "internal_slots", label: "Slots", widget: "number", help: "0 to 12. Default: 3" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
legend: "Community posts",
|
|
||||||
note: "Pinned cards first, then the newest items from the feeds below, up to the number of slots.",
|
|
||||||
fields: [
|
|
||||||
{ path: "external_title", label: "Heading", help: "Default: From our community" },
|
|
||||||
{ path: "external_slots", label: "Slots", widget: "number", help: "0 to 12. Default: 3" },
|
|
||||||
{ path: "external_url", label: "Button link", help: "eg. https://ngu.substack.com", full: true },
|
|
||||||
{ path: "external_label", label: "Button text", help: "Default: Read more on Substack" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: "pinned_posts",
|
|
||||||
label: "Pinned posts (ours)",
|
|
||||||
note: "Always shown, before the newest.",
|
|
||||||
addLabel: "Pin a post",
|
|
||||||
title: (row, options) =>
|
|
||||||
options?.blog_posts?.find((p) => p.id === row.post_id)?.label ?? "New pin",
|
|
||||||
blank: { post_id: "" },
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
path: "post_id",
|
|
||||||
label: "Post",
|
|
||||||
widget: "select",
|
|
||||||
optionsFrom: "blog_posts",
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...featuredCardsChild,
|
|
||||||
label: "Pinned community posts",
|
|
||||||
note: "Always shown, before the feeds' newest. Paste a post's link and press Fetch preview.",
|
|
||||||
addLabel: "Pin a post",
|
|
||||||
blank: { kind: "", url: "", title: "" },
|
|
||||||
fields: featuredCardsChild.fields.map((field) =>
|
|
||||||
field.path === "kind"
|
|
||||||
? { ...field, options: FEATURED_KINDS.filter(([kind]) => kind !== "record") }
|
|
||||||
: field,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "feeds",
|
|
||||||
label: "Feeds",
|
|
||||||
note: "RSS or Atom feeds whose newest posts fill the community slots. Read about every 30 minutes.",
|
|
||||||
addLabel: "Add feed",
|
|
||||||
title: (row) => row.label || row.url || "New feed",
|
|
||||||
blank: { url: "", label: "" },
|
|
||||||
fields: [
|
|
||||||
{ path: "url", label: "Feed URL", required: true, full: true, help: "eg. https://ngu.substack.com/feed" },
|
|
||||||
{ path: "label", label: "Source name", help: "Shown on its cards. Default: the feed's own title" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ export const frontPage = {
|
||||||
options: FRONT_PAGE_SECTIONS,
|
options: FRONT_PAGE_SECTIONS,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
{ path: "title", label: "Heading", help: "Heading Override" },
|
{ path: "title", label: "Heading", help: "Default: the band's own name. Up to about 60 characters fit." },
|
||||||
{ path: "blurb", label: "Blurb", full: true },
|
{ path: "blurb", label: "Blurb", full: true },
|
||||||
{ path: "is_hidden", label: "Hidden", widget: "checkbox", help: "Hide for now" },
|
{ path: "is_hidden", label: "Hidden", widget: "checkbox", help: "Hide for now" },
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
/* Pages → Organization page: the /organization page's own content.
|
|
||||||
Server side: server/src/admin-schema/organizationPage.js. Each
|
|
||||||
section's blocks are their own collection; the Leadership blocks
|
|
||||||
are where the teams go, a People block each, in order. */
|
|
||||||
|
|
||||||
import { blocksChild } from "./shared.ts";
|
|
||||||
|
|
||||||
/* A block collection for one section: the shared block editor,
|
|
||||||
without "Shown in" (these blocks only ever show on the page). */
|
|
||||||
const sectionBlocks = (key: string, label: string, note: string) => ({
|
|
||||||
...blocksChild,
|
|
||||||
key,
|
|
||||||
label,
|
|
||||||
note,
|
|
||||||
fields: blocksChild.fields.filter((field) => field.path !== "slot"),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const organizationPage = {
|
|
||||||
key: "organization_page",
|
|
||||||
label: "Organization page",
|
|
||||||
singular: "organization page",
|
|
||||||
idLabel: "Page",
|
|
||||||
singleton: "organization",
|
|
||||||
|
|
||||||
list: { columns: [], filters: [] },
|
|
||||||
|
|
||||||
groups: [
|
|
||||||
{
|
|
||||||
legend: "Mission, Vision & Values",
|
|
||||||
note: "The page's first section. Its content is the Mission blocks below.",
|
|
||||||
fields: [{ path: "mission_title", label: "Heading", help: "Default: Mission, Vision & Values" }],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
legend: "Leadership",
|
|
||||||
note: "The second section: the Leadership blocks below, then Volunteering.",
|
|
||||||
fields: [
|
|
||||||
{ path: "leadership_title", label: "Heading", help: "Default: Leadership" },
|
|
||||||
{ path: "leadership_blurb", label: "Blurb", widget: "textarea", full: true },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
legend: "Volunteering",
|
|
||||||
note: "Under the leadership: a title, a line or two and the links below.",
|
|
||||||
fields: [
|
|
||||||
{ path: "volunteer_title", label: "Title", help: "Default: Volunteering" },
|
|
||||||
{ path: "volunteer_blurb", label: "Blurb", widget: "textarea", full: true },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
children: [
|
|
||||||
sectionBlocks("mission_blocks", "Mission blocks", "The Mission, Vision & Values section: headings, paragraphs, lists, whatever it needs."),
|
|
||||||
sectionBlocks(
|
|
||||||
"leadership_blocks",
|
|
||||||
"Leadership blocks",
|
|
||||||
"The Leadership section, in order: eg. a People block for the Board of Trustees, then one for the Retreat Team.",
|
|
||||||
),
|
|
||||||
{
|
|
||||||
key: "volunteer_links",
|
|
||||||
label: "Volunteering links",
|
|
||||||
note: "Buttons under the volunteering blurb.",
|
|
||||||
addLabel: "Add link",
|
|
||||||
title: (row) => row.label || row.url || "New link",
|
|
||||||
blank: { label: "", url: "" },
|
|
||||||
fields: [
|
|
||||||
{ path: "label", label: "Label", required: true, help: "eg. Volunteer at a retreat" },
|
|
||||||
{ path: "url", label: "Link", required: true, full: true, help: "A page on this site (eg. /request) or anywhere else" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
215
src/lib/adminSchema/sitePages.ts
Normal file
215
src/lib/adminSchema/sitePages.ts
Normal file
|
|
@ -0,0 +1,215 @@
|
||||||
|
/* ── The site's own pages (056_site_pages.sql) ───────────────────
|
||||||
|
Pages → Community, Retreats, Resources, Organization, History:
|
||||||
|
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
|
||||||
|
(a prebuilt part of the site, drawn under the blocks). Server
|
||||||
|
side: server/src/admin-schema/sitePages.js; the page is
|
||||||
|
src/pages/SitePage.tsx.
|
||||||
|
|
||||||
|
The preset values are the CHECK list on page_sections.preset;
|
||||||
|
each page offers the ones that belong on it. */
|
||||||
|
|
||||||
|
import { FEATURED_KINDS, featuredCardsChild, blocksChild } from "./shared.ts";
|
||||||
|
|
||||||
|
const PRESETS = {
|
||||||
|
community_blog: "Community blog (its settings are below)",
|
||||||
|
group_map: "Local groups map",
|
||||||
|
region_list: "Unity Regions list",
|
||||||
|
partner_list: "Partner organization cards",
|
||||||
|
events: "Event carousel or grid",
|
||||||
|
timeline: "Timeline",
|
||||||
|
organization_details: "Address, tax ID and email",
|
||||||
|
};
|
||||||
|
|
||||||
|
const ACCENT_OPTIONS = [
|
||||||
|
["teal", "Teal"],
|
||||||
|
["deep", "Deep teal"],
|
||||||
|
["green", "Green"],
|
||||||
|
["amber", "Amber"],
|
||||||
|
];
|
||||||
|
|
||||||
|
const EVENT_TYPES = [
|
||||||
|
["retreat", "Retreat"],
|
||||||
|
["class", "Class"],
|
||||||
|
["workshop", "Workshop"],
|
||||||
|
["meeting", "Meeting"],
|
||||||
|
["other", "Other"],
|
||||||
|
];
|
||||||
|
|
||||||
|
const EVENTS = { path: "preset", value: "events" };
|
||||||
|
|
||||||
|
const sectionsChild = (presets: string[]) => ({
|
||||||
|
key: "sections",
|
||||||
|
label: "Sections",
|
||||||
|
note: "Top to bottom. Each is listed in the page's side nav and the header's menu under its title.",
|
||||||
|
addLabel: "Add section",
|
||||||
|
title: (row) => row.title || "New section",
|
||||||
|
blank: { anchor: "", title: "", blurb: "", accent: "", preset: "", content_blocks: [] },
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
path: "title",
|
||||||
|
label: "Title",
|
||||||
|
required: true,
|
||||||
|
help: "Up to 30 characters, so it fits the side nav. eg. Mission, Vision & Values",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "anchor",
|
||||||
|
label: "URL ID",
|
||||||
|
required: true,
|
||||||
|
help: "The section's link after the #: lowercase letters, numbers and hyphens, eg. leadership",
|
||||||
|
},
|
||||||
|
{ path: "blurb", label: "Blurb", widget: "textarea", full: true, help: "A line under the title" },
|
||||||
|
{ path: "accent", label: "Accent", widget: "select", options: ACCENT_OPTIONS, blankLabel: "Default: Teal" },
|
||||||
|
...(presets.length
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
path: "preset",
|
||||||
|
label: "Preset",
|
||||||
|
widget: "select",
|
||||||
|
options: presets.map((key) => [key, PRESETS[key]]),
|
||||||
|
blankLabel: "Default: none, just the blocks below",
|
||||||
|
help: "A prebuilt part of the site, shown under the section's blocks",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
...(presets.includes("events")
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
path: "scope_id",
|
||||||
|
label: "Events: scope",
|
||||||
|
widget: "select",
|
||||||
|
optionsFrom: "event_scopes",
|
||||||
|
blankLabel: "Default: every scope",
|
||||||
|
when: EVENTS,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "event_type",
|
||||||
|
label: "Events: type",
|
||||||
|
widget: "select",
|
||||||
|
options: EVENT_TYPES,
|
||||||
|
blankLabel: "Default: every type",
|
||||||
|
when: EVENTS,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "view",
|
||||||
|
label: "Opens as",
|
||||||
|
widget: "select",
|
||||||
|
options: [["carousel", "Carousel"], ["grid", "Grid"]],
|
||||||
|
blankLabel: "Default: Carousel",
|
||||||
|
when: EVENTS,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
...(presets.includes("group_map")
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
path: "view",
|
||||||
|
label: "Opens as",
|
||||||
|
widget: "select",
|
||||||
|
options: [["map", "Map"], ["grid", "Grid"]],
|
||||||
|
blankLabel: "Default: Map",
|
||||||
|
when: { path: "preset", value: "group_map" },
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
],
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
...blocksChild,
|
||||||
|
label: "Blocks",
|
||||||
|
note: "The section's own content: headings, paragraphs, people, links, whatever it needs.",
|
||||||
|
fields: blocksChild.fields.filter((field) => field.path !== "slot"),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const sitePage = (id: string, label: string, presets: string[], more: Record<string, any> = {}) => ({
|
||||||
|
key: `${id}_page`,
|
||||||
|
label,
|
||||||
|
singular: label.toLowerCase(),
|
||||||
|
idLabel: "Page",
|
||||||
|
singleton: id,
|
||||||
|
|
||||||
|
list: { columns: [], filters: [] },
|
||||||
|
|
||||||
|
groups: [],
|
||||||
|
...more,
|
||||||
|
children: [sectionsChild(presets), ...(more.children ?? [])],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const communityPage = sitePage(
|
||||||
|
"community",
|
||||||
|
"Community page",
|
||||||
|
["community_blog", "group_map", "region_list", "partner_list"],
|
||||||
|
{
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
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.",
|
||||||
|
fields: [
|
||||||
|
{ path: "blog.internal_title", label: "Heading", help: "Default: From NGU" },
|
||||||
|
{ path: "blog.internal_slots", label: "Slots", widget: "number", help: "0 to 12. Default: 3" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
legend: "Community blog: community posts",
|
||||||
|
note: "Pinned cards first, then the newest items from the feeds below, up to the number of slots.",
|
||||||
|
fields: [
|
||||||
|
{ path: "blog.external_title", label: "Heading", help: "Default: From our community" },
|
||||||
|
{ path: "blog.external_slots", label: "Slots", widget: "number", help: "0 to 12. Default: 3" },
|
||||||
|
{ path: "blog.external_url", label: "Button link", help: "eg. https://ngu.substack.com", full: true },
|
||||||
|
{ path: "blog.external_label", label: "Button text", help: "Default: Read more on Substack" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: "pinned_posts",
|
||||||
|
label: "Community blog: pinned posts (ours)",
|
||||||
|
note: "Always shown, before the newest.",
|
||||||
|
addLabel: "Pin a post",
|
||||||
|
title: (row, options) =>
|
||||||
|
options?.blog_posts?.find((p) => p.id === row.post_id)?.label ?? "New pin",
|
||||||
|
blank: { post_id: "" },
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
path: "post_id",
|
||||||
|
label: "Post",
|
||||||
|
widget: "select",
|
||||||
|
optionsFrom: "blog_posts",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...featuredCardsChild,
|
||||||
|
label: "Community blog: pinned community posts",
|
||||||
|
note: "Always shown, before the feeds' newest. Paste a post's link and press Fetch preview.",
|
||||||
|
addLabel: "Pin a post",
|
||||||
|
blank: { kind: "", url: "", title: "" },
|
||||||
|
fields: featuredCardsChild.fields.map((field) =>
|
||||||
|
field.path === "kind"
|
||||||
|
? { ...field, options: FEATURED_KINDS.filter(([kind]) => kind !== "record") }
|
||||||
|
: field,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "feeds",
|
||||||
|
label: "Community blog: feeds",
|
||||||
|
note: "RSS or Atom feeds whose newest posts fill the community slots. Read about every 30 minutes.",
|
||||||
|
addLabel: "Add feed",
|
||||||
|
title: (row) => row.label || row.url || "New feed",
|
||||||
|
blank: { url: "", label: "" },
|
||||||
|
fields: [
|
||||||
|
{ path: "url", label: "Feed URL", required: true, full: true, help: "eg. https://ngu.substack.com/feed" },
|
||||||
|
{ 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", []);
|
||||||
|
export const organizationPage = sitePage("organization", "Organization page", ["organization_details"]);
|
||||||
|
export const historyPage = sitePage("history", "History page", ["timeline"]);
|
||||||
|
|
@ -2,15 +2,16 @@
|
||||||
NAV SECTIONS: the sections listed under each page in the header's
|
NAV SECTIONS: the sections listed under each page in the header's
|
||||||
dropdowns, the mobile menu and the footer's site map
|
dropdowns, the mobile menu and the footer's site map
|
||||||
|
|
||||||
The static pages' lists are PAGE_SECTIONS in navConfig.ts. The
|
Every page's list comes from the page itself, so adding, moving
|
||||||
front page's comes from the front page itself: the bands it is
|
or renaming a section changes the menus too: the site pages'
|
||||||
showing, in the admin's order, each under its heading (Front page
|
sections (Pages → each page, GET /site-pages), and the front
|
||||||
→ Sections), so hiding a band or renaming it changes the menus too.
|
page's bands it is showing, in the admin's order, each under its
|
||||||
|
heading (Front page → Sections).
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
|
|
||||||
import { PAGE_SECTIONS } from '../navConfig.ts'
|
import { useSitePageHeadings } from './useSitePages.ts'
|
||||||
import { useFrontPage } from './useFrontPage.ts'
|
import { useFrontPage } from './useFrontPage.ts'
|
||||||
import { FRONT_PAGE_BANDS, bandShows } from './frontPageBands.ts'
|
import { FRONT_PAGE_BANDS, bandShows } from './frontPageBands.ts'
|
||||||
|
|
||||||
|
|
@ -18,10 +19,16 @@ export type NavSection = { label: string; hash: string }
|
||||||
|
|
||||||
export function useNavSections(): (path: string) => NavSection[] {
|
export function useNavSections(): (path: string) => NavSection[] {
|
||||||
const { data: page } = useFrontPage()
|
const { data: page } = useFrontPage()
|
||||||
|
const { data: sitePages } = useSitePageHeadings()
|
||||||
|
|
||||||
return useCallback(
|
return useCallback(
|
||||||
(path: string) => {
|
(path: string) => {
|
||||||
if (path !== '/') return PAGE_SECTIONS[path] ?? []
|
if (path !== '/') {
|
||||||
|
return (sitePages?.[path.slice(1)] ?? []).map((section) => ({
|
||||||
|
label: section.title,
|
||||||
|
hash: `#${section.anchor}`,
|
||||||
|
}))
|
||||||
|
}
|
||||||
if (!page) return []
|
if (!page) return []
|
||||||
return page.sections.flatMap((section) => {
|
return page.sections.flatMap((section) => {
|
||||||
const band = FRONT_PAGE_BANDS[section.section]
|
const band = FRONT_PAGE_BANDS[section.section]
|
||||||
|
|
@ -29,6 +36,6 @@ export function useNavSections(): (path: string) => NavSection[] {
|
||||||
return [{ label: section.title || band.title, hash: `#${band.id}` }]
|
return [{ label: section.title || band.title, hash: `#${band.id}` }]
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[page],
|
[page, sitePages],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,17 @@
|
||||||
NEWSLETTER: email-ready HTML and plain text from picked items
|
NEWSLETTER: email-ready HTML and plain text from picked items
|
||||||
|
|
||||||
The admin's Newsletter tool (AdminNewsletter.tsx) gathers events,
|
The admin's Newsletter tool (AdminNewsletter.tsx) gathers events,
|
||||||
blog posts and featured cards; this turns them into one email to
|
blog posts and featured cards, with content blocks written for the
|
||||||
paste into Mailchimp, Gmail or Church Center. Nothing is sent or
|
issue; this turns them into one email to paste into Mailchimp,
|
||||||
stored here.
|
Gmail or Church Center. Nothing is sent from here.
|
||||||
|
|
||||||
|
Blocks draw as their email-safe equivalent: headings, paragraphs
|
||||||
|
(with **bold**, *italic* and [links](url)), callouts, quotes,
|
||||||
|
lists, link and button rows, images, cards and dividers; a video
|
||||||
|
is its still linked to the video. Schedules, tables and people,
|
||||||
|
which need the site, are left out.
|
||||||
|
|
||||||
|
No unsubscribe link: Mailchimp adds its own to every send.
|
||||||
|
|
||||||
Email clients ignore stylesheets, CSS variables and most layout,
|
Email clients ignore stylesheets, CSS variables and most layout,
|
||||||
so the HTML is tables with inline styles at 600px, images with
|
so the HTML is tables with inline styles at 600px, images with
|
||||||
|
|
@ -27,15 +35,32 @@ export type NewsletterItem = {
|
||||||
|
|
||||||
export type NewsletterSection = { heading: string; items: NewsletterItem[] }
|
export type NewsletterSection = { heading: string; items: NewsletterItem[] }
|
||||||
|
|
||||||
|
/* A content block as the block editor holds it. */
|
||||||
|
export type NewsletterBlock = {
|
||||||
|
type: string
|
||||||
|
text?: string | null
|
||||||
|
media?: string | null
|
||||||
|
href?: string | null
|
||||||
|
alt?: string | null
|
||||||
|
cite?: string | null
|
||||||
|
items?: Array<{ text?: string | null; detail?: string | null; url?: string | null; media?: string | null }>
|
||||||
|
}
|
||||||
|
|
||||||
export type Newsletter = {
|
export type Newsletter = {
|
||||||
title: string
|
title: string
|
||||||
intro?: string | null
|
intro?: string | null
|
||||||
|
/** Written for this issue, under the intro. */
|
||||||
|
blocks?: NewsletterBlock[]
|
||||||
sections: NewsletterSection[]
|
sections: NewsletterSection[]
|
||||||
|
/** The closing lines. Blank: the site's name and address. */
|
||||||
|
footer?: string | null
|
||||||
/** The site's address, for the header link and footer. */
|
/** The site's address, for the header link and footer. */
|
||||||
origin: string
|
origin: string
|
||||||
siteName: string
|
siteName: string
|
||||||
/** An absolute URL of the logo for the header. */
|
/** An absolute URL of the logo for the header. */
|
||||||
logo?: string | null
|
logo?: string | null
|
||||||
|
/** A site path or upload as an absolute address (blocks hold paths and bare filenames). */
|
||||||
|
absolute: (pathOrFile: string, kind: 'link' | 'image') => string
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The palette as an inbox needs it. */
|
/* The palette as an inbox needs it. */
|
||||||
|
|
@ -55,15 +80,148 @@ const BODY_FONT = "'Montserrat', Helvetica, Arial, sans-serif"
|
||||||
const escape = (value: string) =>
|
const escape = (value: string) =>
|
||||||
value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')
|
value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')
|
||||||
|
|
||||||
/* Paragraphs from text with blank lines between them. */
|
/* A link an email can follow: the site's own paths made absolute,
|
||||||
const paragraphs = (text: string, style: string) =>
|
anything but http, https and mailto refused. */
|
||||||
|
function safeHref(href: string, n: Newsletter): string | null {
|
||||||
|
const value = href.trim()
|
||||||
|
if (/^(https?:|mailto:)/i.test(value)) return value
|
||||||
|
if (value.startsWith('/')) return n.absolute(value, 'link')
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Escaped text with the editor's **bold**, *italic* and [text](url). */
|
||||||
|
function inline(text: string, n: Newsletter): string {
|
||||||
|
return escape(text)
|
||||||
|
.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (_whole, label, href) => {
|
||||||
|
const url = safeHref(href.replace(/&/g, '&'), n)
|
||||||
|
return url ? `<a href="${escape(url)}" style="color:${COLOR.teal};">${label}</a>` : label
|
||||||
|
})
|
||||||
|
.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
|
||||||
|
.replace(/\*([^*]+)\*/g, '<em>$1</em>')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Paragraphs from text with blank lines between them, formatted
|
||||||
|
when given the newsletter (its links need the site's address). */
|
||||||
|
const paragraphs = (text: string, style: string, n?: Newsletter) =>
|
||||||
text
|
text
|
||||||
.split(/\n\s*\n/)
|
.split(/\n\s*\n/)
|
||||||
.map((part) => part.trim())
|
.map((part) => part.trim())
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.map((part) => `<p style="${style}">${escape(part).replace(/\n/g, '<br>')}</p>`)
|
.map((part) => `<p style="${style}">${(n ? inline(part, n) : escape(part)).replace(/\n/g, '<br>')}</p>`)
|
||||||
.join('')
|
.join('')
|
||||||
|
|
||||||
|
const TEXT = `margin:12px 0 0;font-family:${BODY_FONT};font-size:15px;line-height:24px;color:${COLOR.body};`
|
||||||
|
const buttonHtml = (href: string, label: string) =>
|
||||||
|
`<a href="${escape(href)}" style="display:inline-block;margin:4px 8px 4px 0;padding:10px 20px;border-radius:8px;background:${COLOR.teal};color:#ffffff;font-family:${FONT};font-size:14px;font-weight:700;text-decoration:none;">${escape(label)}</a>`
|
||||||
|
|
||||||
|
function blockHtml(block: NewsletterBlock, n: Newsletter): string {
|
||||||
|
const text = block.text?.trim() ?? ''
|
||||||
|
const href = block.href ? safeHref(block.href, n) : null
|
||||||
|
const items = block.items ?? []
|
||||||
|
switch (block.type) {
|
||||||
|
case 'heading':
|
||||||
|
return text
|
||||||
|
? `<h2 style="margin:24px 0 0;font-family:${FONT};font-size:22px;line-height:28px;font-weight:700;color:${COLOR.teal};">${escape(text)}</h2>`
|
||||||
|
: ''
|
||||||
|
case 'subheading':
|
||||||
|
return text
|
||||||
|
? `<h3 style="margin:20px 0 0;font-family:${FONT};font-size:18px;line-height:24px;font-weight:700;color:${COLOR.ink};">${escape(text)}</h3>`
|
||||||
|
: ''
|
||||||
|
case 'paragraph':
|
||||||
|
return text ? paragraphs(text, TEXT, n) : ''
|
||||||
|
case 'callout':
|
||||||
|
return text ? `<div style="margin:16px 0 0;padding:4px 16px 16px;background:${COLOR.rule};">${paragraphs(text, TEXT, n)}</div>` : ''
|
||||||
|
case 'quote':
|
||||||
|
return text
|
||||||
|
? `<blockquote style="margin:16px 0 0;padding:0 0 0 16px;border-left:4px solid ${COLOR.teal};">${paragraphs(text, `${TEXT}font-style:italic;`, n)}${
|
||||||
|
block.cite ? `<p style="${TEXT}color:${COLOR.muted};">${escape(block.cite)}</p>` : ''
|
||||||
|
}</blockquote>`
|
||||||
|
: ''
|
||||||
|
case 'list':
|
||||||
|
return items.length
|
||||||
|
? `<ul style="margin:12px 0 0;padding-left:20px;font-family:${BODY_FONT};font-size:15px;line-height:24px;color:${COLOR.body};">${items
|
||||||
|
.map((item) => {
|
||||||
|
const url = item.url ? safeHref(item.url, n) : null
|
||||||
|
const label = escape(item.text ?? '')
|
||||||
|
const detail = item.detail ? `: ${escape(item.detail)}` : ''
|
||||||
|
return `<li>${url ? `<a href="${escape(url)}" style="color:${COLOR.teal};">${label}</a>` : label}${detail}</li>`
|
||||||
|
})
|
||||||
|
.join('')}</ul>`
|
||||||
|
: ''
|
||||||
|
case 'links': {
|
||||||
|
const buttons = items
|
||||||
|
.map((item) => (item.url ? safeHref(item.url, n) : null))
|
||||||
|
.map((url, i) => (url ? buttonHtml(url, items[i].text || url) : ''))
|
||||||
|
.join('')
|
||||||
|
return buttons ? `<p style="margin:16px 0 0;">${buttons}</p>` : ''
|
||||||
|
}
|
||||||
|
case 'button':
|
||||||
|
return href && text ? `<p style="margin:16px 0 0;">${buttonHtml(href, text)}</p>` : ''
|
||||||
|
case 'image':
|
||||||
|
case 'video': {
|
||||||
|
if (!block.media) return ''
|
||||||
|
const img = `<img src="${escape(n.absolute(block.media, 'image'))}" width="552" alt="${escape(block.alt ?? '')}" style="display:block;width:100%;max-width:552px;height:auto;border:0;">`
|
||||||
|
const caption = text
|
||||||
|
? `<p style="margin:6px 0 0;font-family:${BODY_FONT};font-size:13px;line-height:20px;color:${COLOR.muted};">${escape(text)}</p>`
|
||||||
|
: ''
|
||||||
|
return `<div style="margin:16px 0 0;">${href ? `<a href="${escape(href)}">${img}</a>` : img}${caption}</div>`
|
||||||
|
}
|
||||||
|
case 'cards':
|
||||||
|
return items
|
||||||
|
.map((item) => {
|
||||||
|
const url = item.url ? safeHref(item.url, n) : null
|
||||||
|
if (!url || !item.text) return ''
|
||||||
|
return `<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:16px 0 0;background:${COLOR.card};border-left:4px solid ${COLOR.teal};"><tr><td style="padding:16px 20px;">
|
||||||
|
<h3 style="margin:0;font-family:${FONT};font-size:18px;line-height:24px;font-weight:700;"><a href="${escape(url)}" style="color:${COLOR.ink};text-decoration:none;">${escape(item.text)}</a></h3>
|
||||||
|
${item.detail ? paragraphs(item.detail, TEXT) : ''}</td></tr></table>`
|
||||||
|
})
|
||||||
|
.join('')
|
||||||
|
case 'divider':
|
||||||
|
return `<hr style="margin:24px 0 0;border:0;border-top:2px solid ${COLOR.rule};">`
|
||||||
|
default:
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function blockText(block: NewsletterBlock, n: Newsletter): string[] {
|
||||||
|
const text = block.text?.trim() ?? ''
|
||||||
|
const items = block.items ?? []
|
||||||
|
const link = (url: string) => safeHref(url, n) ?? url
|
||||||
|
switch (block.type) {
|
||||||
|
case 'heading':
|
||||||
|
return text ? [text.toUpperCase(), ''] : []
|
||||||
|
case 'subheading':
|
||||||
|
case 'paragraph':
|
||||||
|
case 'callout':
|
||||||
|
case 'image':
|
||||||
|
return text ? [text, ''] : []
|
||||||
|
case 'quote':
|
||||||
|
return text ? [`"${text}"`, ...(block.cite ? [` ${block.cite}`] : []), ''] : []
|
||||||
|
case 'list':
|
||||||
|
return items.length
|
||||||
|
? [...items.map((item) => `- ${item.text ?? ''}${item.detail ? `: ${item.detail}` : ''}${item.url ? ` (${link(item.url)})` : ''}`), '']
|
||||||
|
: []
|
||||||
|
case 'links':
|
||||||
|
case 'cards': {
|
||||||
|
const lines = items.filter((item) => item.url).map((item) => `${item.text ?? ''}: ${link(item.url!)}`)
|
||||||
|
return lines.length ? [...lines, ''] : []
|
||||||
|
}
|
||||||
|
case 'button':
|
||||||
|
case 'video':
|
||||||
|
return block.href ? [`${text || 'Link'}: ${link(block.href)}`, ''] : []
|
||||||
|
case 'divider':
|
||||||
|
return ['---', '']
|
||||||
|
default:
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The closing lines: the admin's, or the site's name and address. */
|
||||||
|
const footerHtml = (n: Newsletter) =>
|
||||||
|
n.footer?.trim()
|
||||||
|
? paragraphs(n.footer, `margin:0 0 8px;font-family:${BODY_FONT};font-size:13px;line-height:20px;color:${COLOR.muted};`, n)
|
||||||
|
: `${escape(n.siteName)}<br><a href="${escape(n.origin)}" style="color:${COLOR.teal};">${escape(n.origin.replace(/^https?:\/\//, ''))}</a>`
|
||||||
|
|
||||||
function itemHtml(item: NewsletterItem): string {
|
function itemHtml(item: NewsletterItem): string {
|
||||||
const image = item.image
|
const image = item.image
|
||||||
? `<tr><td><a href="${escape(item.href)}"><img src="${escape(item.image)}" width="552" alt="" style="display:block;width:100%;max-width:552px;height:auto;border:0;"></a></td></tr>`
|
? `<tr><td><a href="${escape(item.href)}"><img src="${escape(item.image)}" width="552" alt="" style="display:block;width:100%;max-width:552px;height:auto;border:0;"></a></td></tr>`
|
||||||
|
|
@ -116,11 +274,12 @@ export function newsletterHtml(n: Newsletter): string {
|
||||||
<tr><td style="padding:20px 24px;background:${COLOR.body};">${logo}</td></tr>
|
<tr><td style="padding:20px 24px;background:${COLOR.body};">${logo}</td></tr>
|
||||||
<tr><td style="padding:28px 24px 8px;">
|
<tr><td style="padding:28px 24px 8px;">
|
||||||
<h1 style="margin:0;font-family:${FONT};font-size:28px;line-height:34px;font-weight:700;color:${COLOR.ink};">${escape(n.title)}</h1>
|
<h1 style="margin:0;font-family:${FONT};font-size:28px;line-height:34px;font-weight:700;color:${COLOR.ink};">${escape(n.title)}</h1>
|
||||||
${n.intro ? paragraphs(n.intro, `margin:12px 0 0;font-family:${BODY_FONT};font-size:16px;line-height:26px;color:${COLOR.body};`) : ''}
|
${n.intro ? paragraphs(n.intro, `margin:12px 0 0;font-family:${BODY_FONT};font-size:16px;line-height:26px;color:${COLOR.body};`, n) : ''}
|
||||||
|
${(n.blocks ?? []).map((block) => blockHtml(block, n)).join('')}
|
||||||
</td></tr>
|
</td></tr>
|
||||||
${sections}
|
${sections}
|
||||||
<tr><td style="padding:24px;border-top:2px solid ${COLOR.rule};font-family:${BODY_FONT};font-size:13px;line-height:20px;color:${COLOR.muted};">
|
<tr><td style="padding:24px;border-top:2px solid ${COLOR.rule};font-family:${BODY_FONT};font-size:13px;line-height:20px;color:${COLOR.muted};">
|
||||||
${escape(n.siteName)}<br><a href="${escape(n.origin)}" style="color:${COLOR.teal};">${escape(n.origin.replace(/^https?:\/\//, ''))}</a>
|
${footerHtml(n)}
|
||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
@ -132,6 +291,7 @@ export function newsletterHtml(n: Newsletter): string {
|
||||||
export function newsletterText(n: Newsletter): string {
|
export function newsletterText(n: Newsletter): string {
|
||||||
const lines = [n.title, '='.repeat(Math.min(n.title.length, 60)), '']
|
const lines = [n.title, '='.repeat(Math.min(n.title.length, 60)), '']
|
||||||
if (n.intro) lines.push(n.intro.trim(), '')
|
if (n.intro) lines.push(n.intro.trim(), '')
|
||||||
|
for (const block of n.blocks ?? []) lines.push(...blockText(block, n))
|
||||||
for (const section of n.sections) {
|
for (const section of n.sections) {
|
||||||
if (section.items.length === 0) continue
|
if (section.items.length === 0) continue
|
||||||
lines.push(section.heading.toUpperCase(), '')
|
lines.push(section.heading.toUpperCase(), '')
|
||||||
|
|
@ -142,6 +302,6 @@ export function newsletterText(n: Newsletter): string {
|
||||||
lines.push(`${item.cta}: ${item.href}`, '')
|
lines.push(`${item.cta}: ${item.href}`, '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lines.push('--', n.siteName, n.origin)
|
lines.push('--', ...(n.footer?.trim() ? [n.footer.trim()] : [n.siteName, n.origin]))
|
||||||
return lines.join('\n')
|
return lines.join('\n')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,6 @@ export type BlogPostSummary = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CommunityBlog = {
|
export type CommunityBlog = {
|
||||||
title?: string | null
|
|
||||||
blurb?: string | null
|
|
||||||
internal: { title?: string | null; posts: BlogPostSummary[] }
|
internal: { title?: string | null; posts: BlogPostSummary[] }
|
||||||
external: {
|
external: {
|
||||||
title?: string | null
|
title?: string | null
|
||||||
|
|
|
||||||
25
src/lib/useSitePages.ts
Normal file
25
src/lib/useSitePages.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* The site's own pages (Community, Retreats, Resources, Organization,
|
||||||
|
History), built in the admin from sections: GET /site-pages/:id
|
||||||
|
for one page's sections, GET /site-pages for every page's section
|
||||||
|
headings (the header's dropdowns, the footer, the side nav). */
|
||||||
|
|
||||||
|
import { useRecord, type Resource } from './useRecord.ts'
|
||||||
|
import type { ContentBlock } from './useContent.ts'
|
||||||
|
|
||||||
|
export type SitePageSection = {
|
||||||
|
anchor: string
|
||||||
|
title: string
|
||||||
|
blurb?: string | null
|
||||||
|
accent?: 'teal' | 'deep' | 'green' | 'amber' | null
|
||||||
|
preset?: string | null
|
||||||
|
scope_id?: string | null
|
||||||
|
event_type?: string | null
|
||||||
|
view?: string | null
|
||||||
|
blocks: ContentBlock[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useSitePage = (id: string): Resource<{ id: string; sections: SitePageSection[] }> =>
|
||||||
|
useRecord(`/site-pages/${id}`, 'page')
|
||||||
|
|
||||||
|
export const useSitePageHeadings = (): Resource<Record<string, Array<{ anchor: string; title: string }>>> =>
|
||||||
|
useRecord('/site-pages', 'pages')
|
||||||
|
|
@ -7,4 +7,4 @@
|
||||||
box or a build banner can read the same value later.
|
box or a build banner can read the same value later.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
export const SITE_VERSION = "NGU-Web.v1.10.5";
|
export const SITE_VERSION = "NGU-Web.v1.10.6";
|
||||||
|
|
|
||||||
|
|
@ -10,36 +10,6 @@ export const PAGE_LINKS = [
|
||||||
{ label: "History", path: "/history" },
|
{ label: "History", path: "/history" },
|
||||||
];
|
];
|
||||||
|
|
||||||
// Sections belong to a page, keyed by that page's path: the header's
|
|
||||||
// dropdowns, the mobile menu and the footer list them (navSections.ts).
|
|
||||||
// The front page's aren't here: they follow the bands it's showing.
|
|
||||||
export const PAGE_SECTIONS: Record<string, Array<{ label: string; hash: string }>> = {
|
|
||||||
"/retreats": [
|
|
||||||
{ label: "National", hash: "#national" },
|
|
||||||
{ label: "Regional", hash: "#regional" },
|
|
||||||
{ label: "Partner Events", hash: "#partner"},
|
|
||||||
],
|
|
||||||
"/community": [
|
|
||||||
{ label: "Community Blog", hash: "#blog" },
|
|
||||||
{ label: "Local Groups", hash: "#groups" },
|
|
||||||
{ label: "Unity Regions", hash: "#regions" },
|
|
||||||
{ label: "Partner Organizations", hash: "#partners" },
|
|
||||||
],
|
|
||||||
"/organization": [
|
|
||||||
{ label: "Mission & Values", hash: "#mission" },
|
|
||||||
{ label: "Leadership", hash: "#leadership" },
|
|
||||||
{ label: "Details & Contact", hash: "#contact" },
|
|
||||||
],
|
|
||||||
"/resources": [
|
|
||||||
{ label: "Unity Teachings", hash: "#unity" },
|
|
||||||
{ label: "Branding & Marketing", hash: "#branding" },
|
|
||||||
{ label: "Partner Resources", hash: "#partner" },
|
|
||||||
],
|
|
||||||
"/history": [
|
|
||||||
{ label: "Timeline", hash: "#timeline" },
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
// Right-side actions. `variant` picks the styling, not the destination.
|
// Right-side actions. `variant` picks the styling, not the destination.
|
||||||
export const NAV_ACTIONS = [
|
export const NAV_ACTIONS = [
|
||||||
{ label: "Contact Us", to: "/organization#contact", variant: "ghost" },
|
{ label: "Contact Us", to: "/organization#contact", variant: "ghost" },
|
||||||
|
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
import PageShell from "../components/PageShell.tsx";
|
|
||||||
import { sitePage } from "../lib/site.ts";
|
|
||||||
import { useSectionManifest } from "../lib/sections.tsx";
|
|
||||||
import OrgListMap, { OrgMapToggle } from "./sections/OrgList-Map.tsx";
|
|
||||||
import OrgListVertical from "./sections/OrgList-Vertical.tsx";
|
|
||||||
import OrgListCards from "./sections/OrgList-Card.tsx";
|
|
||||||
import CommunityBlog from "./sections/CommunityBlog.tsx";
|
|
||||||
import { useCommunityBlog } from "../lib/useBlog.ts";
|
|
||||||
import { ACCENTS, BRAND } from "../lib/color.ts"
|
|
||||||
|
|
||||||
/* Title and intro: site.json, which also gives the search metadata. */
|
|
||||||
const PAGE = sitePage("/community");
|
|
||||||
|
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
|
||||||
COMMUNITY PAGE
|
|
||||||
|
|
||||||
The blog first, then two views of the organizations table. The
|
|
||||||
map is filtered to groups; the vertical list is filtered to
|
|
||||||
regions. Same rows, same endpoint, different shape on the page.
|
|
||||||
|
|
||||||
The blog's heading and blurb are the admin's (Pages → Community blog
|
|
||||||
section), so that one entry is built here from the same cached
|
|
||||||
request CommunityBlog makes for its posts.
|
|
||||||
═══════════════════════════════════════════════════════════════ */
|
|
||||||
|
|
||||||
const BLOG_DEFAULT_TITLE = "Community Blog";
|
|
||||||
|
|
||||||
const SECTIONS = [
|
|
||||||
{
|
|
||||||
id: "groups",
|
|
||||||
title: "Local Groups",
|
|
||||||
blurb:
|
|
||||||
"Young adult groups meeting in person and online across the movement.",
|
|
||||||
accent: BRAND,
|
|
||||||
Component: OrgListMap,
|
|
||||||
request: { type: "group", label: "Add or update a group" },
|
|
||||||
views: { options: ["map", "grid"], default: "map", Toggle: OrgMapToggle },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "regions",
|
|
||||||
title: "Unity Regions",
|
|
||||||
blurb:
|
|
||||||
"The regional organizations that support groups and host their own gatherings.",
|
|
||||||
accent: "#3b5456",
|
|
||||||
Component: OrgListVertical,
|
|
||||||
request: { type: "region", label: "Request a region update" },
|
|
||||||
props: {
|
|
||||||
kind: "region",
|
|
||||||
pageLabel: "Region page",
|
|
||||||
groupBy: org => org.details?.scope,
|
|
||||||
groups: [
|
|
||||||
{ key: "domestic", title: "US Unity Regions" },
|
|
||||||
{ key: "international", title: "International Unity Regions" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "partners",
|
|
||||||
title: "Partner Organizations",
|
|
||||||
blurb:
|
|
||||||
"Organizations we collaborate with across the Unity movement and beyond.",
|
|
||||||
accent: ACCENTS.amber,
|
|
||||||
Component: OrgListCards,
|
|
||||||
request: { type: "partner", label: "Request a partner listing" },
|
|
||||||
props: {
|
|
||||||
kind: "partner",
|
|
||||||
pageLabel: "Partner page",
|
|
||||||
empty: "· Partner organizations coming soon ·",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export default function CommunityPage() {
|
|
||||||
const { data: blog } = useCommunityBlog();
|
|
||||||
|
|
||||||
const sections = useSectionManifest([
|
|
||||||
{
|
|
||||||
id: "blog",
|
|
||||||
title: blog?.title || BLOG_DEFAULT_TITLE,
|
|
||||||
blurb: blog?.blurb ?? undefined,
|
|
||||||
accent: BRAND,
|
|
||||||
Component: CommunityBlog,
|
|
||||||
request: { type: "blog", label: "Write for the blog" },
|
|
||||||
},
|
|
||||||
...SECTIONS,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PageShell
|
|
||||||
sideNav
|
|
||||||
title={PAGE.title}
|
|
||||||
intro={PAGE.description}
|
|
||||||
sections={sections}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
||||||
import PageShell from "../components/PageShell.tsx";
|
|
||||||
import { sitePage } from "../lib/site.ts";
|
|
||||||
import HistoryTimeline from "./sections/history/HistoryTimeline.tsx";
|
|
||||||
import { HISTORY_DECADES } from "../data/historyDecades.ts";
|
|
||||||
import { useHistory } from "../lib/useHistory.ts";
|
|
||||||
import { BRAND } from "../lib/color.ts"
|
|
||||||
|
|
||||||
/* Title and intro: site.json, which also gives the search metadata. */
|
|
||||||
const PAGE = sitePage("/history");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Year the program starts. Decades ending before this render with the
|
|
||||||
* pre-program treatment, so the gap moves if the founding date is ever
|
|
||||||
* corrected, no hardcoded 2000 anywhere in the components.
|
|
||||||
*/
|
|
||||||
const PROGRAM_START_YEAR = 2000;
|
|
||||||
|
|
||||||
const BACKGROUND = "var(--color-surface)";
|
|
||||||
|
|
||||||
export default function History() {
|
|
||||||
const { items, loading, error, reload } = useHistory();
|
|
||||||
|
|
||||||
// Section renders `content` outside its own max-width wrapper, so the
|
|
||||||
// container lives here. The custom properties bind the timeline to
|
|
||||||
// this section's accent and background, --tl-surface must match
|
|
||||||
// `background` or the rail will show through the year dots.
|
|
||||||
const wrap = (children: React.ReactNode) => (
|
|
||||||
<div
|
|
||||||
className="max-w-6xl mx-auto px-6"
|
|
||||||
style={{ "--tl-accent": BRAND, "--tl-surface": BACKGROUND } as React.CSSProperties}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
let content: React.ReactNode;
|
|
||||||
|
|
||||||
if (loading) {
|
|
||||||
content = wrap(
|
|
||||||
<p className="py-12 text-muted" role="status">
|
|
||||||
Loading the timeline…
|
|
||||||
</p>,
|
|
||||||
);
|
|
||||||
} else if (error) {
|
|
||||||
// Say what failed and offer the one action that might fix it.
|
|
||||||
// A history page that silently renders nothing looks like an
|
|
||||||
// organization with no history.
|
|
||||||
content = wrap(
|
|
||||||
<div className="py-12">
|
|
||||||
<p className="text-danger">Couldn’t load the timeline. {error}</p>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={reload}
|
|
||||||
className="mt-3 btn border border-brand px-4 py-1.5 text-sm text-link transition-colors hover:bg-tint"
|
|
||||||
>
|
|
||||||
Try again
|
|
||||||
</button>
|
|
||||||
</div>,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
content = wrap(
|
|
||||||
<HistoryTimeline
|
|
||||||
items={items}
|
|
||||||
decades={HISTORY_DECADES}
|
|
||||||
direction="desc"
|
|
||||||
programStartYear={PROGRAM_START_YEAR}
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PageShell
|
|
||||||
sideNav
|
|
||||||
title={PAGE.title}
|
|
||||||
intro={PAGE.description}
|
|
||||||
sections={[
|
|
||||||
{
|
|
||||||
id: "timeline",
|
|
||||||
title: "NGU Timeline",
|
|
||||||
blurb:
|
|
||||||
"Open a year to see what happened.",
|
|
||||||
accent: BRAND,
|
|
||||||
content,
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,153 +0,0 @@
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
|
||||||
ORGANIZATION: /organization
|
|
||||||
|
|
||||||
NGU itself, in three parts, edited in the admin as Pages →
|
|
||||||
Organization page (GET /organization-page):
|
|
||||||
|
|
||||||
mission Mission, Vision & Values: the page's mission blocks
|
|
||||||
leadership its leadership blocks, in order (a People block per
|
|
||||||
team: the Board of Trustees, then the Retreat Team),
|
|
||||||
then Volunteering: a title, a blurb and its links
|
|
||||||
contact NGU's address, nonprofit status and email
|
|
||||||
(src/data/organizationDetails.ts)
|
|
||||||
|
|
||||||
A section with nothing written yet says so (ComingSoon) rather
|
|
||||||
than showing a heading over nothing.
|
|
||||||
═══════════════════════════════════════════════════════════════ */
|
|
||||||
|
|
||||||
import PageShell from '../components/PageShell.tsx'
|
|
||||||
import ComingSoon from '../components/ComingSoon.tsx'
|
|
||||||
import ContentBlocks from '../components/ContentBlocks.tsx'
|
|
||||||
import HomeLink from './sections/home/HomeLink.tsx'
|
|
||||||
import { sitePage } from '../lib/site.ts'
|
|
||||||
import { useRecord } from '../lib/useRecord.ts'
|
|
||||||
import type { ContentBlock } from '../lib/useContent.ts'
|
|
||||||
import { ORGANIZATION_DETAILS } from '../data/organizationDetails.ts'
|
|
||||||
import { ACCENTS, BRAND } from '../lib/color.ts'
|
|
||||||
|
|
||||||
/* Title and intro: site.json, which also gives the search metadata. */
|
|
||||||
const PAGE = sitePage('/organization')
|
|
||||||
|
|
||||||
type OrganizationPage = {
|
|
||||||
mission_title?: string | null
|
|
||||||
mission_blocks: ContentBlock[]
|
|
||||||
leadership_title?: string | null
|
|
||||||
leadership_blurb?: string | null
|
|
||||||
leadership_blocks: ContentBlock[]
|
|
||||||
volunteer: { title?: string | null; blurb?: string | null; links: Array<{ label: string; url: string }> }
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Organization() {
|
|
||||||
const { data: page, loading, error } = useRecord<OrganizationPage>('/organization-page', 'page')
|
|
||||||
|
|
||||||
const pending = (what: string) =>
|
|
||||||
error ? (
|
|
||||||
<p className="mx-auto max-w-6xl px-6 text-danger">Couldn’t load {what} right now.</p>
|
|
||||||
) : loading || !page ? (
|
|
||||||
<div className="mx-auto max-w-6xl px-6">
|
|
||||||
<div className="skeleton !min-h-40" aria-label={`Loading ${what}`} />
|
|
||||||
</div>
|
|
||||||
) : null
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PageShell
|
|
||||||
title={PAGE.title}
|
|
||||||
intro={PAGE.description}
|
|
||||||
sideNav
|
|
||||||
sections={[
|
|
||||||
{
|
|
||||||
id: 'mission',
|
|
||||||
title: page?.mission_title || 'Mission, Vision & Values',
|
|
||||||
accent: BRAND,
|
|
||||||
content:
|
|
||||||
pending('our mission') ??
|
|
||||||
(page!.mission_blocks.length > 0 ? (
|
|
||||||
<div className="mx-auto max-w-6xl px-6">
|
|
||||||
<div className="max-w-3xl">
|
|
||||||
<ContentBlocks blocks={page!.mission_blocks} accent={BRAND} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<ComingSoon what="our mission, vision and values" />
|
|
||||||
)),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'leadership',
|
|
||||||
title: page?.leadership_title || 'Leadership',
|
|
||||||
blurb: page?.leadership_blurb ?? undefined,
|
|
||||||
accent: ACCENTS.green,
|
|
||||||
content: pending('our leadership') ?? <Leadership page={page!} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'contact',
|
|
||||||
title: 'Details & Contact',
|
|
||||||
accent: ACCENTS.deep,
|
|
||||||
content: <Contact />,
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function Leadership({ page }: { page: OrganizationPage }) {
|
|
||||||
const { volunteer } = page
|
|
||||||
const hasVolunteering = Boolean(volunteer.title || volunteer.blurb || volunteer.links.length)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="mx-auto max-w-6xl space-y-14 px-6">
|
|
||||||
{page.leadership_blocks.length > 0 ? (
|
|
||||||
<ContentBlocks blocks={page.leadership_blocks} accent={ACCENTS.green} />
|
|
||||||
) : (
|
|
||||||
<ComingSoon what="our leadership list" />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{hasVolunteering && (
|
|
||||||
<div className="max-w-3xl">
|
|
||||||
<h3 className="text-2xl font-bold text-ink">{volunteer.title || 'Volunteering'}</h3>
|
|
||||||
{volunteer.blurb && <p className="mt-2 leading-relaxed text-body">{volunteer.blurb}</p>}
|
|
||||||
{volunteer.links.length > 0 && (
|
|
||||||
<div className="mt-5 flex flex-wrap gap-3">
|
|
||||||
{volunteer.links.map((link) => (
|
|
||||||
<HomeLink
|
|
||||||
key={`${link.url}-${link.label}`}
|
|
||||||
url={link.url}
|
|
||||||
className="btn inline-block bg-action px-5 py-2.5 text-white transition-colors hover:bg-action-hover"
|
|
||||||
>
|
|
||||||
{link.label}
|
|
||||||
</HomeLink>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function Contact() {
|
|
||||||
const details = ORGANIZATION_DETAILS
|
|
||||||
return (
|
|
||||||
<div className="mx-auto grid max-w-6xl gap-8 px-6 md:grid-cols-2">
|
|
||||||
<div className="space-y-3 text-body">
|
|
||||||
<address className="not-italic leading-relaxed">
|
|
||||||
{details.street}
|
|
||||||
<br />
|
|
||||||
{details.cityLine}
|
|
||||||
<br />
|
|
||||||
<span className="text-sm text-muted">({details.addressNote})</span>
|
|
||||||
</address>
|
|
||||||
<p className="text-sm text-muted">
|
|
||||||
{details.nonprofit} Tax ID: {details.taxId}.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<a
|
|
||||||
href={`mailto:${details.email}`}
|
|
||||||
className="btn inline-block border border-link px-6 py-2.5 text-link transition-colors hover:bg-tint"
|
|
||||||
>
|
|
||||||
{details.email}
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
import PageShell from "../components/PageShell.tsx";
|
|
||||||
import ComingSoon from "../components/ComingSoon.tsx";
|
|
||||||
import { sitePage } from "../lib/site.ts";
|
|
||||||
import { ACCENTS, BRAND } from "../lib/color.ts"
|
|
||||||
|
|
||||||
/* Title and intro: site.json, which also gives the search metadata. */
|
|
||||||
const PAGE = sitePage("/resources");
|
|
||||||
|
|
||||||
const SECTIONS = [
|
|
||||||
{
|
|
||||||
id: "unity",
|
|
||||||
title: "Unity Teachings",
|
|
||||||
blurb: "Core principles, readings, and study material from the Unity movement.",
|
|
||||||
accent: BRAND,
|
|
||||||
content: <ComingSoon what="our Unity teachings" />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "branding",
|
|
||||||
title: "Branding & Marketing",
|
|
||||||
blurb: "Logos, colors, templates, and guidelines for representing NGU.",
|
|
||||||
accent: ACCENTS.green,
|
|
||||||
content: <ComingSoon what="our branding and marketing kit" />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "partner",
|
|
||||||
title: "Partner Resources",
|
|
||||||
blurb: "Material for the organizations we collaborate with.",
|
|
||||||
accent: ACCENTS.amber,
|
|
||||||
content: <ComingSoon what="resources for partners" />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export default function ResourcesPage() {
|
|
||||||
return (
|
|
||||||
<PageShell
|
|
||||||
sideNav
|
|
||||||
title={PAGE.title}
|
|
||||||
intro={PAGE.description}
|
|
||||||
sections={SECTIONS}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,121 +0,0 @@
|
||||||
import PageShell from "../components/PageShell.tsx";
|
|
||||||
import { sitePage } from "../lib/site.ts";
|
|
||||||
import { useSectionManifest } from "../lib/sections.tsx";
|
|
||||||
import EventListCards, { EventCardsToggle } from "./sections/EventList-Cards.tsx";
|
|
||||||
import { ACCENTS, BRAND } from "../lib/color.ts"
|
|
||||||
|
|
||||||
/* Title and intro: site.json, which also gives the search metadata. */
|
|
||||||
const PAGE = sitePage("/retreats");
|
|
||||||
|
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
|
||||||
RETREATS PAGE
|
|
||||||
|
|
||||||
Three bands, all the same view of the same table with a
|
|
||||||
different filter. The page declares them and does nothing else,
|
|
||||||
each section fetches its own slice.
|
|
||||||
|
|
||||||
Two filters per band now, and they answer different questions:
|
|
||||||
|
|
||||||
scope whose gathering it is. event_scopes holds six of
|
|
||||||
these; this page draws three.
|
|
||||||
type what kind of gathering it is. Pinned to "retreat"
|
|
||||||
everywhere on this page, which is what the page is
|
|
||||||
for and what lets "Partner" read as a heading rather
|
|
||||||
than a catch-all.
|
|
||||||
|
|
||||||
Because every band is pinned to one type, EventListCards finds a
|
|
||||||
single kind in each and draws no type chips. Drop the `type` from
|
|
||||||
a band and the chips appear on their own.
|
|
||||||
|
|
||||||
What this page deliberately does not show: local, international
|
|
||||||
and other scopes, and every non-retreat type. Those are reachable
|
|
||||||
from their host's page and by URL, and get a band here when
|
|
||||||
there's enough of them to fill one, see the block at the bottom.
|
|
||||||
|
|
||||||
To reorder the page, move a line. To add a different kind of
|
|
||||||
section, add an entry with another Component.
|
|
||||||
═══════════════════════════════════════════════════════════════ */
|
|
||||||
|
|
||||||
const CARD_VIEWS = { options: ["carousel", "grid"], Toggle: EventCardsToggle };
|
|
||||||
|
|
||||||
/* Pinned on every band. Named rather than repeated so turning this
|
|
||||||
page into "everything, filtered" later is one deletion. */
|
|
||||||
const RETREATS = { type: "retreat" };
|
|
||||||
|
|
||||||
const SECTIONS = [
|
|
||||||
{
|
|
||||||
id: "national",
|
|
||||||
title: "National Retreats",
|
|
||||||
blurb: "Our flagship gatherings, open to young adults across the country.",
|
|
||||||
accent: BRAND,
|
|
||||||
Component: EventListCards,
|
|
||||||
props: { scope: "national", ...RETREATS },
|
|
||||||
views: { ...CARD_VIEWS, default: "carousel" },
|
|
||||||
request: { type: "event", label: "Add or update an event" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "regional",
|
|
||||||
title: "Regional Retreats",
|
|
||||||
blurb: "Smaller gatherings hosted by regions throughout the year.",
|
|
||||||
accent: ACCENTS.green,
|
|
||||||
Component: EventListCards,
|
|
||||||
props: { scope: "regional", ...RETREATS },
|
|
||||||
views: { ...CARD_VIEWS, default: "grid" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "partner",
|
|
||||||
title: "Partner Events",
|
|
||||||
blurb: "Retreats hosted by organizations we collaborate with.",
|
|
||||||
accent: ACCENTS.amber,
|
|
||||||
Component: EventListCards,
|
|
||||||
props: { scope: "partner", ...RETREATS },
|
|
||||||
views: { ...CARD_VIEWS, default: "grid" },
|
|
||||||
},
|
|
||||||
|
|
||||||
/* The other three scopes, ready to uncomment. Each needs an accent
|
|
||||||
and a background of its own, those are presentation and live
|
|
||||||
here, not in event_scopes.
|
|
||||||
|
|
||||||
{
|
|
||||||
id: "local",
|
|
||||||
title: "Local Events",
|
|
||||||
blurb: "Hosted by individual groups.",
|
|
||||||
accent: ACCENTS.green,
|
|
||||||
Component: EventListCards,
|
|
||||||
props: { scope: "local", ...RETREATS_ONLY },
|
|
||||||
views: { ...CARD_VIEWS, default: "grid" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "international",
|
|
||||||
title: "International Events",
|
|
||||||
blurb: "Gatherings beyond the US.",
|
|
||||||
accent: ACCENTS.deep,
|
|
||||||
Component: EventListCards,
|
|
||||||
props: { scope: "international", ...RETREATS_ONLY },
|
|
||||||
views: { ...CARD_VIEWS, default: "grid" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "other",
|
|
||||||
title: "Other Events",
|
|
||||||
blurb: "Everything that doesn't fit the categories above.",
|
|
||||||
accent: ACCENTS.amber,
|
|
||||||
Component: EventListCards,
|
|
||||||
props: { scope: "other", ...RETREATS_ONLY },
|
|
||||||
views: { ...CARD_VIEWS, default: "grid" },
|
|
||||||
},
|
|
||||||
|
|
||||||
*/
|
|
||||||
];
|
|
||||||
|
|
||||||
export default function RetreatsPage() {
|
|
||||||
const sections = useSectionManifest(SECTIONS);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PageShell
|
|
||||||
sideNav
|
|
||||||
title={PAGE.title}
|
|
||||||
intro={PAGE.description}
|
|
||||||
sections={sections}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
216
src/pages/SitePage.tsx
Normal file
216
src/pages/SitePage.tsx
Normal file
|
|
@ -0,0 +1,216 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
SITE PAGE: /community, /retreats, /resources, /organization,
|
||||||
|
/history
|
||||||
|
|
||||||
|
Each is a list of sections built in the admin (Pages → the page,
|
||||||
|
GET /site-pages/:id). A section is its heading, then its own
|
||||||
|
content blocks, then its preset if it has one: a prebuilt part of
|
||||||
|
the site, from PRESETS below. A section with neither says it's
|
||||||
|
coming (ComingSoon) rather than showing a heading over nothing.
|
||||||
|
|
||||||
|
The title and intro are site.json's, which also gives the search
|
||||||
|
metadata.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { useEffect } from 'react'
|
||||||
|
import { useLocation } from 'react-router-dom'
|
||||||
|
|
||||||
|
import PageShell from '../components/PageShell.tsx'
|
||||||
|
import ComingSoon from '../components/ComingSoon.tsx'
|
||||||
|
import ContentBlocks from '../components/ContentBlocks.tsx'
|
||||||
|
import { sitePage } from '../lib/site.ts'
|
||||||
|
import { useSectionManifest } from '../lib/sections.tsx'
|
||||||
|
import { useSitePage, type SitePageSection } from '../lib/useSitePages.ts'
|
||||||
|
import { useHistory } from '../lib/useHistory.ts'
|
||||||
|
import { ORGANIZATION_DETAILS } from '../data/organizationDetails.ts'
|
||||||
|
import { HISTORY_DECADES } from '../data/historyDecades.ts'
|
||||||
|
import { ACCENTS, BRAND } from '../lib/color.ts'
|
||||||
|
import { scrollBehavior } from '../lib/motion.ts'
|
||||||
|
import OrgListMap, { OrgMapToggle } from './sections/OrgList-Map.tsx'
|
||||||
|
import OrgListVertical from './sections/OrgList-Vertical.tsx'
|
||||||
|
import OrgListCards from './sections/OrgList-Card.tsx'
|
||||||
|
import EventListCards, { EventCardsToggle } from './sections/EventList-Cards.tsx'
|
||||||
|
import CommunityBlog from './sections/CommunityBlog.tsx'
|
||||||
|
import HistoryTimeline from './sections/history/HistoryTimeline.tsx'
|
||||||
|
|
||||||
|
/* Year the program starts: decades ending before it get the
|
||||||
|
pre-program look on the timeline. */
|
||||||
|
const PROGRAM_START_YEAR = 2000
|
||||||
|
|
||||||
|
/* Each preset: the view it draws, its fixed props, its toggle (the
|
||||||
|
section's own view picks the first one) and its Request button.
|
||||||
|
The keys are the CHECK list on page_sections.preset. */
|
||||||
|
const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>> = {
|
||||||
|
community_blog: () => ({
|
||||||
|
Component: CommunityBlog,
|
||||||
|
request: { type: 'blog', label: 'Write for the blog' },
|
||||||
|
}),
|
||||||
|
group_map: (section) => ({
|
||||||
|
Component: OrgListMap,
|
||||||
|
request: { type: 'group', label: 'Add or update a group' },
|
||||||
|
views: { options: ['map', 'grid'], default: section.view === 'grid' ? 'grid' : 'map', Toggle: OrgMapToggle },
|
||||||
|
}),
|
||||||
|
region_list: () => ({
|
||||||
|
Component: OrgListVertical,
|
||||||
|
request: { type: 'region', label: 'Request a region update' },
|
||||||
|
props: {
|
||||||
|
kind: 'region',
|
||||||
|
pageLabel: 'Region page',
|
||||||
|
groupBy: (org: any) => org.details?.scope,
|
||||||
|
groups: [
|
||||||
|
{ key: 'domestic', title: 'US Unity Regions' },
|
||||||
|
{ key: 'international', title: 'International Unity Regions' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
partner_list: () => ({
|
||||||
|
Component: OrgListCards,
|
||||||
|
request: { type: 'partner', label: 'Request a partner listing' },
|
||||||
|
props: { kind: 'partner', pageLabel: 'Partner page', empty: '· Partner organizations coming soon ·' },
|
||||||
|
}),
|
||||||
|
events: (section) => ({
|
||||||
|
Component: EventListCards,
|
||||||
|
request: { type: 'event', label: 'Add or update an event' },
|
||||||
|
props: { scope: section.scope_id ?? undefined, type: section.event_type ?? undefined },
|
||||||
|
views: {
|
||||||
|
options: ['carousel', 'grid'],
|
||||||
|
default: section.view === 'grid' ? 'grid' : 'carousel',
|
||||||
|
Toggle: EventCardsToggle,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
timeline: () => ({ Component: Timeline }),
|
||||||
|
organization_details: () => ({ Component: OrganizationDetails }),
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function SitePage({ id }: { id: string }) {
|
||||||
|
const PAGE = sitePage(`/${id}`)
|
||||||
|
const { data: page, loading, error } = useSitePage(id)
|
||||||
|
|
||||||
|
if (page) return <Sections title={PAGE.title} intro={PAGE.description} sections={page.sections} />
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<PageShell title={PAGE.title} intro={PAGE.description} sections={[]} />
|
||||||
|
<div className="mx-auto max-w-6xl px-6 py-20">
|
||||||
|
{error ? (
|
||||||
|
<p className="text-danger">Couldn’t load this page right now.</p>
|
||||||
|
) : (
|
||||||
|
loading && <div className="skeleton !min-h-40" aria-label="Loading the page" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Its own component so the manifest, which seeds each toggle's view
|
||||||
|
once, sees the loaded sections. */
|
||||||
|
function Sections({ title, intro, sections }: { title: string; intro?: string; sections: SitePageSection[] }) {
|
||||||
|
// Layout scrolls to a link's #section on arrival, before the
|
||||||
|
// sections have loaded; this does it again once they're here.
|
||||||
|
const { hash } = useLocation()
|
||||||
|
useEffect(() => {
|
||||||
|
if (hash) document.getElementById(decodeURIComponent(hash.slice(1)))?.scrollIntoView({ behavior: scrollBehavior() })
|
||||||
|
}, [hash])
|
||||||
|
|
||||||
|
const manifest = useSectionManifest(
|
||||||
|
sections.map((section) => {
|
||||||
|
const accent = ACCENTS[section.accent ?? 'teal'] ?? BRAND
|
||||||
|
const preset = section.preset ? PRESETS[section.preset]?.(section) : null
|
||||||
|
return {
|
||||||
|
id: section.anchor,
|
||||||
|
title: section.title,
|
||||||
|
blurb: section.blurb ?? undefined,
|
||||||
|
accent,
|
||||||
|
...preset,
|
||||||
|
// Blocks, then the preset under them.
|
||||||
|
Component: SectionBody,
|
||||||
|
props: { blocks: section.blocks, title: section.title, Preset: preset?.Component, presetProps: preset?.props },
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
return <PageShell sideNav title={title} intro={intro} sections={manifest} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function SectionBody({ blocks, title, Preset, presetProps, ...rest }: any) {
|
||||||
|
if (!blocks.length && !Preset) return <ComingSoon what={`our ${title}`} />
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{blocks.length > 0 && (
|
||||||
|
<div className={`mx-auto max-w-6xl px-6 ${Preset ? 'mb-12' : ''}`}>
|
||||||
|
<ContentBlocks blocks={blocks} accent={rest.accent} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{Preset && <Preset {...presetProps} {...rest} />}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Timeline({ accent = BRAND }: { accent?: string }) {
|
||||||
|
const { items, loading, error, reload } = useHistory()
|
||||||
|
|
||||||
|
// The custom properties bind the timeline to this section's accent
|
||||||
|
// and the page's surface, which the rail must match or it shows
|
||||||
|
// through the year dots.
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="mx-auto max-w-6xl px-6"
|
||||||
|
style={{ '--tl-accent': accent, '--tl-surface': 'var(--color-surface)' } as React.CSSProperties}
|
||||||
|
>
|
||||||
|
{loading ? (
|
||||||
|
<p className="py-12 text-muted" role="status">
|
||||||
|
Loading the timeline…
|
||||||
|
</p>
|
||||||
|
) : error ? (
|
||||||
|
// A history page that silently renders nothing looks like an
|
||||||
|
// organization with no history: say so, and offer a retry.
|
||||||
|
<div className="py-12">
|
||||||
|
<p className="text-danger">Couldn’t load the timeline. {error}</p>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={reload}
|
||||||
|
className="btn mt-3 border border-brand px-4 py-1.5 text-sm text-link transition-colors hover:bg-tint"
|
||||||
|
>
|
||||||
|
Try again
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<HistoryTimeline
|
||||||
|
items={items}
|
||||||
|
decades={HISTORY_DECADES}
|
||||||
|
direction="desc"
|
||||||
|
programStartYear={PROGRAM_START_YEAR}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* NGU's address, nonprofit status and email (src/data/organizationDetails.ts). */
|
||||||
|
function OrganizationDetails() {
|
||||||
|
const details = ORGANIZATION_DETAILS
|
||||||
|
return (
|
||||||
|
<div className="mx-auto grid max-w-6xl gap-8 px-6 md:grid-cols-2">
|
||||||
|
<div className="space-y-3 text-body">
|
||||||
|
<address className="not-italic leading-relaxed">
|
||||||
|
{details.street}
|
||||||
|
<br />
|
||||||
|
{details.cityLine}
|
||||||
|
<br />
|
||||||
|
<span className="text-sm text-muted">({details.addressNote})</span>
|
||||||
|
</address>
|
||||||
|
<p className="text-sm text-muted">
|
||||||
|
{details.nonprofit} Tax ID: {details.taxId}.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a
|
||||||
|
href={`mailto:${details.email}`}
|
||||||
|
className="btn inline-block border border-link px-6 py-2.5 text-link transition-colors hover:bg-tint"
|
||||||
|
>
|
||||||
|
{details.email}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -3,10 +3,15 @@
|
||||||
|
|
||||||
Builds an email newsletter from what's already on the site: tick
|
Builds an email newsletter from what's already on the site: tick
|
||||||
upcoming events, published blog posts and the front page's
|
upcoming events, published blog posts and the front page's
|
||||||
featured cards, write a title and an intro, and copy the result,
|
featured cards, write a title, an intro, content blocks and a
|
||||||
email-ready HTML or plain text, into Mailchimp, Gmail or Church
|
footer, and copy the result, email-ready HTML or plain text, into
|
||||||
Center (or download it as a file). Nothing is sent or saved here;
|
Mailchimp, Gmail or Church Center (or download it as a file).
|
||||||
the builder is src/lib/newsletter.ts.
|
Nothing is sent from here; the builder is src/lib/newsletter.ts.
|
||||||
|
|
||||||
|
Drafts are saved (the newsletters entity, 057_newsletters.sql),
|
||||||
|
to finish later or send again, and a draft can become an
|
||||||
|
unpublished blog post: its intro, blocks and picks as the post's
|
||||||
|
body, opened in the post's editor to finish.
|
||||||
|
|
||||||
Picked blog posts are read from their public pages, so only a
|
Picked blog posts are read from their public pages, so only a
|
||||||
post visitors can open makes it in, with its excerpt and cover.
|
post visitors can open makes it in, with its excerpt and cover.
|
||||||
|
|
@ -14,10 +19,16 @@
|
||||||
email is read far from this admin.
|
email is read far from this admin.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { Check, Copy, DownloadSimple } from '@phosphor-icons/react'
|
import { Article, Check, Copy, DownloadSimple, FloppyDisk, Trash } from '@phosphor-icons/react'
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
import { useEffect, useMemo, useState } from 'react'
|
||||||
|
import { useNavigate } from 'react-router-dom'
|
||||||
|
|
||||||
import { get } from '../../lib/api.ts'
|
import { ApiError, del, get, patch, post } from '../../lib/api.ts'
|
||||||
|
import { useAuth } from '../../lib/auth.tsx'
|
||||||
|
import { canDelete, canWrite } from '../../lib/roles.ts'
|
||||||
|
import { slugify } from '../../lib/adminSchema.ts'
|
||||||
|
import { blocksChild } from '../../lib/adminSchema/shared.ts'
|
||||||
|
import { Repeater } from '../../components/admin/fields.tsx'
|
||||||
import { useEvents } from '../../lib/eventData.ts'
|
import { useEvents } from '../../lib/eventData.ts'
|
||||||
import { useFrontPage, type FeaturedCard } from '../../lib/useFrontPage.ts'
|
import { useFrontPage, type FeaturedCard } from '../../lib/useFrontPage.ts'
|
||||||
import type { BlogPostRecord } from '../../lib/useBlog.ts'
|
import type { BlogPostRecord } from '../../lib/useBlog.ts'
|
||||||
|
|
@ -26,7 +37,13 @@ import { mediaUrl } from '../../lib/media.ts'
|
||||||
import { SITE_NAME, SITE_ORIGIN, siteUrl } from '../../lib/site.ts'
|
import { SITE_NAME, SITE_ORIGIN, siteUrl } from '../../lib/site.ts'
|
||||||
import { seriesLabel } from '../../lib/eventSeries.ts'
|
import { seriesLabel } from '../../lib/eventSeries.ts'
|
||||||
import { useWideAdminPage } from '../../lib/adminWidth.tsx'
|
import { useWideAdminPage } from '../../lib/adminWidth.tsx'
|
||||||
import { newsletterHtml, newsletterText, type NewsletterItem } from '../../lib/newsletter.ts'
|
import {
|
||||||
|
newsletterHtml,
|
||||||
|
newsletterText,
|
||||||
|
type NewsletterBlock,
|
||||||
|
type NewsletterItem,
|
||||||
|
type NewsletterSection,
|
||||||
|
} from '../../lib/newsletter.ts'
|
||||||
|
|
||||||
const MUTED = 'var(--color-muted)'
|
const MUTED = 'var(--color-muted)'
|
||||||
const input =
|
const input =
|
||||||
|
|
@ -39,6 +56,25 @@ const absolute = (path: string | null | undefined) => (path ? siteUrl(path) : nu
|
||||||
const imageFor = (file: string | null | undefined) => absolute(mediaUrl(file))
|
const imageFor = (file: string | null | undefined) => absolute(mediaUrl(file))
|
||||||
|
|
||||||
type PostRow = { id: string; title: string; published_on?: string | null; is_published: number; is_listed: number }
|
type PostRow = { id: string; title: string; published_on?: string | null; is_published: number; is_listed: number }
|
||||||
|
type DraftRow = { id: number; title?: string | null; updated_at: string }
|
||||||
|
type Picks = { events?: string[]; posts?: string[]; cards?: string[] }
|
||||||
|
|
||||||
|
/* The block types an email can show (newsletter.ts draws them);
|
||||||
|
schedules, tables and people need the site. */
|
||||||
|
const EMAIL_BLOCKS = ['paragraph', 'heading', 'subheading', 'callout', 'quote', 'list', 'links', 'button', 'image', 'video', 'cards', 'divider']
|
||||||
|
const BLOCKS_SPEC = {
|
||||||
|
...blocksChild,
|
||||||
|
label: 'Blocks',
|
||||||
|
note: 'Written for this issue, under the intro. A video shows as its still, linked to the video.',
|
||||||
|
fields: blocksChild.fields
|
||||||
|
.filter((field) => field.path !== 'slot')
|
||||||
|
.map((field) =>
|
||||||
|
field.path === 'type' ? { ...field, options: (field.options ?? []).filter(([type]) => EMAIL_BLOCKS.includes(type)) } : field,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A site path or upload on the live site, for the email. */
|
||||||
|
const absoluteFor = (value: string, kind: 'link' | 'image') => (kind === 'image' ? imageFor(value) ?? value : siteUrl(value))
|
||||||
|
|
||||||
function featuredHref(card: FeaturedCard): string | null {
|
function featuredHref(card: FeaturedCard): string | null {
|
||||||
if (card.kind === 'record' && card.ref) return refHref(card.ref.kind, card.ref.id, card.ref.org_kind)
|
if (card.kind === 'record' && card.ref) return refHref(card.ref.kind, card.ref.id, card.ref.org_kind)
|
||||||
|
|
@ -47,15 +83,27 @@ function featuredHref(card: FeaturedCard): string | null {
|
||||||
|
|
||||||
export default function AdminNewsletter() {
|
export default function AdminNewsletter() {
|
||||||
useWideAdminPage()
|
useWideAdminPage()
|
||||||
|
const navigate = useNavigate()
|
||||||
|
const { user } = useAuth()
|
||||||
const [title, setTitle] = useState('')
|
const [title, setTitle] = useState('')
|
||||||
const [intro, setIntro] = useState('')
|
const [intro, setIntro] = useState('')
|
||||||
|
const [footer, setFooter] = useState('')
|
||||||
|
const [blocks, setBlocks] = useState<NewsletterBlock[]>([])
|
||||||
const [pickedEvents, setPickedEvents] = useState<Set<string>>(new Set())
|
const [pickedEvents, setPickedEvents] = useState<Set<string>>(new Set())
|
||||||
const [pickedPosts, setPickedPosts] = useState<Set<string>>(new Set())
|
const [pickedPosts, setPickedPosts] = useState<Set<string>>(new Set())
|
||||||
const [pickedCards, setPickedCards] = useState<Set<number>>(new Set())
|
// Cards by their link: the front page's cards can be reordered
|
||||||
|
// between one save and the next.
|
||||||
|
const [pickedCards, setPickedCards] = useState<Set<string>>(new Set())
|
||||||
const [posts, setPosts] = useState<PostRow[] | null>(null)
|
const [posts, setPosts] = useState<PostRow[] | null>(null)
|
||||||
const [postDetails, setPostDetails] = useState<Record<string, BlogPostRecord>>({})
|
const [postDetails, setPostDetails] = useState<Record<string, BlogPostRecord>>({})
|
||||||
const [copied, setCopied] = useState<'html' | 'text' | null>(null)
|
const [copied, setCopied] = useState<'html' | 'text' | null>(null)
|
||||||
|
|
||||||
|
// The draft being edited: null is a new one, not saved yet.
|
||||||
|
const [drafts, setDrafts] = useState<DraftRow[]>([])
|
||||||
|
const [draft, setDraft] = useState<{ id: number; updated_at: string } | null>(null)
|
||||||
|
const [busy, setBusy] = useState(false)
|
||||||
|
const [message, setMessage] = useState<{ tone: 'ok' | 'error'; text: string } | null>(null)
|
||||||
|
|
||||||
const { events, loading: eventsLoading } = useEvents({ status: 'upcoming' })
|
const { events, loading: eventsLoading } = useEvents({ status: 'upcoming' })
|
||||||
const { data: frontPage } = useFrontPage()
|
const { data: frontPage } = useFrontPage()
|
||||||
const cards = frontPage?.featured ?? []
|
const cards = frontPage?.featured ?? []
|
||||||
|
|
@ -66,6 +114,124 @@ export default function AdminNewsletter() {
|
||||||
.catch(() => setPosts([]))
|
.catch(() => setPosts([]))
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
const loadDrafts = () =>
|
||||||
|
get('/admin/newsletters?limit=100', { ttl: 0 })
|
||||||
|
.then((data: { rows: DraftRow[] }) => setDrafts(data.rows))
|
||||||
|
.catch(() => setDrafts([]))
|
||||||
|
useEffect(() => {
|
||||||
|
loadDrafts()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
function fill(row: any) {
|
||||||
|
let picks: Picks = {}
|
||||||
|
try {
|
||||||
|
picks = JSON.parse(row?.picks || '{}')
|
||||||
|
} catch {
|
||||||
|
// A hand-edited draft: start its picks over.
|
||||||
|
}
|
||||||
|
setDraft(row ? { id: row.id, updated_at: row.updated_at } : null)
|
||||||
|
setTitle(row?.title ?? '')
|
||||||
|
setIntro(row?.intro ?? '')
|
||||||
|
setFooter(row?.footer ?? '')
|
||||||
|
setBlocks(row?.content_blocks ?? [])
|
||||||
|
setPickedEvents(new Set(picks.events ?? []))
|
||||||
|
setPickedPosts(new Set(picks.posts ?? []))
|
||||||
|
setPickedCards(new Set(picks.cards ?? []))
|
||||||
|
}
|
||||||
|
|
||||||
|
async function openDraft(id: string) {
|
||||||
|
setMessage(null)
|
||||||
|
if (!id) return fill(null)
|
||||||
|
try {
|
||||||
|
const data = await get(`/admin/newsletters/${id}`, { ttl: 0 })
|
||||||
|
fill(data.row)
|
||||||
|
} catch (err) {
|
||||||
|
setMessage({ tone: 'error', text: err instanceof Error ? err.message : 'Couldn’t open that draft.' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
setBusy(true)
|
||||||
|
setMessage(null)
|
||||||
|
const payload = {
|
||||||
|
title: title.trim(),
|
||||||
|
intro: intro.trim(),
|
||||||
|
footer: footer.trim(),
|
||||||
|
picks: JSON.stringify({ events: [...pickedEvents], posts: [...pickedPosts], cards: [...pickedCards] }),
|
||||||
|
content_blocks: blocks.map((block) => ({ ...block, slot: 'body' })),
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const data = draft
|
||||||
|
? await patch(`/admin/newsletters/${draft.id}`, { ...payload, updated_at: draft.updated_at })
|
||||||
|
: await post('/admin/newsletters', payload)
|
||||||
|
fill(data.row)
|
||||||
|
loadDrafts()
|
||||||
|
setMessage({ tone: 'ok', text: 'Draft saved.' })
|
||||||
|
} catch (err) {
|
||||||
|
const fields = err instanceof ApiError && err.fields ? Object.values(err.fields).filter(Boolean).join(' ') : ''
|
||||||
|
setMessage({ tone: 'error', text: [err instanceof Error ? err.message : 'Couldn’t save.', fields].filter(Boolean).join(' ') })
|
||||||
|
} finally {
|
||||||
|
setBusy(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function remove() {
|
||||||
|
if (!draft || !window.confirm('Delete this draft? This can’t be undone.')) return
|
||||||
|
setBusy(true)
|
||||||
|
try {
|
||||||
|
await del(`/admin/newsletters/${draft.id}`)
|
||||||
|
fill(null)
|
||||||
|
loadDrafts()
|
||||||
|
setMessage({ tone: 'ok', text: 'Draft deleted.' })
|
||||||
|
} catch (err) {
|
||||||
|
setMessage({ tone: 'error', text: err instanceof Error ? err.message : 'Couldn’t delete.' })
|
||||||
|
} finally {
|
||||||
|
setBusy(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* An unpublished blog post from what's built: the intro, the
|
||||||
|
blocks, then each section's picks as a heading and link cards.
|
||||||
|
It opens in the post's editor to finish and publish. */
|
||||||
|
async function postAsBlog() {
|
||||||
|
setBusy(true)
|
||||||
|
setMessage(null)
|
||||||
|
const postTitle = newsletter.content.title
|
||||||
|
const id = `${slugify(postTitle).slice(0, 52) || 'newsletter'}-${new Date().toISOString().slice(0, 10)}`
|
||||||
|
const body = [
|
||||||
|
...(intro.trim() ? [{ type: 'paragraph', text: intro.trim() }] : []),
|
||||||
|
...blocks,
|
||||||
|
...newsletter.content.sections
|
||||||
|
.filter((section) => section.items.length > 0)
|
||||||
|
.flatMap((section) => [
|
||||||
|
{ type: 'heading', text: section.heading },
|
||||||
|
{
|
||||||
|
type: 'cards',
|
||||||
|
items: section.items.map((item) => ({
|
||||||
|
text: item.title,
|
||||||
|
detail: [item.meta, item.text].filter(Boolean).join('\n\n') || null,
|
||||||
|
url: item.href,
|
||||||
|
media: item.image ?? null,
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
].map((block) => ({ ...block, slot: 'body' }))
|
||||||
|
try {
|
||||||
|
await post('/admin/blog_posts', {
|
||||||
|
id,
|
||||||
|
title: postTitle,
|
||||||
|
excerpt: intro.trim() || null,
|
||||||
|
is_published: false,
|
||||||
|
content_blocks: body,
|
||||||
|
})
|
||||||
|
navigate(`/admin/blog_posts/${id}`)
|
||||||
|
} catch (err) {
|
||||||
|
const fields = err instanceof ApiError && err.fields ? Object.values(err.fields).filter(Boolean).join(' ') : ''
|
||||||
|
setMessage({ tone: 'error', text: [err instanceof Error ? err.message : 'Couldn’t make the post.', fields].filter(Boolean).join(' ') })
|
||||||
|
setBusy(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// A picked post's public page: its excerpt and cover, and proof it's live.
|
// A picked post's public page: its excerpt and cover, and proof it's live.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
for (const id of pickedPosts) {
|
for (const id of pickedPosts) {
|
||||||
|
|
@ -113,8 +279,8 @@ export default function AdminNewsletter() {
|
||||||
})
|
})
|
||||||
|
|
||||||
const cardItems: NewsletterItem[] = cards
|
const cardItems: NewsletterItem[] = cards
|
||||||
.map((card, index) => ({ card, index, href: featuredHref(card) }))
|
.map((card) => ({ card, href: featuredHref(card) }))
|
||||||
.filter(({ index, href }) => pickedCards.has(index) && href)
|
.filter(({ href }) => href && pickedCards.has(href))
|
||||||
.map(({ card, href }) => ({
|
.map(({ card, href }) => ({
|
||||||
title: card.title ?? 'Featured',
|
title: card.title ?? 'Featured',
|
||||||
meta: card.eyebrow ?? null,
|
meta: card.eyebrow ?? null,
|
||||||
|
|
@ -124,22 +290,31 @@ export default function AdminNewsletter() {
|
||||||
cta: card.kind === 'video' ? 'Watch' : 'Learn more',
|
cta: card.kind === 'video' ? 'Watch' : 'Learn more',
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const content = {
|
const sections: NewsletterSection[] = [
|
||||||
title: title.trim() || `News from ${SITE_NAME}`,
|
|
||||||
intro: intro.trim() || null,
|
|
||||||
origin: SITE_ORIGIN,
|
|
||||||
siteName: SITE_NAME,
|
|
||||||
// The site's logo is an SVG, which Gmail and Outlook don't show,
|
|
||||||
// so the header is the site name in type. A PNG logo could go here.
|
|
||||||
logo: null,
|
|
||||||
sections: [
|
|
||||||
{ heading: 'Coming up', items: eventItems },
|
{ heading: 'Coming up', items: eventItems },
|
||||||
{ heading: 'From the blog', items: postItems },
|
{ heading: 'From the blog', items: postItems },
|
||||||
{ heading: 'Featured', items: cardItems },
|
{ heading: 'Featured', items: cardItems },
|
||||||
],
|
]
|
||||||
|
const content = {
|
||||||
|
title: title.trim() || `News from ${SITE_NAME}`,
|
||||||
|
intro: intro.trim() || null,
|
||||||
|
blocks,
|
||||||
|
footer: footer.trim() || null,
|
||||||
|
origin: SITE_ORIGIN,
|
||||||
|
siteName: SITE_NAME,
|
||||||
|
absolute: absoluteFor,
|
||||||
|
// The site's logo is an SVG, which Gmail and Outlook don't show,
|
||||||
|
// so the header is the site name in type. A PNG logo could go here.
|
||||||
|
logo: null,
|
||||||
|
sections,
|
||||||
}
|
}
|
||||||
return { html: newsletterHtml(content), text: newsletterText(content), count: eventItems.length + postItems.length + cardItems.length }
|
return {
|
||||||
}, [title, intro, events, pickedEvents, posts, pickedPosts, postDetails, cards, pickedCards])
|
content,
|
||||||
|
html: newsletterHtml(content),
|
||||||
|
text: newsletterText(content),
|
||||||
|
count: eventItems.length + postItems.length + cardItems.length + blocks.length,
|
||||||
|
}
|
||||||
|
}, [title, intro, footer, blocks, events, pickedEvents, posts, pickedPosts, postDetails, cards, pickedCards])
|
||||||
|
|
||||||
async function copy(kind: 'html' | 'text') {
|
async function copy(kind: 'html' | 'text') {
|
||||||
try {
|
try {
|
||||||
|
|
@ -169,6 +344,43 @@ export default function AdminNewsletter() {
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-6 flex flex-wrap items-end gap-3 border-l-4 border-brand bg-raised p-4 shadow-sm">
|
||||||
|
<label className="block min-w-60 flex-1 text-sm font-semibold text-body">
|
||||||
|
Draft
|
||||||
|
<select value={draft?.id ?? ''} onChange={(e) => openDraft(e.target.value)} className={`mt-1 ${input}`}>
|
||||||
|
<option value="">New draft</option>
|
||||||
|
{drafts.map((row) => (
|
||||||
|
<option key={row.id} value={row.id}>
|
||||||
|
{row.title || `News from ${SITE_NAME}`} (saved {row.updated_at.slice(0, 16)})
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
{canWrite(user) && (
|
||||||
|
<>
|
||||||
|
<button type="button" onClick={save} className={button} disabled={busy}>
|
||||||
|
<FloppyDisk weight="bold" aria-hidden="true" />
|
||||||
|
{draft ? 'Save draft' : 'Save as a new draft'}
|
||||||
|
</button>
|
||||||
|
<button type="button" onClick={postAsBlog} className={button} disabled={busy || newsletter.count === 0}>
|
||||||
|
<Article weight="bold" aria-hidden="true" />
|
||||||
|
Post as blog post
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{draft && canDelete(user) && (
|
||||||
|
<button type="button" onClick={remove} className={`${button} !border-danger !text-danger`} disabled={busy}>
|
||||||
|
<Trash weight="bold" aria-hidden="true" />
|
||||||
|
Delete draft
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{message && (
|
||||||
|
<p role="status" className={`w-full text-sm ${message.tone === 'error' ? 'text-danger' : 'text-body'}`}>
|
||||||
|
{message.text}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="mt-6 grid gap-8 lg:grid-cols-[minmax(0,26rem)_minmax(0,1fr)]">
|
<div className="mt-6 grid gap-8 lg:grid-cols-[minmax(0,26rem)_minmax(0,1fr)]">
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<section className="space-y-3 border-l-4 border-brand bg-raised p-5 shadow-sm">
|
<section className="space-y-3 border-l-4 border-brand bg-raised p-5 shadow-sm">
|
||||||
|
|
@ -188,6 +400,10 @@ export default function AdminNewsletter() {
|
||||||
</label>
|
</label>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section className="border-l-4 border-brand bg-raised p-5 shadow-sm">
|
||||||
|
<Repeater spec={BLOCKS_SPEC} rows={blocks} options={{}} errors={{}} errorPrefix="content_blocks." className="" onChange={setBlocks} />
|
||||||
|
</section>
|
||||||
|
|
||||||
<PickList
|
<PickList
|
||||||
title="Upcoming events"
|
title="Upcoming events"
|
||||||
empty={eventsLoading ? 'Loading…' : 'No upcoming events.'}
|
empty={eventsLoading ? 'Loading…' : 'No upcoming events.'}
|
||||||
|
|
@ -205,10 +421,29 @@ export default function AdminNewsletter() {
|
||||||
<PickList
|
<PickList
|
||||||
title="Featured cards (front page)"
|
title="Featured cards (front page)"
|
||||||
empty="No featured cards."
|
empty="No featured cards."
|
||||||
options={cards.map((card, index) => ({ value: index, label: card.title ?? card.url ?? 'Card', detail: card.kind }))}
|
options={cards.flatMap((card) => {
|
||||||
|
const href = featuredHref(card)
|
||||||
|
return href ? [{ value: href, label: card.title ?? href, detail: card.kind }] : []
|
||||||
|
})}
|
||||||
picked={pickedCards}
|
picked={pickedCards}
|
||||||
onToggle={(value) => toggle(pickedCards, value, setPickedCards)}
|
onToggle={(value) => toggle(pickedCards, value, setPickedCards)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<section className="border-l-4 border-brand bg-raised p-5 shadow-sm">
|
||||||
|
<label className="block text-sm font-semibold text-body">
|
||||||
|
Footer
|
||||||
|
<textarea
|
||||||
|
value={footer}
|
||||||
|
onChange={(e) => setFooter(e.target.value)}
|
||||||
|
rows={3}
|
||||||
|
placeholder={`${SITE_NAME}\n${SITE_ORIGIN}`}
|
||||||
|
className={`mt-1 resize-y ${input}`}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<p className="mt-1 text-xs" style={{ color: MUTED }}>
|
||||||
|
Default: the site's name and address. No unsubscribe link needed: Mailchimp adds its own.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -228,8 +463,8 @@ export default function AdminNewsletter() {
|
||||||
</div>
|
</div>
|
||||||
<p className="mt-2 text-xs" style={{ color: MUTED }}>
|
<p className="mt-2 text-xs" style={{ color: MUTED }}>
|
||||||
{newsletter.count === 0
|
{newsletter.count === 0
|
||||||
? 'Tick at least one item to build the email.'
|
? 'Tick an item or add a block to build the email.'
|
||||||
: `${newsletter.count} item${newsletter.count === 1 ? '' : 's'}. In Mailchimp, paste the HTML into a Code block or "Paste in code".`}
|
: `${newsletter.count} part${newsletter.count === 1 ? '' : 's'}. In Mailchimp, paste the HTML into a Code block or "Paste in code".`}
|
||||||
</p>
|
</p>
|
||||||
<iframe
|
<iframe
|
||||||
title="Newsletter preview"
|
title="Newsletter preview"
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,13 @@ export const DATA_NAV = {
|
||||||
label: "Blog posts",
|
label: "Blog posts",
|
||||||
blurb: "Posts of our own, each at /blog/…, written here or imported from Word.",
|
blurb: "Posts of our own, each at /blog/…, written here or imported from Word.",
|
||||||
},
|
},
|
||||||
|
// A timeline entry can point at an event, an organization, an
|
||||||
|
// award, a person or a team, so it's its own kind of record.
|
||||||
|
{
|
||||||
|
to: "/admin/timeline",
|
||||||
|
label: "Timeline",
|
||||||
|
blurb: "The History page's entries: milestones and the records they point at.",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -93,22 +100,32 @@ export const PAGES_NAV = {
|
||||||
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.",
|
||||||
},
|
},
|
||||||
// A timeline entry can point at an event, an organization, an
|
// The site's own pages, in the header's order: each is its
|
||||||
// award, a person or a team, so it isn't filed under any of them.
|
// sections, built in the editor (sitePages.ts).
|
||||||
{
|
{
|
||||||
to: "/admin/timeline",
|
to: "/admin/retreats_page",
|
||||||
label: "Timeline",
|
label: "Retreats",
|
||||||
blurb: "What the history page shows, and the order it shows it in.",
|
blurb: "Its sections: the event carousels and grids, and anything else written for it.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
to: "/admin/community_page",
|
to: "/admin/community_page",
|
||||||
label: "Community blog section",
|
label: "Community",
|
||||||
blurb: "The Community page's blog: headings, pinned posts and feeds.",
|
blurb: "Its sections: the blog (and its pinned posts and feeds), groups map, regions and partners.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
to: "/admin/resources_page",
|
||||||
|
label: "Resources",
|
||||||
|
blurb: "Its sections and their content.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
to: "/admin/organization_page",
|
to: "/admin/organization_page",
|
||||||
label: "Organization page",
|
label: "Organization",
|
||||||
blurb: "Mission, vision and values, the leadership teams in order, and volunteering.",
|
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.",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
@ -156,7 +173,7 @@ export const TOOLS_NAV = {
|
||||||
{
|
{
|
||||||
to: "/admin/newsletter",
|
to: "/admin/newsletter",
|
||||||
label: "Newsletter",
|
label: "Newsletter",
|
||||||
blurb: "An email newsletter from upcoming events, blog posts and featured cards, ready to paste into Mailchimp or Gmail.",
|
blurb: "An email newsletter from upcoming events, blog posts, featured cards and blocks of its own, ready to paste into Mailchimp or Gmail. Saved as drafts, and can become a blog post.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
to: "/qr",
|
to: "/qr",
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
COMMUNITY BLOG
|
COMMUNITY BLOG
|
||||||
|
|
||||||
The Community page's blog section (Admin → Pages → Community blog
|
The Community page's blog section (Admin → Pages → Community
|
||||||
section). Two halves, each pinned first and then newest, as
|
page, its Community blog preset and the blog settings). Two halves, each pinned first and then newest, as
|
||||||
routes/blog.js decides:
|
routes/blog.js decides:
|
||||||
|
|
||||||
our posts cards for our own /blog/:id pages
|
our posts cards for our own /blog/:id pages
|
||||||
|
|
@ -10,8 +10,7 @@
|
||||||
newest from the listed feeds), drawn by
|
newest from the listed feeds), drawn by
|
||||||
FeaturedCards, with a button to the Substack
|
FeaturedCards, with a button to the Substack
|
||||||
|
|
||||||
The section's heading and blurb come from the same record; the
|
The section's heading and blurb are its section's, like any other.
|
||||||
page reads them through the same cached request (Community.tsx).
|
|
||||||
A half with nothing in it isn't drawn.
|
A half with nothing in it isn't drawn.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue