Repository navigation
feat: support SVG site logo with dark mode color inversion - #583
Merged
Merged
Conversation
- Detect SVG avatars (URL path or data URI) and apply dark:invert in dark mode so monochrome logos stay readable on dark backgrounds - Opt out per-URL by appending #no-invert, mirroring the existing #blurhash= URL-fragment metadata convention - Apply inversion to the header brand, admin sidebar and settings previews via the existing ImageWithFallback imageClassName - Accept image/svg+xml in the editor image picker - Serve SVG avatars directly as the favicon (cached as favicon.svg) instead of rasterizing them through Cloudflare Image Resizing - Update the avatar setting description in en/ja/zh-CN/zh-TW
|
🚀 Preview deployed! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Monochrome SVG logos are common brand assets, but they become almost invisible on dark backgrounds — a dark
#262626logo rendered in dark mode is unreadable. Until now the site avatar was also effectively raster-only: the editor image picker rejected SVG files, and the favicon generator routed SVG avatars through Cloudflare Image Resizing, which rasterizes them.Solution
.svgpath suffix or animage/svg+xmldata URI) automatically get Tailwind'sdark:inverton the logo<img>, following the existing[data-color-mode="dark"]selector. Inversion applies to the header brand, the admin sidebar, and the settings/upload previews — article images and other bitmaps are untouched.#no-invertto the avatar URL to keep the original colors (useful for multi-color SVG logos). This mirrors the existing#blurhash=URL-fragment metadata convention and is ignored by the metadata parser.image/svg+xml(the upload path already supported it).GET /faviconserves it directly (cached asfavicon.svg) instead of rasterizing through Image Resizing, preserving vector crispness. A manually uploaded favicon still takes precedence, as before.#no-invertescape hatch.Tests
shouldInvertImageInDarkMode/darkInvertImageClasshelpers (extension detection, query/hash handling, data URIs, case-insensitivity, opt-out flag)image/svg+xml, and the cachedfavicon.svgis served without refetching the avatarbun run test),bun run checkandbun run format:checkpass