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