From bd924ee52abf96ef3f6352b7b2926d9900ae5ff9 Mon Sep 17 00:00:00 2001
From: Oscar Najera <hi@oscarnajera.com>
Date: Sun, 15 Oct 2023 15:45:53 +0200
Subject: Hero background gradient and post images default

Feature image has precedence
Can have svg feature images. That implies container must have max width
---
 layouts/partials/hero.html |  8 ++++++--
 layouts/partials/post.html | 17 ++++++++++++-----
 2 files changed, 18 insertions(+), 7 deletions(-)

(limited to 'layouts/partials')

diff --git a/layouts/partials/hero.html b/layouts/partials/hero.html
index 4729291..1926f04 100644
--- a/layouts/partials/hero.html
+++ b/layouts/partials/hero.html
@@ -1,5 +1,9 @@
-<div style="background: linear-gradient( rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.5) ){{ with .Params.images }}, url('{{ index . 0 }}'){{ end }}; background-position: center;"
-     class="bg-center pv5" >
+<div
+  style="background: linear-gradient( rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.15) ){{ with resources.Get (index .Params.images 0) }}
+    , url('{{ .RelPermalink }}')
+  {{ end }}; background-position: center;"
+  class="pv5"
+>
   <div class="mw7 center ph2 near-white">
     <h1 class="f1 tc title berkshire-swash">{{ .Title }}</h1>
     {{ .Content }}
diff --git a/layouts/partials/post.html b/layouts/partials/post.html
index fa6d485..fe24ad9 100644
--- a/layouts/partials/post.html
+++ b/layouts/partials/post.html
@@ -3,15 +3,22 @@
     <h3 class="f3 baskerville mt0 lh-title">{{ .Title }}</h3>
     <div class="cf">
       {{ $image := "" }}
-      {{ if resources.Get (index .Params.images 0) }}
-        {{ $image =  resources.Get (index .Params.images 0) }}
-      {{ else if (.Resources.ByType "image").GetMatch "*featured*" }}
+      {{ if (.Resources.ByType "image").GetMatch "featured*" }}
         {{ $image =  (.Resources.ByType "image").GetMatch "*featured*" }}
+      {{ else if resources.Get (index .Params.images 0) }}
+        {{ $image =  resources.Get (index .Params.images 0) }}
       {{ end }}
       {{ with $image }}
-        {{ $image := .Resize (default "320x" .Params.thumbnail_size) }}
         <div class="fl-ns mb4 mb0-ns pr3-ns">
-          <img src="{{ $image.RelPermalink }}" class="db center" />
+          <img
+            src="{{ if ne .MediaType.SubType "svg" }}
+              {{ $image := .Resize (default "320x" .Params.thumbnail_size) }}
+              {{ $image.RelPermalink }}
+            {{ else }}
+              {{ $image.RelPermalink }}
+            {{ end }}"
+            class="mw5-ns db center"
+          />
         </div>
       {{ end }}
       <div class="f5 lh-copy">
-- 
cgit v1.2.3