-
Notifications
You must be signed in to change notification settings - Fork 87
/
gallery.html
96 lines (92 loc) · 5.73 KB
/
gallery.html
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
<section class="gallery" id="work">
<div class="row">
{{ $galleryTotal := len (where .Site.RegularPages "Section" "gallery") }}
{{ $galleryReverse := (where .Site.RegularPages.Reverse "Section" "gallery") }}
<!-- Where gallery is an odd total -->
{{ if not (modBool $galleryTotal 2) }}
<!-- Where gallery is only one item, display it fully -->
{{ if eq $galleryTotal 1 }}
{{ range first 3 $galleryReverse }}
<div class="col-xs-12" onclick {{ if .Params.color }}style="background-color:{{ .Params.color }}"{{ end }}>
<img src="{{ .Params.image}}" {{ if .Params.alt }}alt="{{ .Params.alt }}"{{ end }}>
<div class="row middle-xs center-xs overlay">
<div class="col-xs-12">
<h2>{{ .Title }}</h2>
<div class="row middle-xs center-xs">
{{ if .Params.link1 }}<div class="col-xs-3 col-md-4"><h3><a href="{{ .Params.link1 }}">{{ i18n "view" }}</a></h3></div>{{ end }}
{{ if .Params.link2 }}<div class="col-xs-3 col-md-4"><h3><a href="{{ .Params.link2 }}">{{ i18n "code" }}</a></h3></div>{{ end }}
</div>
</div>
</div>
</div>
{{ end }}
{{ end }}
<!-- Where gallery is greater than 2 items, first 3 items display together on first row -->
{{ if gt $galleryTotal 2 }}
{{ range first 3 $galleryReverse }}
<div class="col-xs-12 col-md-4" onclick {{ if .Params.color }}style="background-color:{{ .Params.color }}"{{ end }}>
<img src="{{ .Params.image}}" {{ if .Params.alt }}alt="{{ .Params.alt }}"{{ end }}>
<div class="row middle-xs center-xs overlay">
<div class="col-xs-12">
<h2>{{ .Title }}</h2>
<div class="row middle-xs center-xs">
{{ if .Params.link1 }}<div class="col-xs-3 col-md-4"><h3><a href="{{ .Params.link1 }}">{{ i18n "view" }}</a></h3></div>{{ end }}
{{ if .Params.link2 }}<div class="col-xs-3 col-md-4"><h3><a href="{{ .Params.link2 }}">{{ i18n "code" }}</a></h3></div>{{ end }}
</div>
</div>
</div>
</div>
{{ end }}
{{ end }}
<!-- Where gallery is greater than 3 items, all items after the first 3 display evenly in grid colums and rows -->
{{ if gt $galleryTotal 3 }}
{{ range after 3 $galleryReverse }}
<!-- Where gallery items are divisible by 3, they will appear in columns of 3 -->
{{ $col := (mod $galleryTotal 3) }}
<div class="col-xs-12 col-md-6
{{ if gt $galleryTotal 5 }}
{{ if eq $col 0 }} col-lg-4
{{ else }} col-lg-3
{{ end }}
{{ end }}" onclick {{ if .Params.color }}style="background-color:{{ .Params.color }}"{{ end }}>
<img src="{{ .Params.image}}" {{ if .Params.alt }}alt="{{ .Params.alt }}"{{ end }}>
<div class="row middle-xs center-xs overlay">
<div class="col-xs-12">
<h2>{{ .Title }}</h2>
<div class="row middle-xs center-xs">
{{ if .Params.link1 }}<div class="col-xs-3 col-md-4"><h3><a href="{{ .Params.link1 }}">{{ i18n "view" }}</a></h3></div>{{ end }}
{{ if .Params.link2 }}<div class="col-xs-3 col-md-4"><h3><a href="{{ .Params.link2 }}">{{ i18n "code" }}</a></h3></div>{{ end }}
</div>
</div>
</div>
</div>
{{ end }}
{{ end }}
{{ end }}
<!-- Where gallery is an even total, all items display evenly in grid columns and rows -->
{{ if modBool $galleryTotal 2 }}
{{ range $galleryReverse }}
<!-- Where gallery items are great than 7 and are divisible by 4, they will appear in colums of 4, else in colums of 2 or 3 -->
<div class="col-xs-12
{{ if gt $galleryTotal 1 }} col-md-6
{{ if gt $galleryTotal 7 }}
{{ if modBool $galleryTotal 4 }} col-lg-3
{{ else }} col-lg-4
{{ end }}
{{ end }}
{{ end }}" onclick {{ if .Params.color }}style="background-color:{{ .Params.color }}"{{ end }}>
<img src="{{ .Params.image}}" {{ if .Params.alt }}alt="{{ .Params.alt }}"{{ end }}>
<div class="row middle-xs center-xs overlay">
<div class="col-xs-12">
<h2>{{ .Title }}</h2>
<div class="row middle-xs center-xs">
{{ if .Params.link1 }}<div class="col-xs-3 col-md-4"><h3><a href="{{ .Params.link1 }}">{{ i18n "view" }}</a></h3></div>{{ end }}
{{ if .Params.link2 }}<div class="col-xs-3 col-md-4"><h3><a href="{{ .Params.link2 }}">{{ i18n "code" }}</a></h3></div>{{ end }}
</div>
</div>
</div>
</div>
{{ end }}
{{ end }}
</div>
</section>