From 96067c95c0e37dca87cd731eb5f35b34e4603ab0 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Tue, 19 Oct 2021 14:01:35 -0500 Subject: [PATCH] Automatically add the featured media to individual posts --- layouts/_default/single.html | 4 ++++ layouts/_default/summary.html | 19 +------------------ layouts/partials/featured_media.html | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 layouts/partials/featured_media.html diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 990d118..2278fe2 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -17,5 +17,9 @@
+{{ with .Resources.GetMatch "feature" }} +{{ partial "featured_media.html" . }} +{{ end }} + {{ .Content }} {{ end }} diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html index fd83cf1..469793e 100644 --- a/layouts/_default/summary.html +++ b/layouts/_default/summary.html @@ -12,24 +12,7 @@ {{ partial "post-metadata.html" . }} {{ with .Resources.GetMatch "feature" }} -
-
- {{ $media := . | resources.Fingerprint "sha512" }} - {{ if eq .MediaType.MainType "image" }} - {{ $media.Title }} - {{ else if eq .MediaType.MainType "video" }} - - {{ end }} - - {{ with $media.Title }} -
- {{ . | markdownify }} -
- {{ end }} -
-
+ {{ partial "featured_media.html" . }} {{ end }}
diff --git a/layouts/partials/featured_media.html b/layouts/partials/featured_media.html new file mode 100644 index 0000000..3212e03 --- /dev/null +++ b/layouts/partials/featured_media.html @@ -0,0 +1,18 @@ +
+
+ {{ $media := . | resources.Fingerprint "sha512" }} + {{ if eq .MediaType.MainType "image" }} + {{ $media.Title }} + {{ else if eq .MediaType.MainType "video" }} + + {{ end }} + + {{ with $media.Title }} +
+ {{ . | markdownify }} +
+ {{ end }} +
+