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:
Zaldimmar 2026-09-28 00:36:58 -05:00
parent 8ec34ea185
commit 47df7b1fe0
15 changed files with 393 additions and 32 deletions

View file

@ -128,8 +128,10 @@ export default function AdminHome() {
))}
{isSuper(user) && (
<CardBlock title="Superadmin" blurb="Only superadmins see this block.">
<NavCard item={PANEL_NAV} />
<CardBlock title={PANEL_NAV.label} blurb={PANEL_NAV.blurb}>
{PANEL_NAV.children.map((item) => (
<NavCard key={item.to} item={item} />
))}
</CardBlock>
)}
</div>

View file

@ -87,7 +87,9 @@ export default function EntityEdit() {
useWideAdminPage();
const isNew = id === "new";
const canWrite = atLeast(user, "editor");
// Editor, unless the entity asks for more (site settings:
// superadmin), matching the server's writeRole.
const canWrite = atLeast(user, manifest?.writeRole ?? "editor");
const canDelete = atLeast(user, "admin");
// Some entities have no slug: the table assigns an integer id, so

View file

@ -38,7 +38,7 @@ export default function EntityList() {
// equality test this replaced hid the button from superadmins as
// well as editors, which is the failure mode an == against a
// ladder always produces once a rank is added above it.
const canWrite = atLeast(user, "editor");
const canWrite = atLeast(user, manifest?.writeRole ?? "editor");
const load = useCallback(async () => {
if (!manifest || manifest.singleton) return;

View file

@ -140,14 +140,27 @@ export const TOOLS_NAV = {
],
};
/* Accounts and server state, not content, which is why it's its
own area rather than a group of CMS pages. */
/* Accounts, server state and what the site says about itself: the
superadmin's area, its own area rather than a group of CMS pages. */
export const SITE_SETTINGS = "/admin/site_settings";
export const PANEL_NAV = {
to: ADMIN_PANEL,
label: "Panel",
blurb: "Accounts, sessions and the state of the server.",
blurb: "Only superadmins see this.",
separated: true,
superOnly: true,
children: [
{
to: ADMIN_PANEL,
label: "Accounts and server",
blurb: "Accounts, sessions and the state of the server.",
},
{
to: SITE_SETTINGS,
label: "Site settings",
blurb: "The site's name, description, preview image, icons, page titles and search indexing.",
},
],
};
export const NAV: any[] = [DATA_NAV, PAGES_NAV, FORMS_NAV, TOOLS_NAV, PANEL_NAV];
@ -167,6 +180,6 @@ export const target = (item) => item.to ?? item.children?.[0]?.to;
export function areaFor(pathname) {
if (matches(pathname, ADMIN_HOME)) return "home";
if (matches(pathname, ADMIN_PANEL)) return "panel";
if (matches(pathname, ADMIN_PANEL) || matches(pathname, SITE_SETTINGS)) return "panel";
return "cms";
}