Skip to content

feat: support SVG site logo with dark mode color inversion - #583

Merged
OXeu merged 1 commit into
openRin:mainfrom
Guoyin-Wen:feat/svg-logo-dark-mode-invert
Nov 2, 2026
Merged

OXeu merged 1 commit into
openRin:mainfrom
Guoyin-Wen:feat/svg-logo-dark-mode-invert

Conversation

@Guoyin-Wen

Copy link
Copy Markdown
Contributor

Problem

Monochrome SVG logos are common brand assets, but they become almost invisible on dark backgrounds — a dark #262626 logo 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

  • Dark mode inversion: SVG avatars (detected via .svg path suffix or an image/svg+xml data URI) automatically get Tailwind's dark:invert on 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.
  • Opt-out: append #no-invert to 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.
  • Editor: the markdown editor image picker now accepts image/svg+xml (the upload path already supported it).
  • Favicon: when the avatar is an SVG, GET /favicon serves it directly (cached as favicon.svg) instead of rasterizing through Image Resizing, preserving vector crispness. A manually uploaded favicon still takes precedence, as before.
  • Docs/i18n: the avatar setting description in en/ja/zh-CN/zh-TW now mentions the behavior and the #no-invert escape hatch.

Tests

  • 9 unit tests for the new shouldInvertImageInDarkMode / darkInvertImageClass helpers (extension detection, query/hash handling, data URIs, case-insensitivity, opt-out flag)
  • 2 new server tests: SVG avatar is served as image/svg+xml, and the cached favicon.svg is served without refetching the avatar
  • Full suite passes (bun run test), bun run check and bun run format:check pass
  • Verified live on a Cloudflare deployment: light mode keeps the dark logo, dark mode inverts it to light, with a clear contrast in both

- 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
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

🚀 Preview deployed!

🔗 https://rin-server-pr-583.xeu.workers.dev

@OXeu
OXeu merged commit c6dc10c into openRin:main Nov 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants