Phase 5 of docs/website/THEMING_AND_NAV.md: uploaded logo/hero/favicon overrides on top of the BRAND_* env defaults, delivered through an HTML shell that is no longer built once at boot. - utils/htmlShell.js owns the shell lifecycle: rendered lazily, cached per process, invalidated on a brand_assets/theme_visual write with a 5-minute TTL so other workers converge. A settings-read failure renders the env-only shell and caches that, so a DB outage is not a failing query per page view, and with no rows the output is byte-identical to what app.js served before. - POST /admin/settings/brand-asset/:slot uploads one asset and writes the row in the same call, so an upload never leaves an unreferenced file. It reuses the shared multer allowlist and only tightens it per slot: favicons are PNG-only and capped at 512 KB, logos at 1 MB, heroes at 8 MB. Refused files are unlinked before the response. - utils/brandAssets.js constrains a stored asset to a same-origin path under /uploads, /brand or /assets — these are the only settings values written straight into the page as a URL. Strict on write, forgiving on read. - The shell also carries the resolved theme as a <style id="theme-boot"> block, removing the first-paint flash phases 3-4 deferred; SiteContext drops that block once a successful settings fetch has been applied. - BrandLogo renders beside the MoonDot on all six shells and renders nothing when no logo is set, which is the shipped default. Co-Authored-By: Claude <noreply@anthropic.com>
34 lines
1.5 KiB
JavaScript
34 lines
1.5 KiB
JavaScript
import { useSite } from '../contexts/SiteContext.jsx'
|
|
|
|
// The instance logo, shown beside the MoonDot wherever the site says its own
|
|
// name (docs/website/THEMING_AND_NAV.md phase 5).
|
|
//
|
|
// Renders NOTHING unless this instance has a logo — `brand.logo` is the uploaded
|
|
// override or BRAND_LOGO, and its default is the empty string. That is what
|
|
// keeps an untouched instance byte-for-byte as today: the MoonDot stands alone
|
|
// exactly as it does now, and the logo is an addition an operator opts into.
|
|
//
|
|
// It sits beside the moon rather than replacing it. The moon is the app's own
|
|
// mark and appears on surfaces (maintenance, login) that must render before the
|
|
// settings fetch resolves; swapping it out would leave those momentarily blank.
|
|
//
|
|
// Deliberately not used for the footer's "powered by Runic Gateway" emblem
|
|
// (SiteFooter.jsx) — that badge is the project's mark, not the instance's, and
|
|
// must not follow brand_assets (§4.11).
|
|
export default function BrandLogo({ height = 22, alt = '', style }) {
|
|
const { brand, siteTitle } = useSite()
|
|
if (!brand.logo) return null
|
|
return (
|
|
<img
|
|
src={brand.logo}
|
|
// Decorative by default: every call site puts the site title in text right
|
|
// next to it, so alt text here would have a screen reader say the name
|
|
// twice. A caller that renders the logo alone passes its own alt.
|
|
alt={alt || ''}
|
|
aria-hidden={alt ? undefined : true}
|
|
title={siteTitle}
|
|
style={{ height, width: 'auto', maxWidth: height * 6, objectFit: 'contain', display: 'block', ...style }}
|
|
/>
|
|
)
|
|
}
|