Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.html « layouts - github.com/wangchucheng/hugo-eureka.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d13ecceb1dd7dc47fa9775c5888b34726927b6f6 (plain)
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
{{- define "main" }}
  {{ $homepage := .Site.GetPage "homepage" }}
  {{ $widgets := $homepage.Resources }}
  {{ range $widgets }}
    {{ if .Params.widget.handler }}
      {{ partial "widgets/load" . }}
    {{ else }}
      {{ errorf "Failed to find widget param in %q" .Path }}
    {{ end }}

    {{/* Deprecation warning(v1.0.0) starts */}}
  {{ else }}
    {{ warnf "Param 'hero' in params.toml is deprecated and will be removed in Eureka v1.0.0. See https://www.wangchucheng.com/en/docs/hugo-eureka/homepage-configuration/" }}
    <div class="bg-secondary-bg pl-scrollbar">
      <div class="mx-auto max-w-screen-xl">
        <div class="h-(screen-16) grid grid-cols-9 grid-rows-5">
          {{- $imgLeft := partial "utils/get-image" (dict "context" . "url" .Site.Params.hero.imgLeft) }}
          {{- with $imgLeft }}
            <div
              class="z-10 col-span-4 col-start-2 row-span-2 row-start-3 bg-cover bg-local shadow-2xl"
              style="background-image: url({{ . }});"
            ></div>
          {{- end }}


          <div class="z-20 col-span-5 col-start-3 row-span-3 row-start-2">
            <div class="flex min-h-full flex-col items-center justify-center">
              <div class="-m-12 bg-white bg-opacity-75 p-12 shadow-2xl">
                <span
                  class="text-2xl font-bold text-black text-opacity-75 md:text-3xl"
                  >{{ .Site.Params.hero.slogan }}</span
                >
              </div>
            </div>
          </div>
          {{- $imgRight := partial "utils/get-image" (dict "context" . "url" .Site.Params.hero.imgRight) }}
          {{- with $imgRight }}
            <div
              class="col-span-4 col-start-5 row-span-2 row-start-2 bg-cover bg-local shadow-2xl"
              style="background-image: url({{ . }});"
            ></div>
          {{- end }}
        </div>
      </div>
    </div>
    <div class="pl-scrollbar">
      <div class="mx-auto max-w-screen-xl">
        <div class="pt-12 md:px-4 xl:px-8">
          {{- $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}
          {{- partial "components/masonry" $pages }}
        </div>
      </div>
    </div>
    {{/* Deprecation warning(v1.0.0) ends */}}

  {{ end }}
{{- end }}

{{ define "partials/widgets/load" }}
  {{ $widget := .Params.widget }}

  {{ $fullScreenWidgets := slice "vintage" }}

  {{/* background config */}}
  {{ $backgroundClass := "" }}
  {{ $backgroundStyle := "" }}

  {{ if $widget.background.image }}
    {{ $image := partial "utils/get-image.html" (dict "context" . "url" $widget.background.image) }}
    {{ $backgroundStyle = print $backgroundStyle "background-image: url(" $image ");" }}
    {{/* background size */}}
    {{ $size := $widget.background.size }}
    {{ $sizeOptions := dict "auto" "bg-auto" "cover" "bg-cover" "contain" "bg-contain" }}
    {{ if $size }}
      {{ $size = index $sizeOptions $size }}
      {{ if $size }}
        {{ $backgroundClass = print $backgroundClass " " $size }}
      {{ else }}
        {{/* TODO error */}}
      {{ end }}
    {{ end }}

    {{/* background position */}}
    {{ $position := $widget.background.position }}
    {{ $positionOptions := dict "center" "bg-center" "top" "bg-top" "right" "bg-right" "bottom" "bg-bottom" "left" "bg-left" }}
    {{ if $position }}
      {{ $position = index $positionOptions $position }}
      {{ if $position }}
        {{ $backgroundClass = print $backgroundClass " " $position }}
      {{ else }}
        {{/* TODO error */}}
      {{ end }}
    {{ end }}

    {{/* background position */}}
    {{ $attachment := $widget.background.attachment }}
    {{ $attachmentOptions := dict "fixed" "bg-fixed" "local" "bg-local" "scroll" "bg-scroll" }}
    {{ if $attachment }}
      {{ $attachment = index $attachmentOptions $attachment }}
      {{ if $attachment }}
        {{ $backgroundClass = print $backgroundClass " " $attachment }}
      {{ else }}
        {{/* TODO error */}}
      {{ end }}
    {{ end }}

  {{ else }}
    {{/* background color */}}
    {{ $color := $widget.background.color }}
    {{ $colorOptions := dict "primary" "bg-primary-bg" "secondary" "bg-secondary-bg" "tertiary" "bg-tertiary-bg" }}
    {{ if $color }}
      {{ $colorClass := index $colorOptions $color }}
      {{ if $colorClass }}
        {{ $backgroundClass = print $backgroundClass " " $colorClass }}
      {{ else }}
        {{ $backgroundStyle = print $backgroundStyle "background-color: " $color ";" }}
      {{ end }}
    {{ else }}
      {{ $colorClass := index $colorOptions "primary" }}
      {{ $backgroundClass = print $backgroundClass " " $colorClass }}
    {{ end }}
  {{ end }}

  {{/* widget config */}}
  {{ $widgetClass := "" }}

  {{ if not (in $fullScreenWidgets $widget.handler) }}
    {{/* widget width */}}
    {{ $width := $widget.width }}
    {{ $widthOptions := dict "sm" "lg:w-2/3" "md" "lg:w-3/4" "lg" "lg:w-4/5" "xl" "w-full" }}
    {{ if $width }}
      {{ $widthClass := index $widthOptions $width }}
      {{ if $widthClass }}
        {{ $widgetClass = print $widgetClass " " $widthClass }}
      {{ end }}
    {{ else }}
      {{ $widthClass := index $widthOptions "md" }}
      {{ $widgetClass = print $widgetClass " " $widthClass }}
    {{ end }}

    {{/* widget height */}}
    {{ $height := $widget.height }}
    {{ $heightOptions := dict "sm" "h-64" "md" "h-96" "lg" "h-128" "xl" "h-160" "screen" "h-(screen-16)" }}
    {{ if $height }}
      {{ $heightClass := index $heightOptions $height }}
      {{ if $heightClass }}
        {{ $widgetClass = print $widgetClass " " $heightClass }}
      {{ end }}
    {{ end }}
    {{ $widgetClass = print $widgetClass " mx-auto px-6 md:px-8 xl:px-12 py-12" }}
  {{ end }}


  <div
    class="pl-scrollbar {{ with $backgroundClass -}}
      {{ partial "utils/standardize-classes" . }}
    {{- end }}"
    {{ with $backgroundStyle }}style="{{ . | safeCSS }}"{{ end }}
  >
    <div class="mx-auto max-w-screen-xl">
      <div
        id="{{ .File.BaseFileName }}"
        class="{{ with $widgetClass -}}
          {{ partial "utils/standardize-classes" . }}
        {{- end }}"
      >
        {{ partial "widgets/load-sidebar" . }}
      </div>
    </div>
  </div>
{{ end }}

{{ define "partials/widgets/load-sidebar" }}
  {{ $sidebar := .Params.widget.sidebar }}

  {{ if $sidebar.position }}

    {{ $scaleClass := "" }}
    {{/* widget width */}}
    {{ $scale := $sidebar.scale }}
    {{ $scaleOptions := dict "sm" "lg:w-1/5" "md" "lg:w-1/4" "lg" "lg:w-1/3" "xl" "lg:w-1/2" }}
    {{ if $scale }}
      {{ $scaleClass = index $scaleOptions $scale }}
    {{ else }}
      {{ $scaleClass = index $scaleOptions "md" }}
    {{ end }}
    <div
      class="{{ if eq $sidebar.position "right" -}}
        lg:flex-row-reverse
      {{- else -}}
        lg:flex-row
      {{- end }} flex flex-col"
    >
      <div
        class="{{ with $scaleClass -}}
          {{ partial "utils/standardize-classes" . }}
        {{- end }} {{ if eq $sidebar.position "left" -}}
          lg:me-4
        {{- else -}}
          lg:ms-4
        {{- end }} flex-none"
      >
        <h2 class="my-4 text-3xl font-bold">{{ .Params.Title }}</h2>
      </div>
      <div
        class="{{ if eq $sidebar.position "right" -}}
          lg:me-4
        {{- else -}}
          lg:ms-4
        {{- end }} grow"
      >
        {{/* Deprecation warning(v1.0.0) starts */}}
        {{- if eq .Params.widget.handler "experiences" }}
          {{- warnf "Value `experiences` for `widget.handler` in %s is deprecated and will be removed in Eureka v1.0.0. Please use `experience` instead." .File.Path }}
          {{ partial (printf "widgets/%s" "experience") . }}
        {{- else }}
          {{/* Deprecation warning(v1.0.0) ends */}}
          {{ partial (printf "widgets/%s" .Params.widget.handler) . }}
          {{/* Deprecation warning(v1.0.0) starts */}}
        {{- end }}
        {{/* Deprecation warning(v1.0.0) ends */}}

      </div>
    </div>
  {{ else }}
    {{/* Deprecation warning(v1.0.0) starts */}}
    {{- if eq .Params.widget.handler "experiences" }}
      {{- warnf "Value `experiences` for `widget.handler` in %s is deprecated and will be removed in Eureka v1.0.0. Please use `experience` instead." .File.Path }}
      {{ partial (printf "widgets/%s" "experience") . }}
    {{- else }}
      {{/* Deprecation warning(v1.0.0) ends */}}
      {{ partial (printf "widgets/%s" .Params.widget.handler) . }}
      {{/* Deprecation warning(v1.0.0) starts */}}
    {{- end }}
    {{/* Deprecation warning(v1.0.0) ends */}}
  {{ end }}
{{ end }}