-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
portfolio.html
106 lines (91 loc) · 4.54 KB
/
portfolio.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
97
98
99
100
101
102
103
104
105
106
{{/* Hugo Blox: Portfolio */}}
{{/* Documentation: https://hugoblox.com/blocks/ */}}
{{/* License: https://github.com/HugoBlox/hugo-blox-builder/blob/main/LICENSE.md */}}
{{/* Initialise */}}
{{ $page := .wcPage }}
{{ $block := .wcBlock }}
{{ $columns := $block.Params.design.columns | default "2" }}
{{ $view := $block.Params.design.view | default "masonry" }}
{{/* Require Isotope */}}
{{ $page.Page.Store.Set "has_isotope" true }}
<div class="col-12 {{if eq $columns "2"}}col-lg-8{{end}}">
{{ with $block.Content }}{{ . }}{{ end }}
{{ if $block.Params.content.filter_button }}
{{ $filter_default := default (int $block.Params.content.filter_default) 0 }}
{{/* Parse default filter tag from front matter in the form of either tag name or CSS class name. */}}
{{ $default_filter_item := (index $block.Params.content.filter_button ($filter_default)) }}
{{ $default_data_filter := "" }}
{{ with $default_filter_item.filter }}
{{ $default_data_filter = . }}
{{ else }}
{{ $default_filter_tag := $default_filter_item.tag }}
{{ if or (eq (substr $default_filter_tag 0 1) "*") (eq (substr $default_filter_tag 0 1) ".") }}
{{ $default_data_filter = $default_filter_tag }}
{{ else }}
{{ $default_data_filter = printf ".js-id-%s" (lower (replace $default_filter_tag " " "-")) }}
{{ end }}
{{end}}
<span class="d-none default-project-filter">{{ $default_data_filter }}</span>
{{/* Only show filter buttons if there are multiple filters. */}}
{{ if gt (len $block.Params.content.filter_button) 1 }}
<div class="project-toolbar">
<div class="project-filters">
<div class="btn-toolbar {{if eq $columns "1"}}d-flex justify-content-center{{end}}">
<div class="btn-group flex-wrap">
{{ range $idx, $item := $block.Params.content.filter_button }}
{{/* Parse filter tag from front matter in the form of either tag name or CSS class name. */}}
{{ $data_filter := "" }}
{{ with .filter }}
{{ $data_filter = . }}
{{ else }}
{{ if or (eq (substr .tag 0 1) "*") (eq (substr .tag 0 1) ".") }}
{{ $data_filter = .tag }}
{{ else }}
{{ $data_filter = printf ".js-id-%s" (lower (replace .tag " " "-")) }}
{{ end }}
{{ end }}
<a href="#" data-filter="{{ $data_filter | safeHTMLAttr }}" class="btn btn-primary btn-lg{{ if eq $idx $filter_default }} active{{ end }}">{{ .name }}</a>
{{ end }}
</div>
</div>
</div>
</div>
{{ end }}
{{ end }}
<div class="{{ if or $block.Params.content.filter_button (in (slice "masonry" 3) $view) }}isotope projects-container{{end}} {{if in (slice "masonry" 3) $view}}js-layout-masonry{{else}}row js-layout-row{{end}} {{ if eq $view "showcase" }}project-showcase{{end}}">
{{/* Query */}}
{{ $query := site.Pages }}
{{/* Filters */}}
{{ with $block.Params.content.page_type }}
{{/* Legacy filter, superseded by `filters.folders` */}}
{{ $query = where $query "Type" . }}
{{ end }}
{{ with $block.Params.content.filters.folders }}
{{ $query = where $query "Section" "in" . }}
{{ end }}
{{ with $block.Params.content.filters.tags }}
{{ $query = where $query "Params.tags" "intersect" . }}
{{ end }}
{{ with $block.Params.content.filters.exclude_tags }}
{{ $query = $query | symdiff (where site.Pages "Params.tags" "intersect" .) }}
{{ end }}
{{ with ($block.Params.content.filters.kinds | default (slice "page")) }}
{{ $query = where $query "Kind" "in" . }}
{{ end }}
{{/* Sort */}}
{{ $sort_by := $block.Params.content.sort_by | default "Date" }}
{{ $sort_ascending := $block.Params.content.sort_ascending | default (eq $block.Params.content.order "asc") | default false }}
{{ $sort_order := cond $sort_ascending "asc" "desc" }}
{{ $query = sort $query $sort_by $sort_order }}
{{ range $index, $item := $query }}
{{ $js_tag_classes := delimit (apply (apply (apply $item.Params.tags "replace" "." " " "-") "printf" "js-id-%s" ".") "lower" ".") " " }}
{{ if in (slice "masonry" 3) $view }}
<div class="project-card project-item isotope-item {{ $js_tag_classes | safeHTMLAttr }}">
{{else}}
<div class="col-12 isotope-item {{ $js_tag_classes | safeHTMLAttr }}">
{{end}}
{{ partial "functions/render_view" (dict "page" $block "item" . "view" $view "index" $index) }}
</div>
{{end}}
</div>
</div>