File size: 9,507 Bytes
bc8bf33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
{{- define "partials/taxonomies.html" -}}
    {{ "<!-- taxonomies.html -->" | safeHTML }}
    {{- $taxonomy := .taxonomy }}
    {{- $tags := eq $taxonomy "tags"}}
    {{- $class := .class }}
    {{- $cover := .cover }}
    {{- $limit := .limit }}
    {{- with index site.Taxonomies $taxonomy }}
        <ul class="{{ $class }}" role="presentation">
            {{- $index := 0 }}
            {{ range . -}}
                {{- $index = add $index 1 }}
                {{- if or (le $index $limit) (not $limit) -}}
                    {{- $src := partial "partials/page/cover.html" (dict "page" .Page) }}
                    {{- if not $src}}
                        {{- $src = partial "partials/flowlines.html" . }}
                    {{- end }}
                    <li  {{ if $cover }}style="background-image:url({{ $src }});"{{ end }}>
                        <a href="{{ .Page.Permalink }}"
                            aria-label="{{ i18n $taxonomy 1 }}:{{ .Page.Title }}"
                            data-post-counter="{{ printf "%d" .Count }}"
                            >
                            <span>{{ humanize .Page.Title | title }}</span>
                        </a>
                        {{- /* workaround needed */}}
                        {{- /*  {{- if eq $taxonomy "categories" }}
                            <ul role="presentation">
                                {{ $postWithin := where site.RegularPages "Params.categories" "intersect" .Page.Title }}
                                {{- range first 5 $postWithin }}
                                    <li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
                                {{- end }}
                            </ul>
                        {{- end }}  */}}
                    </li>
                {{- end }}
            {{- end }}
        </ul>
    {{- end }}
{{- end }}

{{- define "partials/terms.html" -}}
    {{ "<!-- terms.html -->" | safeHTML }}
    {{- $page := .page }}
    {{- $taxonomy := .taxonomy }}
    {{- $class := .class }}
    {{- with $page.GetTerms $taxonomy }}
    <ul class="{{ $class }}" role="presentation">
        {{- range . }}
            <li><a href="{{ .RelPermalink }}">{{ humanize .LinkTitle | title }}</a></li>
        {{- end }}
    </ul>
    {{- end }}
{{- end }}

{{- define "partials/paginator.html" -}}
    {{ "<!-- paginator.html -->" | safeHTML }}
    {{- $pagerSize := .Params.Paginate }}
    {{- $pages := .RegularPagesRecursive }}
    {{- if .IsHome }}
        {{- $pages =  where site.RegularPages "Type" (or "post" "articles") }}
    {{- end }}
    {{- $paginator := .Paginate $pages }}
    {{- if $pagerSize }}
        {{- $paginator = .Paginate $pages $pagerSize }}
    {{- end }}
    {{- return $paginator }}
{{- end }}

{{- define "partials/coffeeStat.html" }}
    {{- $cups := 0 }}
    {{- range site.RegularPages }}
        {{- range .AllTranslations }}
            {{- with .Params.Coffee }}
                {{- $cups = add $cups . }}
            {{- end }}
        {{- end }}
    {{- end }}
    {{- return $cups }}
{{- end }}

{{- define "partials/hero.html" }}
    {{ "<!-- hero.html -->" | safeHTML }}
    <div class="hero">
        <div class="hero__image">
            {{- $src := partial "page/cover.html" (dict "page" . ) }}
            {{- $alt := or .Params.Alt .Params.coverAlt .Params.imagesAlt }}
            {{- if $src }}
                <img src="{{ $src }}" alt="{{ with $alt }}{{ . }}{{ end }}" role="doc-cover"/>
            {{- end }}
        </div>
        <div class="hero__content">
            {{- .Content }}
            {{- /*

                author page hero extras  */}}
            {{- if and (eq .Kind "term")  (eq .Data.Singular "author") }}
                {{- $authorName := .Title }}
                {{- $co := or site.Params.Author.coauthor site.Params.Author.collabolator }}
                {{- range $co }}
                    {{- if eq $authorName .name }}
                        <p>{{  or .bio .about }}</p>
                    {{- end }}
                {{- end }}
                {{- $author := urlize .Title }}
                {{/*

                    author's social links */}}
                {{ partial "menu.html" (dict "menuID" $author "open" "open" "page" .)}}
            {{- end }}
        </div>
    </div>
{{ end }}

{{- define "partials/list/sections.html" -}}
    {{ "<!-- sections.html -->" | safeHTML }}
    {{- $page := .page }}
    {{- $class := .class }}
    {{- $limit := .limit }}
    {{- $cover := .cover }}
    {{- $getCover := .Resources.GetMatch "cover.*" }}
    {{- with $page.Sections }}
        <ul class="{{ $class }}" role="presentation">
            {{- $index := 0 }}
            {{- range . }}
                {{- $index = add $index 1 }}
                {{- if or (le $index $limit) (not $limit) }}
                {{- $src := false }}
                {{- $images := or .Page.Params.cover .Page.Params.images }}
                {{- if $images }}
                    {{- $src = $images }}
                {{- else if $getCover }}
                    {{- $src = $getCover.Permalink }}
                {{- else }}
                    {{- $src = partial "flowlines.html" . }}
                {{- end }}
                <li {{ if $cover}}style="background-image:url({{ $src }});"{{ end }}>
                    <a href="{{ .Page.Permalink }}" aria-label="{{ i18n "section" 1 }}:{{ .Page.Title }}">
                        <span>{{ .Page.Title }}</span>
                    </a>
                </li>
                {{- end }}
            {{- end }}
        </ul>
    {{- end }}
{{ end }}

{{- define "partials/listing.html" -}}
    {{ "<!-- listing.html -->" | safeHTML }}
    {{- $entry := .entry }}
    {{- if index site.Taxonomies $entry }}
        <div id="list-{{ $entry }}" class="carousel">
            <header class="section-title">{{ i18n $entry }}</header>
            {{ partial "taxonomies.html" (dict "taxonomy" $entry "class" "carousel__viewport" "cover" true) }}
        </div>
    {{- end }}
{{- end }}

{{- define "partials/carousel.html" -}}
    {{ "<!-- carousel.html -->" | safeHTML }}
    {{- $slides := where .Site.RegularPages "Type" "slide" }}
    {{- with $slides }}
        <aside class="carousel">
            {{- $numSlides := len . }}
            {{- if gt $numSlides 2 }}
                <nav class="carousel__nav">
                    <ul class="rounded invert" role="presentation">
                        {{- range $index, $slide := . }}
                            <li>
                                <a href="#slide-{{ add $index 1 }}" role="button" aria-controls="slide-{{ add $index 1 }}">
                                    <span>{{ .Title }}</span>
                                </a>
                            </li>
                        {{- end }}
                    </ul>
                </nav>
            {{- end }}

            <div class="carousel__viewport">
                {{- range $index, $slide := . }}
                    {{- $slideNum := add $index 1 }}
                    <section id="slide-{{ $slideNum }}" class="carousel__viewport__slide{{ with .Params.Background }} has-background{{ end }}"
                        aria-labelledby="slide-{{ $slideNum }}__heading">
                        {{- $hasCover := partial "partials/page/cover.html" (dict "page" .Page) }}
                        {{- $alt := or .Page.Params.Alt .Page.Params.coverAlt .Page.Params.imagesAlt }}
                        {{- if or $hasCover }}
                        <div class="carousel__viewport__slide__cover">
                            <img src="{{ $hasCover }}"
                                alt="{{ with $alt }}{{ . }}{{ end }}" {{ if ne $slideNum 1 }}loading="lazy"{{ end }}>
                        </div>
                        {{- end }}
                        <div class="carousel__viewport__slide__content">
                            {{- with .Title }}
                                <h1 id="slide-{{ $slideNum }}__heading" class="section-title">{{ . }}</h1>
                            {{- end }}
                            <div>
                                {{- if or .Params.task $.Site.Params.Post.enableCheckbox }}
                                    {{ replace .Content "disabled=" "" | safeHTML }}
                                {{- else }}
                                    {{ .Content }}
                                {{- end }}
                            </div>
                        </div>
                        {{- /*

                            simple prev/next pair for 2 slides */}}
                        {{- if eq $numSlides 2 }}
                            <nav class="carousel__nav">
                                {{- range $navIndex, $navSlide := $slides }}
                                    {{- if ne $slideNum (add $navIndex 1) }}
                                    {{ $rel := cond (eq $navIndex 1) "next" "prev" }}
                                        <a href="#slide-{{ add $navIndex 1 }}" rel="{{ $rel }}" class="underline" role="button" aria-controls="slide-{{ add $navIndex 1 }}">
                                            <span>{{ .Title }}</span>
                                        </a>
                                    {{- end }}
                                {{- end }}
                            </nav>
                        {{- end }}
                    </section>
                {{- end }}
            </div>
        </aside>
    {{- end }}
{{- end }}