From 7a72373ce4bf6b3dae92d006627b388449c78dcf Mon Sep 17 00:00:00 2001 From: paspo Date: Thu, 24 Oct 2024 23:13:14 +0200 Subject: [PATCH 1/5] 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 }} -- 2.47.2 From 2d18734e47f04c2d048f3ab26bc2a0b447408f93 Mon Sep 17 00:00:00 2001 From: paspo Date: Thu, 24 Oct 2024 23:40:57 +0200 Subject: [PATCH 2/5] featured_first --- data/it/homepage.yml | 1 + layouts/_default/shortblock.html | 64 +------------------ layouts/_default/shortblock_common.html | 63 ++++++++++++++++++ layouts/_default/shortblock_wide.html | 3 + .../blocks/posts_homepage_grouping.html | 8 +++ 5 files changed, 76 insertions(+), 63 deletions(-) create mode 100644 layouts/_default/shortblock_common.html create mode 100644 layouts/_default/shortblock_wide.html diff --git a/data/it/homepage.yml b/data/it/homepage.yml index 6e4b098..09daf7c 100644 --- a/data/it/homepage.yml +++ b/data/it/homepage.yml @@ -13,6 +13,7 @@ items: url: /it/posts/2024/09/2024-09-28-cambio-entrata/ title: Più informazioni max: 6 + featured_first: true type: posts_homepage_grouping - heading: Ultimi post ed eventi contents: "L'entrata è stata spostata in Via San Giovanni Bosco 16" diff --git a/layouts/_default/shortblock.html b/layouts/_default/shortblock.html index e25ec60..e9dc23c 100644 --- a/layouts/_default/shortblock.html +++ b/layouts/_default/shortblock.html @@ -1,65 +1,3 @@
-
- - {{ $rasters := slice "jpeg" "png" }} - {{ $newres := "360x250 smart" }} - - {{/* immagine di default */}} - {{- $featimg := (resources.Get "/images/placeholder_elenco.png").RelPermalink -}} - - {{- if .Params.image -}} - {{/* se è stata definita un'immagine featured */}} - {{- $img := .Page.Resources.GetMatch .Params.image -}} - {{- if $img -}} - {{- if in $rasters $img.MediaType.SubType -}} - {{- $img = $img.Fill $newres -}} - {{ end }} - {{- $featimg = $img.RelPermalink -}} - {{- end -}} - {{- else if .Params.featured -}} - {{/* se è stata definita un'immagine featured */}} - {{- $img := .Page.Resources.GetMatch .Params.featured -}} - {{- if $img -}} - {{- if in $rasters $img.MediaType.SubType -}} - {{- $img = $img.Fill $newres -}} - {{ end }} - {{- $featimg = $img.RelPermalink -}} - {{- end -}} - {{- else -}} - {{/* altrimenti prendo la prima risorsa immagine disponibile */}} - {{- $img := (.Page.Resources.ByType "image").GetMatch "**" -}} - {{- if $img -}} - {{- if in $rasters $img.MediaType.SubType -}} - {{- $img = $img.Fill $newres -}} - {{ end }} - {{- $featimg = $img.RelPermalink -}} - {{- end -}} - {{- end -}} - - {{ .Params.image_alt }} -
-

{{ .Title }}

- - {{- with .GetTerms "author" }} - {{- range . -}} - - {{- end }} - {{- end }} - - - {{ if .Site.Params.show_post_dates | default true }} - {{- with .Date }}{{ end }} - {{ end }} -

- {{ with .Description }} - {{- . | plainify | truncate 400 }} - {{- else }} - {{- .Summary | plainify | truncate 400 }} - {{- end }} -

- {{ partial "tags.html" . }} -
-
+ {{- .Render "shortblock_common" -}}
diff --git a/layouts/_default/shortblock_common.html b/layouts/_default/shortblock_common.html new file mode 100644 index 0000000..a8e8413 --- /dev/null +++ b/layouts/_default/shortblock_common.html @@ -0,0 +1,63 @@ +
+ + {{ $rasters := slice "jpeg" "png" }} + {{ $newres := "360x250 smart" }} + + {{/* immagine di default */}} + {{- $featimg := (resources.Get "/images/placeholder_elenco.png").RelPermalink -}} + + {{- if .Params.image -}} + {{/* se è stata definita un'immagine featured */}} + {{- $img := .Page.Resources.GetMatch .Params.image -}} + {{- if $img -}} + {{- if in $rasters $img.MediaType.SubType -}} + {{- $img = $img.Fill $newres -}} + {{ end }} + {{- $featimg = $img.RelPermalink -}} + {{- end -}} + {{- else if .Params.featured -}} + {{/* se è stata definita un'immagine featured */}} + {{- $img := .Page.Resources.GetMatch .Params.featured -}} + {{- if $img -}} + {{- if in $rasters $img.MediaType.SubType -}} + {{- $img = $img.Fill $newres -}} + {{ end }} + {{- $featimg = $img.RelPermalink -}} + {{- end -}} + {{- else -}} + {{/* altrimenti prendo la prima risorsa immagine disponibile */}} + {{- $img := (.Page.Resources.ByType "image").GetMatch "**" -}} + {{- if $img -}} + {{- if in $rasters $img.MediaType.SubType -}} + {{- $img = $img.Fill $newres -}} + {{ end }} + {{- $featimg = $img.RelPermalink -}} + {{- end -}} + {{- end -}} + + {{ .Params.image_alt }} +
+

{{ .Title }}

+ + {{- with .GetTerms "author" }} + {{- range . -}} + + {{- end }} + {{- end }} + + + {{ if .Site.Params.show_post_dates | default true }} + {{- with .Date }}{{ end }} + {{ end }} +

+ {{ with .Description }} + {{- . | plainify | truncate 400 }} + {{- else }} + {{- .Summary | plainify | truncate 400 }} + {{- end }} +

+ {{ partial "tags.html" . }} +
+
diff --git a/layouts/_default/shortblock_wide.html b/layouts/_default/shortblock_wide.html new file mode 100644 index 0000000..838633a --- /dev/null +++ b/layouts/_default/shortblock_wide.html @@ -0,0 +1,3 @@ +
+ {{- .Render "shortblock_common" -}} +
diff --git a/layouts/partials/homepage/blocks/posts_homepage_grouping.html b/layouts/partials/homepage/blocks/posts_homepage_grouping.html index 136ce37..bb884e6 100644 --- a/layouts/partials/homepage/blocks/posts_homepage_grouping.html +++ b/layouts/partials/homepage/blocks/posts_homepage_grouping.html @@ -3,6 +3,14 @@
{{ 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 }} -- 2.47.2 From 823f8de3e5cebd437bf6693631a3d1c3122fdafa Mon Sep 17 00:00:00 2001 From: paspo Date: Fri, 25 Oct 2024 20:19:54 +0200 Subject: [PATCH 3/5] definisci ordinamento --- layouts/partials/homepage/blocks/posts_homepage_grouping.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/homepage/blocks/posts_homepage_grouping.html b/layouts/partials/homepage/blocks/posts_homepage_grouping.html index bb884e6..5d03705 100644 --- a/layouts/partials/homepage/blocks/posts_homepage_grouping.html +++ b/layouts/partials/homepage/blocks/posts_homepage_grouping.html @@ -1,4 +1,4 @@ -{{- $pages := (where .ctx.Site.Pages ".Params.grouping" "intersect" (slice "homepage")) }} +{{- $pages := (where .ctx.Site.RegularPages ".Params.grouping" "intersect" (slice "homepage")) }} {{- if gt (len $pages) 0 }}
-- 2.47.2 From 22d1dc4e02c1b5fa1eb0530a7cbf6419ac24b985 Mon Sep 17 00:00:00 2001 From: paspo Date: Fri, 25 Oct 2024 20:25:48 +0200 Subject: [PATCH 4/5] homepage en --- data/en/homepage.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/data/en/homepage.yml b/data/en/homepage.yml index 4074f76..d865994 100644 --- a/data/en/homepage.yml +++ b/data/en/homepage.yml @@ -13,14 +13,10 @@ items: url: /en/posts/2024/09/2024-09-28-cambio-entrata/ title: More information contents: "The entrance has been moved to Via San Giovanni Bosco 16" - - heading: Latest posts - type: posts - content_type: posts - max: 4 - - heading: Latest events - type: posts - content_type: events - max: 4 + - heading: Latest posts and events + type: posts_homepage_grouping + max: 6 + featured_first: true - type: highlights items_per_row: 2 items: -- 2.47.2 From c0bba6eeba440b2c92d4f594900c1283ab0d98d0 Mon Sep 17 00:00:00 2001 From: paspo Date: Sun, 27 Oct 2024 22:55:56 +0100 Subject: [PATCH 5/5] homepage it --- data/it/homepage.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/it/homepage.yml b/data/it/homepage.yml index 09daf7c..8861ffe 100644 --- a/data/it/homepage.yml +++ b/data/it/homepage.yml @@ -12,11 +12,11 @@ items: link: url: /it/posts/2024/09/2024-09-28-cambio-entrata/ title: Più informazioni + contents: "L'entrata è stata spostata in Via San Giovanni Bosco 16" + - heading: Ultimi post ed eventi + type: posts_homepage_grouping max: 6 featured_first: true - type: posts_homepage_grouping - - heading: Ultimi post ed eventi - contents: "L'entrata è stata spostata in Via San Giovanni Bosco 16" - type: highlights items_per_row: 2 items: -- 2.47.2