portfolio.html 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {{/* Portfolio Widget */}}
  2. {{/* Initialise */}}
  3. {{ $ := .root }}
  4. {{ $st := .page }}
  5. {{ $items_type := $st.Params.content.page_type | default "project" }}
  6. {{ $columns := $st.Params.design.columns | default "2" }}
  7. {{ $columns := $st.Params.design.columns | default "2" }}
  8. <div class="col-12 {{if eq $columns "2"}}col-lg-8{{end}}">
  9. {{ with $st.Content }}{{ . }}{{ end }}
  10. {{ if $st.Params.content.filter_button }}
  11. {{ $filter_default := default (int $st.Params.content.filter_default) 0 }}
  12. {{/* Parse default filter tag from front matter in the form of either tag name or CSS class name. */}}
  13. {{ $default_filter_tag_raw := (index $st.Params.content.filter_button ($filter_default)).tag }}
  14. {{ $default_filter_tag := printf ".js-id-%s" (replace $default_filter_tag_raw " " "-") }}
  15. {{ if or (eq (substr $default_filter_tag_raw 0 1) "*") (eq (substr $default_filter_tag_raw 0 1) ".") }}
  16. {{ $default_filter_tag = $default_filter_tag_raw }}
  17. {{ end }}
  18. <span class="d-none default-project-filter">{{ $default_filter_tag }}</span>
  19. {{/* Only show filter buttons if there are multiple filters. */}}
  20. {{ if gt (len $st.Params.content.filter_button) 1 }}
  21. <div class="project-toolbar">
  22. <div class="project-filters">
  23. <div class="btn-toolbar">
  24. <div class="btn-group flex-wrap">
  25. {{ range $idx, $item := $st.Params.content.filter_button }}
  26. {{/* Parse filter tag from front matter in the form of either tag name or CSS class name. */}}
  27. {{ $data_filter := printf ".js-id-%s" (replace .tag " " "-") }}
  28. {{ if or (eq (substr .tag 0 1) "*") (eq (substr .tag 0 1) ".") }}
  29. {{ $data_filter = .tag }}
  30. {{ end }}
  31. <a href="#" data-filter="{{ $data_filter | safeHTMLAttr }}" class="btn btn-primary btn-lg{{ if eq $idx $filter_default }} active{{ end }}">{{ .name }}</a>
  32. {{ end }}
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. {{ end }}
  38. {{ end }}
  39. <div class="{{ if or $st.Params.content.filter_button (eq $st.Params.design.view 3) }}isotope projects-container{{end}} {{if eq $st.Params.design.view 3}}js-layout-masonry{{else}}row js-layout-row{{end}} {{ if eq $st.Params.design.view 5 }}project-showcase mt-5{{end}}">
  40. {{ $query := "" }}
  41. {{ if $st.Params.content.filters.tags }}
  42. {{ $query = where site.Pages "Params.tags" "intersect" $st.Params.content.filters.tags }}
  43. {{ else }}
  44. {{ $query = where site.RegularPages "Type" $items_type }}
  45. {{ end }}
  46. {{ range $idx, $item := $query }}
  47. {{ $link := $item.RelPermalink }}
  48. {{ $target := "" }}
  49. {{ if $item.Params.external_link }}
  50. {{ $link = $item.Params.external_link }}
  51. {{ $target = "target=\"_blank\" rel=\"noopener\"" }}
  52. {{ end }}
  53. {{ if eq $st.Params.design.view 1 }}
  54. {{ partial "portfolio_li_list" (dict "item" $item) }}
  55. {{ else if eq $st.Params.design.view 2 }}
  56. {{ partial "portfolio_li_compact" (dict "item" $item) }}
  57. {{ else if eq $st.Params.design.view 3 }}
  58. {{ partial "portfolio_li_card" (dict "widget" $st "index" $idx "item" $item "link" $link "target" $target) }}
  59. {{ else }}
  60. {{ partial "portfolio_li_showcase" (dict "widget" $st "index" $idx "item" $item "link" $link "target" $target) }}
  61. {{ end }}
  62. {{ end }}
  63. </div>
  64. </div>