From 0994df7177b2f397f3977df51475755f66b4d78b Mon Sep 17 00:00:00 2001 From: George Cushen Date: Sun, 18 Apr 2021 20:41:34 +0100 Subject: [PATCH] feat: allow SVG as Hero image --- .../assets/scss/wowchemy/widgets/_hero.scss | 5 +++ wowchemy/layouts/partials/widgets/hero.html | 32 ++++++++++++------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/wowchemy/assets/scss/wowchemy/widgets/_hero.scss b/wowchemy/assets/scss/wowchemy/widgets/_hero.scss index 382d9abd..11a6a386 100644 --- a/wowchemy/assets/scss/wowchemy/widgets/_hero.scss +++ b/wowchemy/assets/scss/wowchemy/widgets/_hero.scss @@ -28,6 +28,11 @@ /* Uncomment to standout on complicated backgrounds. */ } +// Prevent `.home-section.light a` setting text to same color as button bg (the primary color) +.wg-hero.light a.btn { + color: #fff; +} + .wg-hero.dark a:not(.wg-hero .btn) { color: #fff; } diff --git a/wowchemy/layouts/partials/widgets/hero.html b/wowchemy/layouts/partials/widgets/hero.html index 4a7f0321..3cf72473 100644 --- a/wowchemy/layouts/partials/widgets/hero.html +++ b/wowchemy/layouts/partials/widgets/hero.html @@ -64,21 +64,29 @@ {{- $image = resources.Get (path.Join "media" $page.Params.hero_media) -}} {{- end -}} {{ if $image }} - {{ $legacy_img := $image.Resize "400x" }} - {{ $img_src := "" }} - {{ $img_src_set := slice }} - {{ $widths := slice 1200 800 400 }} + {{ $isSVG := eq $image.MediaType.SubType "svg" }} + {{ if $isSVG -}} - {{ range $widths }} - {{ $src_link := ($image.Resize (printf "%dx" .)).RelPermalink }} - {{ if eq $img_src "" }} - {{ $img_src = $src_link }} + {{ $page.Title }} + + {{- else }} + + {{ $legacy_img := $image.Resize "400x" }} + {{ $img_src := "" }} + {{ $img_src_set := slice }} + {{ $widths := slice 1200 800 400 }} + + {{ range $widths }} + {{ $src_link := ($image.Resize (printf "%dx" .)).RelPermalink }} + {{ if eq $img_src "" }} + {{ $img_src = $src_link }} + {{ end }} + {{ $img_src_set = $img_src_set | append (printf "%s %dw" $src_link .) }} {{ end }} - {{ $img_src_set = $img_src_set | append (printf "%s %dw" $src_link .) }} - {{ end }} - {{ $img_src_set = delimit $img_src_set "," }} + {{ $img_src_set = delimit $img_src_set "," }} - {{ $page.Title }} + {{ $page.Title }} + {{ end }} {{ end }}