feat: add preview_only option for featured image

Add `preview_only = true` under `[image]` in a page's front matter to
only show featured image in page previews and not on the page itself.

Example: https://raw.githubusercontent.com/gcushen/hugo-academic/master/exampleSite/content/post/getting-started/index.md

Close #789
See #728
This commit is contained in:
George Cushen committed 2018-11-03 23:42:15 +00:00
1 parent 0ff174bbf4
commit d930502a55
2 files changed
+6 -3

No files matched your search

@@ -30,6 +30,9 @@ summary = "Create a beautifully simple website or blog in under 10 minutes."
# Options: Smart, Center, TopLeft, Top, TopRight, Left, Right, BottomLeft, Bottom, BottomRight
focal_point = ""
# Show image only in page previews?
preview_only = false
# Set captions for image gallery.
[[gallery_item]]
+3 -3
View File
@@ -29,14 +29,14 @@
{{end}}
{{/* Featured image */}}
{{ with $featured }}
{{ $image := .Fill (printf "1600x400 q90 %s" $anchor) }}
{{ if and $featured (not $.Params.image.preview_only) }}
{{ $image := $featured.Fill (printf "1600x400 q90 %s" $anchor) }}
<div class="article-header d-xl-none">
<img src="{{ $image.RelPermalink }}" class="article-banner" itemprop="image" alt="">
{{ with $.Params.image.caption }}<span class="article-header-caption">{{ . | markdownify | emojify }}</span>{{ end }}
</div>
{{ $image := .Fill (printf "680x500 q90 %s" $anchor) }}
{{ $image := $featured.Fill (printf "680x500 q90 %s" $anchor) }}
<div class="container-fluid split-header d-none d-xl-block">
<div class="row">
<div class="col-6">