From c9fa6c7915d275cbef1739a5b919e014e18ccb98 Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Tue, 29 Dec 2020 16:44:03 +0530 Subject: [PATCH] cover: granular controls for hiding cover image #156 in site config => params: cover: hidden: true # hide everywhere but not in structured data hiddenInList: true # hide on list pages and home hiddenInSingle: true # hide on single page per-page in front-matter => hidden: true # only hide on current single page --- layouts/_default/list.html | 3 ++- layouts/_default/single.html | 3 ++- layouts/partials/cover.html | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/layouts/_default/list.html b/layouts/_default/list.html index b196ae5c..b6ddbfa5 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -31,7 +31,8 @@ {{- $class = "post-entry tag-entry" }} {{- end }}
- {{- partial "cover.html" (dict "cxt" . "IsHome" true) }} + {{- $isHidden := (.Site.Params.cover.hidden | default .Site.Params.cover.hiddenInList)}} + {{- partial "cover.html" (dict "cxt" . "IsHome" true "isHidden" $isHidden) }}

{{ .Title }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 607841b0..21e8e793 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -28,7 +28,8 @@ {{- end}}

- {{- partial "cover.html" (dict "cxt" . "IsHome" false) }} + {{- $isHidden := ((.Site.Params.cover.hidden | default .Site.Params.cover.hiddenInSingle) | default .Params.cover.hidden )}} + {{- partial "cover.html" (dict "cxt" . "IsHome" false "isHidden" $isHidden) }} {{- if .Params.ShowToc }}
diff --git a/layouts/partials/cover.html b/layouts/partials/cover.html index 86ee4894..5ff16bc0 100644 --- a/layouts/partials/cover.html +++ b/layouts/partials/cover.html @@ -1,5 +1,5 @@ {{- with .cxt}} {{/* Apply proper context from dict */}} -{{- if .Params.cover.image }} +{{- if (and .Params.cover.image (not $.isHidden)) }} {{- $alt := (.Params.cover.alt | default .Params.cover.caption | plainify) }}
{{- $addLink := (and .Site.Params.cover.linkFullImages (not $.IsHome)) }}