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:
parent
71a470b66f
commit
64cb2ec56a
21 changed files with 777 additions and 29 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue