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
This commit is contained in:
Aditya Telange 2020-12-29 16:44:03 +05:30
parent e252e761f5
commit c9fa6c7915
No known key found for this signature in database
GPG Key ID: 82E844EF3DA99E77
3 changed files with 5 additions and 3 deletions

View File

@ -31,7 +31,8 @@
{{- $class = "post-entry tag-entry" }}
{{- end }}
<article class="{{ $class }}">
{{- 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) }}
<header class="entry-header">
<h2>
{{ .Title }}

View File

@ -28,7 +28,8 @@
</div>
{{- end}}
</header>
{{- 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 }}
<div class="toc">
<details {{if .Params.TocOpen }} open{{ end }}>

View File

@ -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) }}
<figure class="entry-cover">
{{- $addLink := (and .Site.Params.cover.linkFullImages (not $.IsHome)) }}