/* ═══════════════════════════════════════════════════════════════ SITE What the site says about itself, for the browser: /site.json, with the admin's Site settings (Panel) laid over it. The server merges the two and writes the result into each page's HTML as window.__SITE__ (server/src/pageMeta.js), which is read here before the app renders, so there's no request and no flash of the old wording. In development, or if the API is down and nginx serves the plain index.html, it isn't there and site.json alone applies. A page's visible heading and intro and its search title and description come from the same values, so they can't drift. 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. ═══════════════════════════════════════════════════════════════ */ import siteConfiguration from '../../site.json' type PageText = { title: string; description: string } type SiteText = { title?: string; pages?: Record; privacyEmail?: string; requestFiles?: boolean } /* What the server wrote into the page, if it did. */ const fromServer: SiteText = (typeof window !== 'undefined' && (window as unknown as { __SITE__?: SiteText }).__SITE__) || {} export const SITE_NAME: string = fromServer.title || siteConfiguration.title export const SITE_ORIGIN: string = siteConfiguration.url /** Where privacy questions and data requests go (Panel → Site * settings, else site.json). Blank: the Privacy page's form only. */ export const PRIVACY_EMAIL: string = fromServer.privacyEmail ?? siteConfiguration.privacyEmail /** Whether the Request form takes files (Google Drive is set up on * the server). Unknown (the Vite dev server) offers them, and the * server says so if it can't. */ export const REQUEST_FILES: boolean = fromServer.requestFiles ?? true /** A site path as a full URL on the live site. */ export const siteUrl = (path: string): string => new URL(path, SITE_ORIGIN).href const PAGES: Record = { ...siteConfiguration.pages, ...fromServer.pages } /* Every static page's path and text, for the not-found page's suggestions. */ export const SITE_PAGES: Readonly> = 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