Add per-page search metadata, link previews and a sitemap

Page requests now go through the API (routes/pages.js), which fills
the built index.html in for that path before the app loads: title,
description, preview image, canonical URL, and structured data
(Organization, Event, BlogPosting). Shared links preview the page
itself. Unlisted records are noindex; missing ones return 404.
/sitemap.xml lists every public, listed page.

site.json is the one place for the site's name, address, default
description and preview image, and each static page's title and
intro, which the pages now read too. Indexing is switched on:
robots.txt allows all but /admin and /api and names the sitemap. The
browser tab title follows the page.

nginx setup, with a fallback to the plain page if the API is down,
is in docs/seo.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-27 21:21:10 -05:00
parent 71a470b66f
commit 64cb2ec56a
21 changed files with 777 additions and 29 deletions

View file

@ -29,7 +29,9 @@
/>
═══════════════════════════════════════════════════════════════ */
import type { ReactNode } from "react";
import { useEffect, type ReactNode } from "react";
import { documentTitle } from "../lib/site.ts";
const TEAL = "#138ba0";
@ -89,6 +91,13 @@ export function Section({ section }: { section: ShellSection }) {
}
export default function PageShell({ title, intro, sections }: PageShellProps) {
// The tab's title as the visitor moves around. The first load's
// comes from the server (pageMeta.js), which also sets the page's
// description and preview for search and link sharing.
useEffect(() => {
if (typeof title === "string") document.title = documentTitle(title);
}, [title]);
return (
<>
{/* Page header */}

View file

@ -1,13 +1,39 @@
/* ═══════════════════════════════════════════════════════════════
SITE
The public address of the live site. Used where a URL has to
leave the browser and still work: a printed QR code made on
localhost or a preview has to point here, not at wherever it was
generated. Everything inside the site links by path, not this.
What /site.json says about the site, for the browser. The server
reads the same file for the metadata it puts in each page's HTML
(server/src/pageMeta.js), so a page's visible heading and intro
and its search title and description come from one place.
SITE_ORIGIN is the public address of the live site. It's used
where a URL has to leave the browser and still work: a printed QR
code made on localhost or a preview has to point here, not at
wherever it was generated. Everything inside the site links by
path, not this.
═══════════════════════════════════════════════════════════════ */
export const SITE_ORIGIN = 'https://nextgenerationofunity.org'
import siteConfiguration from '../../site.json'
export const SITE_NAME: string = siteConfiguration.title
export const SITE_ORIGIN: string = siteConfiguration.url
/** A site path as a full URL on the live site. */
export const siteUrl = (path: string): string => new URL(path, SITE_ORIGIN).href
type PageText = { title: string; description: string }
const PAGES: Record<string, PageText> = siteConfiguration.pages
/** A static page's title and intro, from site.json's "pages". */
export function sitePage(path: string): PageText {
const page = PAGES[path]
if (!page) throw new Error(`site.json has no "pages" entry for ${path}`)
return page
}
/** The browser tab's title for a page: "Retreats | Next Generation
* of Unity", or the site name alone for the home page. */
export const documentTitle = (title?: string | null): string =>
title ? `${title} | ${SITE_NAME}` : SITE_NAME

View file

@ -1,4 +1,5 @@
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";
@ -6,6 +7,9 @@ import OrgListCards from "./sections/OrgList-Card.tsx";
import CommunityBlog from "./sections/CommunityBlog.tsx";
import { useCommunityBlog } from "../lib/useBlog.ts";
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/community");
/* ═══════════════════════════════════════════════════════════════
COMMUNITY PAGE
@ -82,8 +86,8 @@ export default function CommunityPage() {
return (
<PageShell
title="Community"
intro="Chapters, regions and the people who make up Next Generation of Unity."
title={PAGE.title}
intro={PAGE.description}
sections={sections}
/>
);

View file

@ -1,6 +1,10 @@
import PageShell from "../components/PageShell";
import { sitePage } from "../lib/site.ts";
import FeedbackForm from "./sections/FeedbackForm";
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/feedback");
/* ═══════════════════════════════════════════════════════════════
Feedback page.
@ -36,8 +40,8 @@ const SECTIONS = [
export default function Feedback() {
return (
<PageShell
title="Feedback"
intro="Tell us what's working, what isn't, and what you'd like to see next."
title={PAGE.title}
intro={PAGE.description}
sections={SECTIONS}
/>
);

View file

@ -1,5 +1,9 @@
import { useEffect } from "react";
import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts";
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/give");
const GIVING_URL =
"https://ngu.churchcenteronline.com/giving?open-in-church-center-modal=true";
@ -81,8 +85,8 @@ export default function GivingPage() {
return (
<PageShell
title="Giving"
intro="Support the work of Next Generation of Unity."
title={PAGE.title}
intro={PAGE.description}
sections={sections}
/>
);

View file

@ -1,8 +1,12 @@
import PageShell from "../components/PageShell";
import { sitePage } from "../lib/site.ts";
import HistoryTimeline from "./sections/history/HistoryTimeline";
import { HISTORY_DECADES } from "../data/historyDecades";
import { useHistory } from "../lib/useHistory";
/* 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
@ -66,8 +70,8 @@ export default function History() {
return (
<PageShell
title="History"
intro="A near-complete timeline of Next Generation of Unity (NGU), and other Unity Young Adult programs."
title={PAGE.title}
intro={PAGE.description}
sections={[
{
id: "timeline",

View file

@ -23,7 +23,7 @@
broken server.
═══════════════════════════════════════════════════════════════ */
import type { ReactNode } from 'react'
import { useEffect, type ReactNode } from 'react'
import HeroStage from './sections/home/HeroStage.tsx'
import NextEventCountdown from './sections/home/NextEventCountdown.tsx'
@ -33,6 +33,7 @@ import StatsBand from './sections/home/StatsBand.tsx'
import FeaturedBand from './sections/home/FeaturedBand.tsx'
import FeaturedTimelineRail from './sections/home/FeaturedTimelineRail.tsx'
import Pathfinder from './sections/home/Pathfinder.tsx'
import { documentTitle } from '../lib/site.ts'
import {
useFrontPage,
type FrontPage,
@ -104,6 +105,11 @@ const SECTIONS: Record<
export default function Home() {
const { data: page, error, reload } = useFrontPage()
// Back to the site name when a visitor returns here from a page.
useEffect(() => {
document.title = documentTitle()
}, [])
return (
<>
<HeroStage hero={page?.hero ?? null} />

View file

@ -1,6 +1,10 @@
import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts";
import PeopleTiles from "../components/PeopleTiles.tsx";
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/leadership");
const SECTIONS = [
{
id: "board-staff",
@ -61,8 +65,8 @@ const SECTIONS = [
export default function Leadership() {
return (
<PageShell
title="Leadership"
intro="The board, staff, and volunteers who keep Next Generation of Unity running."
title={PAGE.title}
intro={PAGE.description}
sections={SECTIONS}
/>
);

View file

@ -1,4 +1,8 @@
import PageShell from "../components/PageShell.jsx";
import { sitePage } from "../lib/site.ts";
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/privacy");
const SECTIONS = [
{
@ -18,8 +22,8 @@ const SECTIONS = [
export default function PrivacyPage() {
return (
<PageShell
title="Privacy Policy"
intro="How Next Generation of Unity collects, uses, and protects your information."
title={PAGE.title}
intro={PAGE.description}
sections={SECTIONS}
/>
);

View file

@ -1,6 +1,10 @@
import PageShell from '../components/PageShell.tsx'
import { sitePage } from '../lib/site.ts'
import QrCodeMaker from './sections/QrCodeMaker.tsx'
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage('/qr')
/* ═══════════════════════════════════════════════════════════════
QR CODES PAGE: /qr
@ -29,8 +33,8 @@ const SECTIONS = [
export default function QrCodes() {
return (
<PageShell
title="QR Codes"
intro="Codes for flyers, slides and signs, pointing at any page on the site."
title={PAGE.title}
intro={PAGE.description}
sections={SECTIONS}
/>
)

View file

@ -1,4 +1,8 @@
import PageShell from "../components/PageShell.jsx";
import { sitePage } from "../lib/site.ts";
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/resources");
const SECTIONS = [
{
@ -42,8 +46,8 @@ const SECTIONS = [
export default function ResourcesPage() {
return (
<PageShell
title="Resources"
intro="Teachings, brand assets, and material for chapters and partners."
title={PAGE.title}
intro={PAGE.description}
sections={SECTIONS}
/>
);

View file

@ -1,7 +1,11 @@
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";
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/retreats");
/* ═══════════════════════════════════════════════════════════════
RETREATS PAGE
@ -112,8 +116,8 @@ export default function RetreatsPage() {
return (
<PageShell
title="Retreats"
intro="Retreats hosted by Next Generation of Unity, our regions, and our partners throughout the year."
title={PAGE.title}
intro={PAGE.description}
sections={sections}
/>
);

View file

@ -1,4 +1,8 @@
import PageShell from "../components/PageShell.jsx";
import { sitePage } from "../lib/site.ts";
/* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/terms");
const SECTIONS = [
{
@ -18,8 +22,8 @@ const SECTIONS = [
export default function TermsPage() {
return (
<PageShell
title="Terms of Service"
intro="The terms that apply when you use this site and our programs."
title={PAGE.title}
intro={PAGE.description}
sections={SECTIONS}
/>
);