add background colour to logos

This commit is contained in:
Ben Goldsworthy 2025-06-04 17:33:43 +02:00
parent eb434b2ebe
commit 3e1f9420bf
No known key found for this signature in database

View file

@ -117,12 +117,21 @@
{{ if .IsDescendant ( .GetPage "/cv/organisations" ) }}
<header class="site-content__header">
<div
class="article-header__featured-image"
{{ if .Params.featured_image }}
{{ with .Resources.GetMatch .Params.featured_image }}
style="background-image: url({{ .RelPermalink }}); {{ with .Params.bg }}background-color: {{ . }};{{ end }}"
{{ end }}
{{ end }}
class="article-header__featured-image article-header__featured-image--fit"
{{- with .Params.featured_image -}}
{{- with ( $.Resources.GetMatch . ) -}}
{{- $darkest := "" -}}
{{- $lightest := "" -}}
{{- if not ( in ( slice "avif" "svg" "gif" ) .MediaType.SubType ) -}}
{{- $darkest = index (sort .Colors "Luminance") 0 -}}
{{- $lightest = index (sort .Colors "Luminance" "desc") 0 -}}
{{- end -}}
style="background-image: url({{- partialCached "images/get-image.html" ( dict "img" . ) .Title -}});
background-color: {{ default ( default "#fff" $lightest ) .Params.bg -}};"
{{- else -}}
{{- errorf "No Page Resource found for src '%q' (%q).\n\n\tAvailable Page Resources are:\n\t\t%v" . $.Page.File.Path $.Page.Resources -}}
{{- end -}}
{{- end -}}
>
<div class="article-header__title-wrapper{{ if .Params.title_in_logo }}article-header__title-wrapper--no-title{{ end }}">
<h2 class="article-header__title">