diff --git a/CLAUDE.md b/CLAUDE.md index 1332872..375dde6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -57,7 +57,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu - `navConfig.ts` is the single source of truth for navigation, routes, and actions (header, footer, pages). - `api.ts` is the shared caching client used by frontend data hooks. - `docs/updating-data-in-code.md`: where content that isn't in the database lives (admin dropdown labels, fixed value lists, nav, banner, decades, map grid) and how to change it. Keep it current when adding a dropdown or code-owned content. -- Logos: org logos in `public/org-logos/` (served at `/org-logos/`); event logos are uploads (`/uploads/`, a bare filename resolves there). The site's own NGU logos are bundled from `src/assets/logos/`. Image paths resolve through `src/lib/media.ts`. The `` component hides itself on load error. +- Images: every record image (logos, photos, backgrounds, block images) is an upload. A bare filename resolves to `/uploads/` (`src/lib/media.ts`, and `server/src/pageMeta.js` for previews). Only the site's own chosen assets, the NGU logos in the nav, footer and admin, are bundled from `src/assets/logos/`. The `` component hides itself on load error. ## Rules and gotchas - **Role checks must use ladder comparisons, never equality.** Roles rank viewer → editor → admin → superadmin. Use the minimum-rank helpers from `src/lib/roles.ts` (`canWrite`, `canDelete`, `isSuper`, `atLeast`). Where a local variable shadows the name, import with an alias, e.g. `canWrite as roleCanWrite`. `role === "admin"` silently excludes higher roles and has caused repeated bugs. diff --git a/server/src/pageMeta.js b/server/src/pageMeta.js index f47f28d..c76dc45 100644 --- a/server/src/pageMeta.js +++ b/server/src/pageMeta.js @@ -27,8 +27,8 @@ /admin noindex Image paths resolve like src/lib/media.ts does: a bare filename - lives in that record kind's public/ directory, anything starting - with / or a scheme is used as it is. Keep DIRS in step with it. + is in the uploads directory, anything starting with / or a scheme + is used as it is. An SVG isn't used as a preview image (the big sites won't show one), so it falls back to the site default. ═══════════════════════════════════════════════════════════════ */ @@ -45,16 +45,9 @@ export const SITE_CONFIG = path.resolve(process.env.SITE_CONFIG ?? path.join(her const DESCRIPTION_CHARS = 160; -/* Where a bare filename lives, per kind. Mirrors src/lib/media.ts. */ -const DIRS = { - person: "/people", - eventLogo: "/uploads", - eventBackground: "/event-backgrounds", - organization: "/org-logos", - team: "/team-logos", - award: "/award-logos", - blog: "/blog", -}; +/* Where a bare filename lives: record images are uploads, whatever + kind they are. Mirrors src/lib/media.ts. */ +const UPLOADS = "/uploads"; /* ── site.json, reread when it changes ─────────────────────── */ @@ -94,9 +87,9 @@ const first = (...values) => values.find((v) => v != null && String(v).trim() != function imageUrl(site, file, kind) { if (!file || /\.svg(\?|#|$)/i.test(file)) return null; - // A bare filename is in that kind's directory, or at the site's - // root for the site's own default (kind null). - const pathOrUrl = /^(https?:|\/)/.test(file) ? file : kind ? `${DIRS[kind]}/${file}` : `/${file}`; + // A record's bare filename is an upload; the site's own default + // image (kind null) is a path from the site's root. + const pathOrUrl = /^(https?:|\/)/.test(file) ? file : kind ? `${UPLOADS}/${file}` : `/${file}`; return /^https?:/.test(pathOrUrl) ? pathOrUrl : `${origin(site)}${pathOrUrl}`; } diff --git a/src/lib/adminSchema.ts b/src/lib/adminSchema.ts index 94d227b..224dbd9 100644 --- a/src/lib/adminSchema.ts +++ b/src/lib/adminSchema.ts @@ -1305,7 +1305,7 @@ const frontPage = { full: true, help: "A YouTube, Vimeo or Facebook link, or a video file: a filename in " + - "/front-page/ or a link ending in .mp4 or .webm", + "the uploads folder, or a link ending in .mp4 or .webm", }, { path: "video_title", label: "Video title", full: true, help: "Shown after \"Featured video\" above the headline" }, { diff --git a/src/lib/embeds.ts b/src/lib/embeds.ts index afc68c1..435560c 100644 --- a/src/lib/embeds.ts +++ b/src/lib/embeds.ts @@ -15,7 +15,7 @@ so the visitor presses play. A featured video can also be a file rather than a link: a - filename in public/front-page/, a /path, or an https URL ending + filename in the uploads directory, a /path, or an https URL ending in a video extension. videoSource() says which, so the hero can hand a file to