aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOscar Najera <hi@oscarnajera.com>2023-10-15 04:43:42 +0200
committerOscar Najera <hi@oscarnajera.com>2023-10-15 06:16:46 +0200
commit65695c7fa2684d7221a5069cbc27e7f0cfffd892 (patch)
tree66de0a1909bf3a10bff32d2e9044147401d114a5
parent6c38043107f41a059a103022555a2ddb84e0b944 (diff)
downloadhugo-minimalist-theme-65695c7fa2684d7221a5069cbc27e7f0cfffd892.tar.gz
hugo-minimalist-theme-65695c7fa2684d7221a5069cbc27e7f0cfffd892.tar.bz2
hugo-minimalist-theme-65695c7fa2684d7221a5069cbc27e7f0cfffd892.zip
Get featured image into the post list & single
-rw-r--r--layouts/_default/list.html2
-rw-r--r--layouts/_default/single.html46
-rw-r--r--layouts/partials/post.html10
3 files changed, 34 insertions, 24 deletions
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" }}
- <div class="mw7 center">
+ <div class="mw7 center pa1">
{{ 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" }}
<header class="mw7 center">
- <h2 class="baskerville f2 lh-title mv3">
+ <h2 class="baskerville f2 lh-title mv3 ph1">
{{ .Title }}
</h2>
{{ with .Params.subtitle }}
- <h3 class="f3 baskerville mv3">{{ . }}</h3>
+ <h3 class="f3 baskerville mv3 pa1">{{ . }}</h3>
{{ end }}
- {{ with resources.Get (index .Params.images 0) }}
- {{ $image := .Fill (default "400x400" $.Params.image_size) }}
- <div class="relative">
- <img
- src="{{ $image.RelPermalink }}"
- class="db center"
- alt="{{ .Title }}"
- />
- {{ with $.Params.caption }}
- <a
- href="{{ .url }}"
- class="link near-white absolute bottom-0 right-0 pa2 bg-black-30 br2"
- >
- {{ .text }}
- </a>
- {{ 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) }}
+ <div class="tc">
+ <div class="relative dib">
+ <img src="{{ $image.RelPermalink }}" class="ma0" alt="{{ .Title }}" />
+ {{ with $.Params.caption }}
+ <a
+ href="{{ .url }}"
+ class="link near-white db absolute bottom-0 right-0 pa2 bg-black-30 br2"
+ >
+ {{ .text }}
+ </a>
+ {{ end }}
+ </div>
</div>
{{ end }}
- {{ if isset .Params "metadata" }}
+ {{ if in (slice "post" "talk") .Section }}
{{ partial "metadata.html" . }}
{{ end }}
</header>
- <div class="main-content mw7 center lh-copy f5 f4-ns">
+ <div class="main-content mw7 center lh-copy f5 f4-ns ph1">
{{ .Content }}
</div>
<div class="f5 f4-ns lh-copy pv2">
- {{ if isset .Params "metadata" }}
+ {{ if in (slice "post" "talk") .Section }}
{{ partial "author_card" . }}
{{ end }}
{{ partial "post_pager" . }}
diff --git a/layouts/partials/post.html b/layouts/partials/post.html
index a950810..fa6d485 100644
--- a/layouts/partials/post.html
+++ b/layouts/partials/post.html
@@ -2,7 +2,13 @@
<a class="db no-underline dim near-black" href="{{ .RelPermalink }}">
<h3 class="f3 baskerville mt0 lh-title">{{ .Title }}</h3>
<div class="cf">
- {{ with resources.Get (index .Params.images 0) }}
+ {{ $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 := .Resize (default "320x" .Params.thumbnail_size) }}
<div class="fl-ns mb4 mb0-ns pr3-ns">
<img src="{{ $image.RelPermalink }}" class="db center" />
@@ -14,7 +20,7 @@
</div>
</div>
</a>
- {{ if isset .Params "metadata" }}
+ {{ if in (slice "post" "talk") .Section }}
{{ partial "metadata.html" . }}
{{ end }}
</article>