{{/* 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" }}
{{ 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 }} {{ $default_filter_tag }} {{/* Only show filter buttons if there are multiple filters. */}} {{ if gt (len $st.Params.content.filter_button) 1 }}
{{ 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 }} {{ .name }} {{ end }}
{{ end }} {{ 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 }}
{{else}}
{{end}} {{ partial "functions/render_view" (dict "page" $st "item" . "view" $view "index" $index) }}
{{end}}