Skip to content

fix(admin): use the configured Site Icon as the admin favicon#1505

Open
swissky wants to merge 3 commits into
emdash-cms:mainfrom
swissky:fix/admin-site-icon
Open

fix(admin): use the configured Site Icon as the admin favicon#1505
swissky wants to merge 3 commits into
emdash-cms:mainfrom
swissky:fix/admin-site-icon

Conversation

@swissky

@swissky swissky commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

The admin shell (admin.astro) sets its favicon only from the build-time admin.favicon config, falling back to the bundled EmDash mark. The Site Icon users configure in Settings → General (the favicon site setting) was ignored by the backend — even though the public site already uses it via EmDashHead (renderSiteIdentity({ favicon: siteSettings.favicon })).

So setting a Site Icon brands the public site but not the admin — unlike WordPress, where the Site Icon also brands wp-admin.

This loads the site settings at request time and prefers the configured Site Icon for the admin <link rel="icon">:

Site Icon (Settings → General) → build-time admin.favicon → bundled EmDash mark

const settings = await getSiteSettingsWithDb(emdash.db, emdash.storage ?? null);
const favicon = settings.favicon?.url ?? adminConfig?.favicon; // then <link rel="icon" href={favicon}>

No behaviour change when no Site Icon is set (the existing config/default fallback still applies). Wrapped in try/catch so a pre-setup or settings error can't break the admin shell.

Closes #

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes (emdash package — ran clean)
  • pnpm lint passes (left to CI)
  • pnpm test passes — n/a: change is in an Astro route <head> template (no unit harness); behaviour verified manually
  • pnpm format has been run (left to CI)
  • I have added/updated tests for my changes — see above (Astro template head)
  • User-visible strings in the admin UI are wrapped for translation (if applicable) — n/a, no strings added
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion — n/a (bug fix)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Cursor + Claude Opus 4.8

Screenshots / test output

Single-file change in packages/core/src/astro/routes/admin.astro (+ changeset). Reuses the existing getSiteSettingsWithDb loader (same import the sitemap route uses). pnpm --filter emdash typecheck is clean.

@changeset-bot

changeset-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 013c8ad

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added review/needs-review No maintainer or bot review yet area/core size/S labels Jun 16, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1505

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1505

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@1505

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1505

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1505

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@1505

emdash

npm i https://pkg.pr.new/emdash@1505

create-emdash

npm i https://pkg.pr.new/create-emdash@1505

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1505

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@1505

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@1505

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@1505

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@1505

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@1505

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1505

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1505

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1505

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1505

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1505

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1505

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@1505

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1505

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1505

commit: 013c8ad

@swissky

swissky commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

/review

// Settings unavailable (e.g. pre-setup) — fall back to the config/default.
}
}
const favicon = siteFavicon ?? adminConfig?.favicon;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it default to the admin favicon? That's more specific than the site one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call — agreed. An explicitly configured admin.favicon is admin-specific and shouldn't be silently overridden by the more general Site Icon. I've flipped the precedence to adminConfig?.favicon ?? siteFavicon (admin.favicon → Site Icon → bundled mark). The Site Icon still brands the admin in the common case where no admin.favicon is set, which was the goal of the PR. Comment + changeset updated, and rebased on latest main.

@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-review No maintainer or bot review yet labels Jun 17, 2026
swissky added 2 commits July 1, 2026 15:33
Address review: an explicitly configured build-time admin.favicon is
admin-specific and should not be overridden by the more general Site
Icon. Flip precedence to admin.favicon -> Site Icon -> bundled mark.
The Site Icon still brands the admin for the common case where no
admin.favicon is set.
@swissky swissky force-pushed the fix/admin-site-icon branch from 6c2d8fa to ec7f8c6 Compare July 1, 2026 13:35
@github-actions github-actions Bot added review/needs-rereview Author pushed changes since the last review and removed review/awaiting-author Reviewed; waiting on the author to respond labels Jul 1, 2026
// Settings unavailable (e.g. pre-setup) — fall back to the config/default.
}
}
const favicon = adminConfig?.favicon ?? siteFavicon;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we're defaulting to adminConfig?.favicon we could skip getting siteFavicon if it's present

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — the settings read is now skipped entirely when an explicit admin.favicon is configured (013c8ad), so the common self-hosted case with a build-time favicon no longer pays the per-request settings lookup.

@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-rereview Author pushed changes since the last review labels Jul 1, 2026
@github-actions github-actions Bot added review/needs-rereview Author pushed changes since the last review and removed review/awaiting-author Reviewed; waiting on the author to respond labels Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core review/needs-rereview Author pushed changes since the last review size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants