From: Danilo M. Date: Sat, 18 Apr 2026 18:03:54 +0000 (+0200) Subject: feat: theme-aware default thumbnails with picture element X-Git-Tag: release_22042026-1342~88 X-Git-Url: https://git.danix.xyz/?a=commitdiff_plain;h=a05ea86f931b17b0599960a6d496af842b527f00;p=danix.xyz-2.git feat: theme-aware default thumbnails with picture element - Use HTML element with prefers-color-scheme media query - Fallback dark thumbnail via content: url() CSS for theme-light class - Automatically displays light/dark thumbnails based on user theme - Articles without custom images now show default thumbnails - Maintains all existing hover effects and type badges Co-Authored-By: Claude Haiku 4.5 --- diff --git a/static/images/default_thumbnail_dark.png b/static/images/default_thumbnail_dark.png new file mode 100644 index 0000000..c054b7a Binary files /dev/null and b/static/images/default_thumbnail_dark.png differ diff --git a/static/images/default_thumbnail_light.png b/static/images/default_thumbnail_light.png new file mode 100644 index 0000000..7bf35bc Binary files /dev/null and b/static/images/default_thumbnail_light.png differ diff --git a/themes/danix-xyz-hacker/assets/css/main.css b/themes/danix-xyz-hacker/assets/css/main.css index a2f6b09..f618f2d 100644 --- a/themes/danix-xyz-hacker/assets/css/main.css +++ b/themes/danix-xyz-hacker/assets/css/main.css @@ -72,6 +72,11 @@ html.theme-light { } } +/* Theme-aware picture element for default thumbnails */ +html.theme-light picture img[src="/images/default_thumbnail_dark.png"] { + content: url('/images/default_thumbnail_light.png'); +} + @layer base { html { @apply overflow-x-hidden; diff --git a/themes/danix-xyz-hacker/assets/css/main.min.css b/themes/danix-xyz-hacker/assets/css/main.min.css index 899978a..d928b7a 100644 --- a/themes/danix-xyz-hacker/assets/css/main.min.css +++ b/themes/danix-xyz-hacker/assets/css/main.min.css @@ -2532,6 +2532,12 @@ html.theme-light { } } +/* Theme-aware picture element for default thumbnails */ + +html.theme-light picture img[src="/images/default_thumbnail_dark.png"] { + content: url('/images/default_thumbnail_light.png'); +} + /* Prose overrides for light theme */ html.theme-light .prose, diff --git a/themes/danix-xyz-hacker/layouts/partials/article-list-item.html b/themes/danix-xyz-hacker/layouts/partials/article-list-item.html index d473e9a..d0ab504 100644 --- a/themes/danix-xyz-hacker/layouts/partials/article-list-item.html +++ b/themes/danix-xyz-hacker/layouts/partials/article-list-item.html @@ -4,6 +4,7 @@ {{ $excerpt := .Description | default .Summary }} {{ $imageURL := "" }} +{{ $useDefaultThumbnail := false }} {{ if .Params.image }} {{ $resource := .Resources.GetMatch .Params.image }} {{ if $resource }} @@ -11,18 +12,32 @@ {{ else }} {{ $imageURL = .Params.image }} {{ end }} +{{ else }} + {{ $useDefaultThumbnail = true }} {{ end }}