From 62c7979cc4da977a72e2dd538dd0e51c74fc2da9 Mon Sep 17 00:00:00 2001
From: alexisben <alex@noesya.coop>
Date: Mon, 18 Mar 2024 11:49:49 +0100
Subject: [PATCH] prepare block projects

---
 config.yaml                                   |  3 ++-
 i18n/en.yml                                   | 20 ++++++++++++++++-
 i18n/fr.yml                                   |  3 +--
 .../partials/blocks/templates/portfolio.html  | 22 +++++++++++++++++++
 .../blocks/templates/projects/grid.html       | 12 ++++++++++
 layouts/partials/projects/project-infos.html  | 10 +++++----
 layouts/partials/projects/project.html        | 10 +++++----
 7 files changed, 68 insertions(+), 12 deletions(-)
 create mode 100644 layouts/partials/blocks/templates/portfolio.html
 create mode 100644 layouts/partials/blocks/templates/projects/grid.html

diff --git a/config.yaml b/config.yaml
index e0e28f75..38b0724b 100644
--- a/config.yaml
+++ b/config.yaml
@@ -83,10 +83,11 @@ params:
       whatsapp: false
   projects:
     default_image: false
-    date_format: ":date_long"
+    date_format: "2006"
     index:
       show_categories: true
       show_description: true
+      show_year: false
       truncate_description: 200 # Set to 0 to disable truncate
       layout: list # grid | list
     share_links:
diff --git a/i18n/en.yml b/i18n/en.yml
index 431275af..16a2bf4d 100644
--- a/i18n/en.yml
+++ b/i18n/en.yml
@@ -223,7 +223,7 @@ posts:
   next: Next article
   next_aria: Next article “{{ .Title }}”
   previous: Previous article
-  previous_aria: revious article “{{ .Title }}”
+  previous_aria: Previous article “{{ .Title }}”
   reading_time: Reading time
   see_all: See all posts
   see_all_in_program: See all program's news
@@ -231,6 +231,24 @@ posts:
   share: Please, share
   share_aria: Share on “{{ .Title }}” - extern link
   title: News
+projects:
+  author: Author
+  category:
+    one: Category
+    other: Categories
+  informations: Informations
+  next: Next project
+  next_aria: Next project “{{ .Title }}”
+  previous: Previous project
+  previous_aria: Previous project “{{ .Title }}”
+  reading_time: Reading time
+  see_all: See all posts
+  see_all_in_program: See all program's projects
+  see_all_in_category: See all projects in “{{ .Title }}”
+  share: Please, share
+  share_aria: Share on “{{ .Title }}” - extern link
+  title: Projects
+  year: Year
 programs:
   accessibility: Accessibility
   administrative_information: Administrative information
diff --git a/i18n/fr.yml b/i18n/fr.yml
index 50a84f11..cfc4cd02 100644
--- a/i18n/fr.yml
+++ b/i18n/fr.yml
@@ -232,13 +232,11 @@ posts:
   share: Partager sur
   share_aria: Partager sur “{{ .Title }}” - lien externe
   title: Actualités
-
 projects:
   author: Auteur·rice
   category:
     one: Catégorie
     other: Catégories
-  date: Date
   informations: Informations
   next: Projet suivant
   next_aria: Projet suivant “{{ .Title }}”
@@ -251,6 +249,7 @@ projects:
   share: Partager sur
   share_aria: Partager sur “{{ .Title }}” - lien externe
   title: Projets
+  year: Année
 programs:
   accessibility: Accessibilité
   administrative_information: Informations administratives
diff --git a/layouts/partials/blocks/templates/portfolio.html b/layouts/partials/blocks/templates/portfolio.html
new file mode 100644
index 00000000..cc04421f
--- /dev/null
+++ b/layouts/partials/blocks/templates/portfolio.html
@@ -0,0 +1,22 @@
+{{- $block := .block -}}
+{{- $block_title := .block.title -}}
+{{- $block_class := partial "GetBlockClass" .block -}}
+{{- $layout := .block.data.layout | default "grid" -}}
+
+{{- with .block.data -}}
+  <div class="{{ $block_class }}">
+    <div class="container">
+      <div class="block-content">
+        {{ partial "blocks/top.html" (dict
+          "title" $block_title
+          "heading_level" $block.ranks.self
+        ) }}
+
+        {{- partial (printf "blocks/templates/projects/%s.html" $layout) (dict 
+          "projects" .projects
+          "heading_level" $block.ranks.children
+        ) }}
+      </div>
+    </div>
+  </div>
+{{- end -}}
diff --git a/layouts/partials/blocks/templates/projects/grid.html b/layouts/partials/blocks/templates/projects/grid.html
new file mode 100644
index 00000000..b396c989
--- /dev/null
+++ b/layouts/partials/blocks/templates/projects/grid.html
@@ -0,0 +1,12 @@
+{{ $heading_level := .heading_level | default 3 }}
+{{ $heading := printf "h%d" $heading_level }}
+<div class="projects grid">
+  {{ range $project := .projects -}}
+    {{ with site.GetPage .file }}
+      {{ partial "projects/project.html" (dict 
+        "project" .
+        "heading" $heading
+        ) }}
+    {{ end }}
+  {{ end }}
+</div>
diff --git a/layouts/partials/projects/project-infos.html b/layouts/partials/projects/project-infos.html
index 14f26f1b..e33502c5 100644
--- a/layouts/partials/projects/project-infos.html
+++ b/layouts/partials/projects/project-infos.html
@@ -5,10 +5,12 @@
       {{ partial "projects/categories.html" . }}
     </li>
   {{ end }}
-  <li>
-    <span>{{ i18n "projects.date" }}</span>
-    <time datetime="{{ .Date.Format "2006-01-02T15:04" }}">{{ .Date | time.Format site.Params.projects.date_format }}</time>
-  </li>
+  {{ with .Params.year }}
+    <li>
+      <span>{{ i18n "projects.year" }}</span>
+      <time datetime="{{ . }}">{{ . }}</time>
+    </li>
+  {{ end }}
   <li class="social-share">
     <span>{{ i18n "projects.share" }}</span>
     {{ partial "commons/share.html" . }}
diff --git a/layouts/partials/projects/project.html b/layouts/partials/projects/project.html
index de399590..c7ec5b28 100644
--- a/layouts/partials/projects/project.html
+++ b/layouts/partials/projects/project.html
@@ -26,10 +26,12 @@
     {{ if site.Params.projects.index.show_categories }}
       {{- partial "projects/categories" . -}}
     {{ end }}
-    
-    <div class="project-meta">
-      <time itemprop="datePublished" datetime="{{ .Date.Format "2006-01-02T15:04" }}">{{ .Date | time.Format site.Params.projects.date_format }}</time>
-    </div>
+
+    {{ if and site.Params.projects.index.show_year .Params.year }}
+      <div class="project-meta">
+        <time itemprop="datePublished" datetime="{{ .Params.year }}">{{ .Params.year }}</time>
+      </div>
+    {{ end }}
   </div>
 
   <div class="media">
-- 
GitLab