mirror of https://github.com/theNewDynamic/gohugo-theme-ananke.git

Patrick Kollitsch
10 hours ago c70b22c0c65d21fc25eda46a8182eb042da11da0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{{/*
    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 -}}