NGU-Web/src/lib/adminSchema.ts
Zaldimmar e4a9c96f7e Finish the audit leftovers
- One mediaUrl in media.ts instead of 12 identical aliases and a
  kind map; orgPath builds on hrefs.ts's orgHref
- One Logo component (hides itself or shows a fallback when the file
  is missing) for event cards, org lists and chapter marks
- useHistory is a thin wrapper over useRecord
- adminSchema.ts split into adminSchema/, one file per entity plus
  shared.ts; the registry is unchanged (checked by loading both)
- JS smooth scrolls respect reduced motion (lib/motion.ts)
- Content-Security-Policy in Report-Only, with /api/csp-report logging
  what it would block

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 22:49:07 -05:00

53 lines
2.1 KiB
TypeScript

/* ═══════════════════════════════════════════════════════════════
ADMIN FORM MANIFESTS
The presentation half of server/src/admin-schema.js: labels,
widgets, grouping, and which select pulls from which option
list. The server decides what's storable; this decides what the
form looks like. Paths here must match column names there, and
nested paths ('region.scope') match the side-table keys.
Adding a field is one entry. Adding an entity is one file in
adminSchema/ (its manifest), one line in ADMIN_ENTITIES below,
and one descriptor on the server, with no new page component.
Field sets and collections several entities share are in
adminSchema/shared.ts.
A value seeded in a repeater's `blank` must also be declared as
a default: on the matching server column, or a row the user adds
and never fills in reads as real input instead of being skipped.
═══════════════════════════════════════════════════════════════ */
import { organizations } from "./adminSchema/organizations.ts";
import { events } from "./adminSchema/events.ts";
import { people } from "./adminSchema/people.ts";
import { teams } from "./adminSchema/teams.ts";
import { awards } from "./adminSchema/awards.ts";
import { timeline } from "./adminSchema/timeline.ts";
import { frontPage } from "./adminSchema/frontPage.ts";
import { blogPosts, communityPage } from "./adminSchema/blog.ts";
import { siteSettings } from "./adminSchema/siteSettings.ts";
export const ADMIN_ENTITIES: Record<string, any> = {
organizations,
events,
people,
teams,
awards,
timeline,
front_page: frontPage,
blog_posts: blogPosts,
community_page: communityPage,
site_settings: siteSettings,
};
export function slugify(value) {
return String(value ?? "")
.toLowerCase()
.normalize("NFKD")
.replace(/[^\w\s-]/g, "")
.trim()
.replace(/[\s_]+/g, "-")
.replace(/-+/g, "-")
.slice(0, 64);
}