diff --git a/exampleSite/hugo.toml b/exampleSite/hugo.toml index 84fb666..835deb1 100644 --- a/exampleSite/hugo.toml +++ b/exampleSite/hugo.toml @@ -134,3 +134,5 @@ enableGitInfo = true # /!\ This is an experimental feature, might be removed or changed at any time # (Optional, experimental, default false) Enables a drop-down menu for translations only if a translation is present. BookTranslatedOnly = false + # count number of thumbnails that should be shown on posts, default 0 + thumbnailsPerPost = 0 diff --git a/exampleSite/hugo.yaml b/exampleSite/hugo.yaml index 3fd0c40..3c780a3 100644 --- a/exampleSite/hugo.yaml +++ b/exampleSite/hugo.yaml @@ -113,3 +113,5 @@ params: # /!\ This is an experimental feature, might be removed or changed at any time # (Optional, experimental, default false) Enables a drop-down menu for translations only if a translation is present. BookTranslatedOnly: false + # count number of thumbnails that should be shown on posts, default 0 + thumbnailsPerPost: 0 diff --git a/layouts/posts/list.html b/layouts/posts/list.html index dd0d76d..f4fdc58 100644 --- a/layouts/posts/list.html +++ b/layouts/posts/list.html @@ -1,13 +1,29 @@ {{ define "main" }} + {{ $thumbCount := default 0 .Site.Params.thumbnailsPerPost }} + {{ range sort .Paginator.Pages }}

{{ partial "docs/title.html" . }}

{{ partial "docs/post-meta" . }} -
+ + {{ $images := where (.Resources.ByType "image") "MediaType.SubType" "!=" "svg+xml" }} + {{ if and (gt (len $images) 0) (gt $thumbCount 0) }} +
+ {{ range first $thumbCount $images }} + {{ $thumb := .Fit "200x200" }} + Thumbnail for {{ $.Title }} + {{ end }} +
+ {{ end }} + +

{{- .Summary -}} -

+ {{ if .Truncated }} + ... + {{ end }} +

{{ end }}