tw-runner
Version:
Run and manage Tower Website projects with this utility.
49 lines (43 loc) • 1.86 kB
HTML
<main class="grid grid-rows-6 grid-flow-row sm:grid-flow-col gap-4">
{{/* Show the newest offer */}}
{{ $offers := sort (where .Site.RegularPages "Type" "offers") ".Params.weight" ".Params.date" }}
{{ if gt (len $offers) 0 }}
{{ with index $offers 0 }}
{{ partial "components/cards/base.html" (dict
"page" (index $offers 0)
"styles" "row-span-2 box-pop box-primary-highlight"
"cta" "Learn More"
) }}
{{ end }}
{{ end }}
{{ $categories := slice }}
{{ range $name, $taxonomy := .Site.Taxonomies.categories }}
{{ $categories = $categories | append (dict "name" $name "count" $taxonomy.Count "page" $taxonomy.Page) }}
{{ end }}
{{ $categories = first 4 (sort $categories "count" "desc") }}
{{ range $index, $category := $categories }}
{{ $activeCategory := $category.name }}
{{ $products := sort (where (where $.Site.RegularPages "Section" "products") "Params.categories" "intersect" (slice $activeCategory)) }}
{{ $prod := index $products 0 }}
{{/* Assign ROW SPAN CSS class */}}
{{ $styles := "box-pop" }}
{{ if eq $index 0 }}
{{ if gt (len $offers) 0 }} {{ $styles = printf "%s %s" $styles "row-span-4" }} {{ else }} {{ $styles = printf "%s %s" $styles "row-span-6" }} {{ end }}
{{ end }}
{{ if eq $index 3 }} {{ $styles = printf "%s %s" $styles "row-span-6" }} {{ else }}
{{ if and (ge $index 1) (le $index 2) }} {{ $styles = printf "%s %s" $styles "row-span-3" }} {{ end }}
{{ end }}
{{ partial "image/responsive-bg.html" (dict
"name" (replace $prod.Title " " "")
"src" $prod.Params.background
"page" $prod
"styles" $styles
"overlayStyles" ""
"opacity" "0.75"
"heading" $category.name
"cta" "See More"
"ctaStyles" "text-xl"
"url" $category.page.Permalink
) }}
{{ end }}
</main>