mirror of
https://github.com/alex-shpak/hugo-book.git
synced 2025-07-16 19:51:22 +00:00
allow / use thumbnail for blog articles
This commit is contained in:
parent
dcf89964d8
commit
3ea02a86df
@ -134,3 +134,5 @@ enableGitInfo = true
|
|||||||
# /!\ This is an experimental feature, might be removed or changed at any time
|
# /!\ 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.
|
# (Optional, experimental, default false) Enables a drop-down menu for translations only if a translation is present.
|
||||||
BookTranslatedOnly = false
|
BookTranslatedOnly = false
|
||||||
|
# count number of thumbnails that should be shown on posts, default 0
|
||||||
|
thumbnailsPerPost = 0
|
||||||
|
@ -113,3 +113,5 @@ params:
|
|||||||
# /!\ This is an experimental feature, might be removed or changed at any time
|
# /!\ 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.
|
# (Optional, experimental, default false) Enables a drop-down menu for translations only if a translation is present.
|
||||||
BookTranslatedOnly: false
|
BookTranslatedOnly: false
|
||||||
|
# count number of thumbnails that should be shown on posts, default 0
|
||||||
|
thumbnailsPerPost: 0
|
||||||
|
@ -1,13 +1,29 @@
|
|||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
|
{{ $thumbCount := default 0 .Site.Params.thumbnailsPerPost }}
|
||||||
|
|
||||||
{{ range sort .Paginator.Pages }}
|
{{ range sort .Paginator.Pages }}
|
||||||
<article class="markdown book-post">
|
<article class="markdown book-post">
|
||||||
<h2>
|
<h2>
|
||||||
<a href="{{ .RelPermalink }}">{{ partial "docs/title.html" . }}</a>
|
<a href="{{ .RelPermalink }}">{{ partial "docs/title.html" . }}</a>
|
||||||
</h2>
|
</h2>
|
||||||
{{ partial "docs/post-meta" . }}
|
{{ partial "docs/post-meta" . }}
|
||||||
<div class="book-post-content">
|
|
||||||
|
{{ $images := where (.Resources.ByType "image") "MediaType.SubType" "!=" "svg+xml" }}
|
||||||
|
{{ if and (gt (len $images) 0) (gt $thumbCount 0) }}
|
||||||
|
<div class="thumbnails">
|
||||||
|
{{ range first $thumbCount $images }}
|
||||||
|
{{ $thumb := .Fit "200x200" }}
|
||||||
|
<img src="{{ $thumb.RelPermalink }}" alt="Thumbnail for {{ $.Title }}">
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<p>
|
||||||
{{- .Summary -}}
|
{{- .Summary -}}
|
||||||
</div>
|
{{ if .Truncated }}
|
||||||
|
<a href="{{ .RelPermalink }}">...</a>
|
||||||
|
{{ end }}
|
||||||
|
</p>
|
||||||
</article>
|
</article>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user