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" }} {{- $class = "post-entry tag-entry" }}
{{- end }} {{- end }}
<article class="{{ $class }}"> <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"> <header class="entry-header">
<h2> <h2>
{{ .Title }} {{ .Title }}

View File

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

View File

@ -1,5 +1,5 @@
{{- with .cxt}} {{/* Apply proper context from dict */}} {{- 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) }} {{- $alt := (.Params.cover.alt | default .Params.cover.caption | plainify) }}
<figure class="entry-cover"> <figure class="entry-cover">
{{- $addLink := (and .Site.Params.cover.linkFullImages (not $.IsHome)) }} {{- $addLink := (and .Site.Params.cover.linkFullImages (not $.IsHome)) }}