From 7a72373ce4bf6b3dae92d006627b388449c78dcf Mon Sep 17 00:00:00 2001 From: paspo Date: Thu, 24 Oct 2024 23:13:14 +0200 Subject: [PATCH] homepage grouping --- data/it/homepage.yml | 11 +++------- .../blocks/posts_homepage_grouping.html | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 layouts/partials/homepage/blocks/posts_homepage_grouping.html diff --git a/data/it/homepage.yml b/data/it/homepage.yml index 48d6565..6e4b098 100644 --- a/data/it/homepage.yml +++ b/data/it/homepage.yml @@ -12,15 +12,10 @@ items: link: url: /it/posts/2024/09/2024-09-28-cambio-entrata/ title: Più informazioni + max: 6 + type: posts_homepage_grouping + - heading: Ultimi post ed eventi contents: "L'entrata è stata spostata in Via San Giovanni Bosco 16" - - heading: Ultimi post - type: posts - content_type: posts - max: 4 - - heading: Ultimi Eventi - type: posts - content_type: events - max: 4 - type: highlights items_per_row: 2 items: diff --git a/layouts/partials/homepage/blocks/posts_homepage_grouping.html b/layouts/partials/homepage/blocks/posts_homepage_grouping.html new file mode 100644 index 0000000..136ce37 --- /dev/null +++ b/layouts/partials/homepage/blocks/posts_homepage_grouping.html @@ -0,0 +1,20 @@ +{{- $pages := (where .ctx.Site.Pages ".Params.grouping" "intersect" (slice "homepage")) }} +{{- if gt (len $pages) 0 }} +
+
+ {{ with .item.heading }}

{{ . }}

{{ end }} + {{- range $idx, $itm := first (.item.max | default 4) $pages }} + {{- $rowpos := mod $idx 2 }} + {{- if eq $rowpos 0 }} +
+ {{ end }} + + {{- .Render "shortblock" -}} + + {{ if or (eq $rowpos 1) (eq $idx (len $pages)) -}} +
+ {{- end }} + {{- end }} +
+
+{{ end }}