fix: support monochrome custom logos via logo-invert.svg filename convention (#141)

Custom logos were hardcoded as full-color, making white/monochrome logos
invisible in light mode. Adds logo-invert.svg as a higher-priority
candidate that enables the brightness filter in light mode.
This commit is contained in:
JingleManSweep
2026-03-09 17:30:40 +00:00
committed by GitHub
parent 59a1898824
commit a32255e110
4 changed files with 13 additions and 8 deletions

View File

@@ -640,7 +640,8 @@ ${CONTENT_HOME}/
│ └── getting-started.md # Example: Getting Started (/pages/getting-started)
└── media/ # Custom media files
└── images/
── logo.svg # Custom logo (replaces default favicon and navbar/home logo)
── logo.svg # Full-color custom logo (default)
└── logo-invert.svg # Monochrome custom logo (darkened in light mode)
```
Pages use YAML frontmatter for metadata:

View File

@@ -480,15 +480,17 @@ Control which pages are visible in the web dashboard. Disabled features are full
The web dashboard supports custom content including markdown pages and media files. Content is organized in subdirectories:
Custom logo note:
- If a custom logo file is present, the UI keeps its original colors in both light/dark themes (no automatic light-mode darkening).
Custom logo options:
- `logo.svg` — full-color logo, displayed as-is in both themes (no automatic darkening)
- `logo-invert.svg` — monochrome/two-tone logo, automatically darkened in light mode for visibility
```
content/
├── pages/ # Custom markdown pages
│ └── about.md
└── media/ # Custom media files
└── images/
── logo.svg # Custom logo (replaces favicon and navbar/home logo)
── logo.svg # Full-color custom logo (default)
└── logo-invert.svg # Monochrome custom logo (darkened in light mode)
```
**Setup:**

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -56,13 +56,15 @@ def _resolve_logo(media_home: Path) -> tuple[str, bool, Path | None]:
Returns:
tuple of (logo_url, invert_in_light_mode, resolved_path)
"""
custom_logo_candidates = (("logo.svg", "/media/images/logo.svg"),)
for filename, url in custom_logo_candidates:
custom_logo_candidates = (
("logo-invert.svg", "/media/images/logo-invert.svg", True),
("logo.svg", "/media/images/logo.svg", False),
)
for filename, url, invert_in_light_mode in custom_logo_candidates:
path = media_home / "images" / filename
if path.exists():
# Custom logos are assumed to be full-color and should not be darkened.
cache_buster = int(path.stat().st_mtime)
return f"{url}?v={cache_buster}", False, path
return f"{url}?v={cache_buster}", invert_in_light_mode, path
# Default packaged logo is monochrome and needs darkening in light mode.
return "/static/img/logo.svg", True, None