Admin-teksten en merklogo: Weergavenaam, Wachtwoord wijzigen, Eerste account aanmaken, logo per thema

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-08 14:36:10 +01:00
co-authored by Claude Sonnet 5.5
parent cd81723bf5
commit 55dcab121b
20 changed files with 350 additions and 25 deletions
+18 -2
View File
@@ -16,8 +16,13 @@ function themeFor(mode: string) {
* Per-site favicon (VITE_THEME): the page links the theme favicon instead of the default one.
* Build emits it as an asset; the dev server serves it from the theme folder.
*/
function themeFavicon(faviconPath: string | null): Plugin {
function themeFavicon(faviconPath: string | null, logo: { onLight: string; onDark: string } | null): Plugin {
const publicName = 'favicon-theme.png';
// Brand logo files, served/emitted next to the favicon (see src/lib/brand.ts for the names' consumer).
const logoFiles: Record<string, string> = logo === null ? {} : {
'brand-logo-on-light.png': logo.onLight,
'brand-logo-on-dark.png': logo.onDark,
};
return {
name: 'cms-theme-favicon',
// 'post': Vite has already prefixed the base path (/admin/) by then, so match any prefix.
@@ -29,6 +34,12 @@ function themeFavicon(faviconPath: string | null): Plugin {
},
},
configureServer(server) {
for (const [name, file] of Object.entries(logoFiles)) {
server.middlewares.use(`/${name}`, (_req, res) => {
res.setHeader('Content-Type', 'image/png');
res.end(fs.readFileSync(file));
});
}
if (faviconPath === null) return;
server.middlewares.use(`/${publicName}`, (_req, res) => {
res.setHeader('Content-Type', 'image/png');
@@ -36,6 +47,9 @@ function themeFavicon(faviconPath: string | null): Plugin {
});
},
generateBundle() {
for (const [name, file] of Object.entries(logoFiles)) {
this.emitFile({ type: 'asset', fileName: name, source: fs.readFileSync(file) });
}
if (faviconPath === null) return;
this.emitFile({ type: 'asset', fileName: publicName, source: fs.readFileSync(faviconPath) });
},
@@ -46,10 +60,12 @@ function themeFavicon(faviconPath: string | null): Plugin {
export default defineConfig(({ command, mode }) => ({
// Production builds are deployed under /admin (see Program.cs); the dev server keeps serving from '/'.
base: command === 'build' ? '/admin/' : '/',
plugins: [react(), tailwindcss(), themeFavicon(themeFor(mode).favicon)],
plugins: [react(), tailwindcss(), themeFavicon(themeFor(mode).favicon, themeFor(mode).logo)],
define: {
// Injected at build time, used as the Sentry `release` tag (see src/lib/sentry.ts).
__APP_VERSION__: JSON.stringify(version),
// Whether the selected theme ships a brand logo (consumed by src/lib/brand.ts).
__THEME_HAS_LOGO__: JSON.stringify(themeFor(mode).logo !== null),
},
resolve: {
alias: {