Add Site settings: name, description, icons, page titles, indexing
Panel → Site settings (migration 035, superadmins only) edits the site's name, description, preview image, favicon and home-screen icon, each static page's title and intro, and whether search engines may list the site. Every value overrides site.json; a blank one falls back to it. The indexing switch is per database, so the dev server can be off while production is on from one build. The server merges the two (siteFor in pageMeta.js) for page metadata, the sitemap and a new /robots.txt route, and writes the merged wording into each page as window.__NGU_SITE__, which site.ts reads so headings match with no extra request. Entities can now require a higher role to save (writeRole), checked on both sides. Panel is a menu group with Accounts and server, and Site settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8ec34ea185
commit
47df7b1fe0
15 changed files with 393 additions and 32 deletions
|
|
@ -1,10 +1,17 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
SITE
|
||||
|
||||
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.
|
||||
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.__NGU_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
|
||||
|
|
@ -15,16 +22,25 @@
|
|||
|
||||
import siteConfiguration from '../../site.json'
|
||||
|
||||
export const SITE_NAME: string = siteConfiguration.title
|
||||
type PageText = { title: string; description: string }
|
||||
|
||||
type SiteText = { title?: string; pages?: Record<string, PageText> }
|
||||
|
||||
/* What the server wrote into the page, if it did. */
|
||||
const fromServer: SiteText =
|
||||
(typeof window !== 'undefined' && (window as unknown as { __NGU_SITE__?: SiteText }).__NGU_SITE__) || {}
|
||||
|
||||
export const SITE_NAME: string = fromServer.title || 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, ...fromServer.pages }
|
||||
|
||||
const PAGES: Record<string, PageText> = siteConfiguration.pages
|
||||
/** The static pages site.json knows, for the admin's page list. */
|
||||
export const SITE_PAGE_PATHS: string[] = Object.keys(siteConfiguration.pages)
|
||||
|
||||
/** A static page's title and intro, from site.json's "pages". */
|
||||
export function sitePage(path: string): PageText {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue