diff options
author | Guillermo Guerrero Ibarra <wolf.fox1985@gmail.com> | 2021-08-07 20:36:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-07 20:36:45 +0300 |
commit | c80a0e76599f76f4efa4687b73de9dfbb3f5ed6c (patch) | |
tree | e1199f74720cab0a7c3e8baee27d283dab3cec6b /layouts | |
parent | 39d9ad856ddae27eaaf83a10df64d0a1bc1733a4 (diff) |
Able to customize number of columns. (#308)
* Able to customize number of columns.
* mark row with index.
* clases to rows odd/even.
* Update features.html
Co-authored-by: Guillermo Guerrero Ibarra <guillermo.guerrero@deliveroo.co.uk>
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/features.html | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/layouts/partials/features.html b/layouts/partials/features.html index f41f2a1..ea73ac5 100644 --- a/layouts/partials/features.html +++ b/layouts/partials/features.html @@ -3,30 +3,41 @@ {{ if gt (len .Site.Data.features) 0 }} <section class="bar background-white"> <div class="container"> - {{ range $index, $element := sort .Site.Data.features "weight" }} - {{ if eq (mod $index 3) 0 }} - <div class="col-md-12"> - <div class="row"> + {{ $elements := default 3 .Site.Params.features.cols }} + {{ $features := sort .Site.Data.features "weight" }} + + {{ $total_rows := div (len $features) $elements }} + + {{ if gt (mod (len $features) $elements) 0 }} + {{ $total_rows = add $total_rows 1 }} {{ end }} - <div class="col-md-4"> - <div class="box-simple"> - {{ with $element.url }} - <a href="{{ $element.url }}"> - {{ end }} - <div class="icon"> - <i class="{{ .icon }}"></i> - </div> - {{ with $element.url }} - </a> - {{ end }} - <h3>{{ $element.name | markdownify }}</h3> - <p>{{ $element.description | markdownify }}</p> + + {{ range $i, $sequence := seq $total_rows }} + <div class="row row-{{ $i }} row-{{ if eq (mod $i 2) 0 }}odd{{ else }}even{{ end }}"> + {{ range $j, $sequence2 := (seq $elements) }} + + {{ $feature_index := add (mul $i $elements) $j }} + {{ if lt $feature_index (len $features) }} + {{ $element := index $features $feature_index }} + + <div class="col-md-{{ div 12 $elements }} col-{{ $j }} col-{{ if eq (mod $j 2) 0 }}odd{{ else }}even{{ end }}"> + <div class="box-simple"> + {{ with $element.url }} + <a href="{{ $element.url }}"> + {{ end }} + <div class="icon"> + <i class="{{ $element.icon }}"></i> + </div> + {{ with $element.url }} + </a> + {{ end }} + <h3>{{ $element.name | markdownify }}</h3> + <p>{{ $element.description | markdownify }}</p> + </div> </div> - </div> - {{ if or (eq (mod $index 3) 2) (eq $index (sub (len $.Site.Data.features) 1 )) }} - </div> - </div> - {{ end }} + {{ end }} + {{ end }} + </div> {{ end }} </div> </section> |