From dbbe645aafea232aee8806d8626971ea60d54c30 Mon Sep 17 00:00:00 2001 From: paspo Date: Thu, 31 Oct 2024 22:04:28 +0000 Subject: [PATCH] homepage-list (#329) fixes #320 Reviewed-on: https://git.libreschool.org/BgLUG/bglug.it/pulls/329 Co-authored-by: paspo Co-committed-by: paspo --- data/en/homepage.yml | 6 +++- data/it/homepage.yml | 6 +++- .../homepage/blocks/posts_homepage.html | 30 +++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 layouts/partials/homepage/blocks/posts_homepage.html diff --git a/data/en/homepage.yml b/data/en/homepage.yml index d8659944..b13eac32 100644 --- a/data/en/homepage.yml +++ b/data/en/homepage.yml @@ -14,9 +14,13 @@ items: title: More information contents: "The entrance has been moved to Via San Giovanni Bosco 16" - heading: Latest posts and events - type: posts_homepage_grouping + type: posts_homepage max: 6 featured_first: true + sections: + - events + - linuxday + - posts - type: highlights items_per_row: 2 items: diff --git a/data/it/homepage.yml b/data/it/homepage.yml index 8861ffe0..920b66b3 100644 --- a/data/it/homepage.yml +++ b/data/it/homepage.yml @@ -14,9 +14,13 @@ items: title: Più informazioni contents: "L'entrata è stata spostata in Via San Giovanni Bosco 16" - heading: Ultimi post ed eventi - type: posts_homepage_grouping + type: posts_homepage max: 6 featured_first: true + sections: + - events + - linuxday + - posts - type: highlights items_per_row: 2 items: diff --git a/layouts/partials/homepage/blocks/posts_homepage.html b/layouts/partials/homepage/blocks/posts_homepage.html new file mode 100644 index 00000000..51d7e46b --- /dev/null +++ b/layouts/partials/homepage/blocks/posts_homepage.html @@ -0,0 +1,30 @@ +{{- $pages := (where .ctx.Site.RegularPages "Section" "in" .item.sections ) }} +{{- $pages := (where $pages ".Params.homepage" "ne" false ) }} + +{{- if gt (len $pages) 0 }} +
+
+ {{ with .item.heading }}

{{ . }}

{{ end }} + {{ if eq .item.featured_first true }} +
+ {{- range $idx, $itm := first 1 $pages }} + {{- .Render "shortblock_wide" -}} + {{- end }} +
+ {{- $pages = after 1 $pages }} + {{- 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 }}