{{/*
|
IsShown
|
|
Decides whether an optional page element should be rendered.
|
|
The element is shown by default. It is hidden when the site sets
|
`ananke.pages.<key> = false`, unless a page opts back in with
|
`ananke.<key> = true` in its front matter. A page can also hide the
|
element with `ananke.<key> = false`. Sections can set the page value for
|
all of their pages with `cascade`.
|
|
The page key, page fallback, site key, and site fallback are checked in that order.
|
|
@param page The page context.
|
@param key The name of the setting, for example `show_date`.
|
|
@param fallback Optional shared setting to use when the specific key is unset.
|
@return boolean True when the element should be displayed.
|
|
*/}}
|
{{- $keys := slice .key -}}
|
{{- with .fallback -}}
|
{{- $keys = $keys | append . -}}
|
{{- end -}}
|
{{- $show := true -}}
|
{{- $found := false -}}
|
{{- $page_values := .page.Params.ananke | default dict -}}
|
{{- $site_values := site.Params.ananke.pages | default dict -}}
|
{{- range slice $page_values $site_values -}}
|
{{- $values := . -}}
|
{{- range $keys -}}
|
{{- $value := index $values . -}}
|
{{- if and (not $found) (or (eq true $value) (eq false $value)) -}}
|
{{- $show = $value -}}
|
{{- $found = true -}}
|
{{- end -}}
|
{{- end -}}
|
{{- end -}}
|
{{- return $show -}}
|