From 65695c7fa2684d7221a5069cbc27e7f0cfffd892 Mon Sep 17 00:00:00 2001 From: Oscar Najera Date: Sun, 15 Oct 2023 04:43:42 +0200 Subject: Get featured image into the post list & single --- layouts/_default/list.html | 2 +- layouts/_default/single.html | 46 ++++++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 22 deletions(-) (limited to 'layouts/_default') diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 2349bb7..d653b32 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -3,7 +3,7 @@ {{ end }} {{ define "main" }} -
+
{{ range .Paginator.Pages.ByPublishDate.Reverse }} {{ partial "post.html" . }} {{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index bcd733b..61194ed 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,41 +1,45 @@ {{ define "main" }}
-

+

{{ .Title }}

{{ with .Params.subtitle }} -

{{ . }}

+

{{ . }}

{{ end }} - {{ with resources.Get (index .Params.images 0) }} - {{ $image := .Fill (default "400x400" $.Params.image_size) }} -
- {{ .Title }} - {{ with $.Params.caption }} - - {{ .text }} - - {{ end }} + {{ $image := "" }} + {{ if resources.Get (index .Params.images 0) }} + {{ $image = resources.Get (index .Params.images 0) }} + {{ else if (.Resources.ByType "image").GetMatch "*featured*" }} + {{ $image = (.Resources.ByType "image").GetMatch "*featured*" }} + {{ end }} + {{ with $image }} + {{ $image := .Fit (default "400x400" $.Params.image_size) }} +
+
+ {{ .Title }} + {{ with $.Params.caption }} + + {{ .text }} + + {{ end }} +
{{ end }} - {{ if isset .Params "metadata" }} + {{ if in (slice "post" "talk") .Section }} {{ partial "metadata.html" . }} {{ end }}
-
+
{{ .Content }}
- {{ if isset .Params "metadata" }} + {{ if in (slice "post" "talk") .Section }} {{ partial "author_card" . }} {{ end }} {{ partial "post_pager" . }} -- cgit v1.2.3