123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- {{/* Portfolio Widget */}}
- {{/* Initialise */}}
- {{ $ := .root }}
- {{ $st := .page }}
- {{ $items_type := $st.Params.content.page_type | default "project" }}
- {{ $columns := $st.Params.design.columns | default "2" }}
- {{ $view := $st.Params.design.view | default "masonry" }}
- <div class="col-12 {{if eq $columns "2"}}col-lg-8{{end}}">
- {{ with $st.Content }}{{ . }}{{ end }}
- {{ if $st.Params.content.filter_button }}
- {{ $filter_default := default (int $st.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_tag_raw := (index $st.Params.content.filter_button ($filter_default)).tag }}
- {{ $default_filter_tag := printf ".js-id-%s" (replace $default_filter_tag_raw " " "-") }}
- {{ if or (eq (substr $default_filter_tag_raw 0 1) "*") (eq (substr $default_filter_tag_raw 0 1) ".") }}
- {{ $default_filter_tag = $default_filter_tag_raw }}
- {{ end }}
- <span class="d-none default-project-filter">{{ $default_filter_tag }}</span>
- {{/* Only show filter buttons if there are multiple filters. */}}
- {{ if gt (len $st.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 := $st.Params.content.filter_button }}
- {{/* Parse filter tag from front matter in the form of either tag name or CSS class name. */}}
- {{ $data_filter := printf ".js-id-%s" (replace .tag " " "-") }}
- {{ if or (eq (substr .tag 0 1) "*") (eq (substr .tag 0 1) ".") }}
- {{ $data_filter = .tag }}
- {{ 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 $st.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 := "" }}
- {{ if $st.Params.content.filters.tags }}
- {{ $query = where site.Pages "Params.tags" "intersect" $st.Params.content.filters.tags }}
- {{ else }}
- {{ $query = where site.RegularPages "Type" $items_type }}
- {{ end }}
- {{ range $index, $item := $query }}
- {{ $js_tag_classes := delimit (apply (apply $item.Params.tags "replace" "." " " "-") "printf" "js-id-%s" ".") " " }}
- {{ 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" $st "item" . "view" $view "index" $index) }}
- </div>
- {{end}}
- </div>
- </div>
|