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
|
|
@ -18,6 +18,7 @@
|
|||
import { preview } from "./text.ts";
|
||||
import { PLATFORMS } from "./platforms.ts";
|
||||
import { FORMATTING_HELP } from "../components/InlineText.tsx";
|
||||
import siteConfiguration from "../../site.json";
|
||||
import {
|
||||
awardLogo,
|
||||
blockMedia,
|
||||
|
|
@ -1619,6 +1620,112 @@ const communityPage = {
|
|||
],
|
||||
};
|
||||
|
||||
/* ── Site settings (035_site_settings.sql) ───────────────────────
|
||||
Overrides for site.json, superadmins only: every blank falls back
|
||||
to what site.json says, which is shown as the default. */
|
||||
const SITE_PAGES: [string, string][] = Object.entries(siteConfiguration.pages).map(
|
||||
([path, page]) => [path, `${page.title} (${path})`],
|
||||
);
|
||||
|
||||
const siteSettings = {
|
||||
key: "site_settings",
|
||||
label: "Site settings",
|
||||
singular: "site settings",
|
||||
idLabel: "Settings",
|
||||
singleton: "site",
|
||||
writeRole: "superadmin",
|
||||
|
||||
list: { columns: [], filters: [] },
|
||||
|
||||
groups: [
|
||||
{
|
||||
legend: "The site",
|
||||
note: "Anything left blank uses site.json, so the build and these settings agree until you change one.",
|
||||
fields: [
|
||||
{ path: "site_name", label: "Site name", help: `Default: ${siteConfiguration.title}` },
|
||||
{
|
||||
path: "description",
|
||||
label: "Description",
|
||||
widget: "textarea",
|
||||
full: true,
|
||||
help: "Search engines and link previews show this for pages without their own. Default: site.json's, or the front page's subhead.",
|
||||
},
|
||||
{
|
||||
path: "preview_image",
|
||||
label: "Preview image",
|
||||
widget: "image",
|
||||
resolve: blogImage,
|
||||
full: true,
|
||||
help: "Shown when a page without its own image is shared. 1200 × 630 works everywhere.",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Icons",
|
||||
fields: [
|
||||
{
|
||||
path: "favicon",
|
||||
label: "Favicon",
|
||||
widget: "image",
|
||||
resolve: blogImage,
|
||||
full: true,
|
||||
help: "The browser-tab icon: a square PNG (512px) or an SVG. Keep original when uploading an SVG.",
|
||||
},
|
||||
{
|
||||
path: "apple_touch_icon",
|
||||
label: "Home-screen icon",
|
||||
widget: "image",
|
||||
resolve: blogImage,
|
||||
full: true,
|
||||
help: "For iPhones saving the site to their home screen: a square PNG, 180px, no transparency.",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Search engines",
|
||||
fields: [
|
||||
{
|
||||
path: "indexing",
|
||||
label: "Let search engines list this site",
|
||||
widget: "select",
|
||||
options: [
|
||||
["on", "On: pages can appear in Google"],
|
||||
["off", "Off: hidden from search (use on the dev server)"],
|
||||
],
|
||||
blankLabel: `Default: site.json (${siteConfiguration.robots?.index === false ? "off" : "on"})`,
|
||||
help: "Applies to this server's database only, so dev can be off while production is on.",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
children: [
|
||||
{
|
||||
key: "pages",
|
||||
label: "Page titles and intros",
|
||||
note: "Change a static page's heading and intro, which are also its search title and description. Blank fields keep site.json's.",
|
||||
addLabel: "Change a page",
|
||||
title: (row) => SITE_PAGES.find(([path]) => path === row.path)?.[1] ?? "New page",
|
||||
blank: { path: "", title: "", description: "" },
|
||||
fields: [
|
||||
{ path: "path", label: "Page", widget: "select", options: SITE_PAGES, required: true },
|
||||
{
|
||||
path: "title",
|
||||
label: "Title",
|
||||
help: (row) => (row?.path ? `Default: ${siteConfiguration.pages[row.path]?.title ?? ""}` : undefined),
|
||||
},
|
||||
{
|
||||
path: "description",
|
||||
label: "Intro",
|
||||
widget: "textarea",
|
||||
full: true,
|
||||
help: (row) => (row?.path ? `Default: ${siteConfiguration.pages[row.path]?.description ?? ""}` : undefined),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const ADMIN_ENTITIES: Record<string, any> = {
|
||||
organizations,
|
||||
events,
|
||||
|
|
@ -1629,6 +1736,7 @@ export const ADMIN_ENTITIES: Record<string, any> = {
|
|||
front_page: frontPage,
|
||||
blog_posts: blogPosts,
|
||||
community_page: communityPage,
|
||||
site_settings: siteSettings,
|
||||
};
|
||||
|
||||
export function slugify(value) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue