From e75035da2de14bbca624b5dd45f887b0bfc127ae Mon Sep 17 00:00:00 2001
From: alexisben <alex@noesya.coop>
Date: Thu, 4 May 2023 18:56:02 +0200
Subject: [PATCH] handle summary for persons programs and diplomas

---
 config.yaml                                 |  6 +-----
 layouts/diplomas/term.html                  |  2 +-
 layouts/papers/list.html                    | 10 ++--------
 layouts/papers/single.html                  | 11 ++---------
 layouts/partials/categories/summary.html    |  2 +-
 layouts/partials/diplomas/hero-single.html  | 15 ++++++++++++++-
 layouts/partials/diplomas/summary.html      |  2 +-
 layouts/partials/header/hero.html           |  4 +++-
 layouts/partials/home/summary.html          |  2 +-
 layouts/partials/organizations/summary.html |  2 +-
 layouts/partials/pages/summary.html         |  2 +-
 layouts/partials/papers/hero.html           |  8 ++++++++
 layouts/partials/persons/hero-single.html   | 16 +++++++++++++++-
 layouts/partials/persons/summary.html       |  2 +-
 layouts/partials/posts/summary.html         |  2 +-
 layouts/partials/programs/hero-single.html  | 14 +++++++++++++-
 layouts/partials/programs/summary.html      |  2 +-
 layouts/partials/sitemap/summary.html       |  2 +-
 layouts/persons/single.html                 |  8 +++-----
 19 files changed, 71 insertions(+), 41 deletions(-)
 create mode 100644 layouts/partials/papers/hero.html

diff --git a/config.yaml b/config.yaml
index 7e811742..100ff599 100644
--- a/config.yaml
+++ b/config.yaml
@@ -14,7 +14,7 @@ params:
   breadcrumb:
     position: hero-start #  hero-start |  hero-end | after-hero | none
   summary:
-    position: content # content | hero
+    position: hero # content | hero
   home:
     toc:
       disabled: true
@@ -141,10 +141,6 @@ params:
           mobile:   400
           tablet:   800
           desktop:  900
-        hero_single:
-          mobile:   400
-          tablet:   800
-          desktop:  900
       persons:
         hero:
           mobile:   400
diff --git a/layouts/diplomas/term.html b/layouts/diplomas/term.html
index 807600e0..76057e4a 100644
--- a/layouts/diplomas/term.html
+++ b/layouts/diplomas/term.html
@@ -12,7 +12,7 @@
             <a href="{{ .Permalink }}" class="title" title="{{ safeHTML (i18n "commons.more_aria" (dict "Title" $title)) }}">
               {{- $title -}}
             </a>
-            {{ if .Params.summary }}
+            {{ if .Params }}
               <p class="description">
                 {{- partial "PrepareHTML" .Params.summary -}}
               </p>
diff --git a/layouts/papers/list.html b/layouts/papers/list.html
index cf184250..cad287b8 100644
--- a/layouts/papers/list.html
+++ b/layouts/papers/list.html
@@ -1,12 +1,6 @@
 {{ define "main" }}
-  {{- $title := or .Params.header_text .Title -}}
-  {{- partial "header/hero.html"
-        (dict
-          "title" $title
-          "image" .Params.image
-          "sizes" site.Params.image_sizes.sections.papers.hero
-          "context" .
-        ) -}}
+{{ partial "papers/hero.html" . }}
+
   <div class="document-content">
     <div class="container">
       <ul class="papers">
diff --git a/layouts/papers/single.html b/layouts/papers/single.html
index f03da63b..fe22fc24 100644
--- a/layouts/papers/single.html
+++ b/layouts/papers/single.html
@@ -1,13 +1,6 @@
 {{ define "main" }}
-  {{- $title := or .Params.header_text .Title -}}
-  {{- partial "header/hero.html"
-        (dict
-          "title" $title
-          "subtitle" .Params.summary
-          "image" .Params.image
-          "sizes" site.Params.image_sizes.sections.papers.hero_single
-          "context" .
-        ) -}}
+{{ partial "papers/hero.html" . }}
+
 <div class="document-content" itemscope itemtype="https://schema.org/ScholarlyArticle">
   <meta itemprop="name" content="{{ partial "PrepareHTML" .Title }}">
   {{ partial "papers/sidebar.html" . }}
diff --git a/layouts/partials/categories/summary.html b/layouts/partials/categories/summary.html
index 7893d856..85e4edf8 100644
--- a/layouts/partials/categories/summary.html
+++ b/layouts/partials/categories/summary.html
@@ -1 +1 @@
-{{- partial "commons/summary-wrapper.html" . -}}
+{{- partial "commons/summary-in-content.html" . -}}
diff --git a/layouts/partials/diplomas/hero-single.html b/layouts/partials/diplomas/hero-single.html
index 6bd1f431..cb953525 100644
--- a/layouts/partials/diplomas/hero-single.html
+++ b/layouts/partials/diplomas/hero-single.html
@@ -1,11 +1,24 @@
 {{- $title := or .Params.header_text .Title -}}
+{{ $subtitle := "" }}
+{{- $summary := partial "PrepareText" .Params.summary -}}
+{{ if and (eq site.Params.summary.position "hero") $summary }}
+  {{ $subtitle = $summary }}
+{{ end }}
+
 <header class="hero">
   <div class="container">
     {{- if .Params.breadcrumb | default true -}}
       {{ partial "header/breadcrumbs.html" . }}
     {{- end -}}
     <div class="content">
-      <h1>{{ partial "PrepareHTML" $title }}</h1>
+      {{- if $subtitle -}}
+        <hgroup>
+          <h1>{{ partial "PrepareHTML" $title }}</h1>
+          <p class="lead">{{ partial "PrepareHTML" $subtitle }}</p>
+        </hgroup>
+      {{- else -}}
+        <h1>{{ partial "PrepareHTML" $title }}</h1>
+      {{- end -}}
       {{- if .Params.image }}
         <figure>
           {{ partial "commons/image.html"
diff --git a/layouts/partials/diplomas/summary.html b/layouts/partials/diplomas/summary.html
index 7893d856..85e4edf8 100644
--- a/layouts/partials/diplomas/summary.html
+++ b/layouts/partials/diplomas/summary.html
@@ -1 +1 @@
-{{- partial "commons/summary-wrapper.html" . -}}
+{{- partial "commons/summary-in-content.html" . -}}
diff --git a/layouts/partials/header/hero.html b/layouts/partials/header/hero.html
index 024bf648..d3c557c9 100644
--- a/layouts/partials/header/hero.html
+++ b/layouts/partials/header/hero.html
@@ -6,10 +6,12 @@
 {{ end }}
 
 {{- $summary := partial "PrepareText" .context.Params.summary -}}
+{{- $subtitle_is_summary := false -}}
 
 {{ if not $subtitle }}
   {{ if and (eq site.Params.summary.position "hero") $summary }}
    {{ $subtitle = $summary }}
+   {{ $subtitle_is_summary = true }}
   {{ end }}
 {{ end }}
 
@@ -24,7 +26,7 @@
       {{- if $subtitle -}}
         <hgroup>
           <h1>{{ partial "PrepareHTML" .title }}</h1>
-          <p>{{ partial "PrepareHTML" $subtitle }}</p>
+          <p {{ if $subtitle_is_summary -}} class="lead" {{- end -}}>{{ partial "PrepareHTML" $subtitle }}</p>
         </hgroup>
       {{- else -}}
         <h1>{{ partial "PrepareHTML" .title }}</h1>
diff --git a/layouts/partials/home/summary.html b/layouts/partials/home/summary.html
index 7893d856..85e4edf8 100644
--- a/layouts/partials/home/summary.html
+++ b/layouts/partials/home/summary.html
@@ -1 +1 @@
-{{- partial "commons/summary-wrapper.html" . -}}
+{{- partial "commons/summary-in-content.html" . -}}
diff --git a/layouts/partials/organizations/summary.html b/layouts/partials/organizations/summary.html
index 7893d856..85e4edf8 100644
--- a/layouts/partials/organizations/summary.html
+++ b/layouts/partials/organizations/summary.html
@@ -1 +1 @@
-{{- partial "commons/summary-wrapper.html" . -}}
+{{- partial "commons/summary-in-content.html" . -}}
diff --git a/layouts/partials/pages/summary.html b/layouts/partials/pages/summary.html
index 7893d856..85e4edf8 100644
--- a/layouts/partials/pages/summary.html
+++ b/layouts/partials/pages/summary.html
@@ -1 +1 @@
-{{- partial "commons/summary-wrapper.html" . -}}
+{{- partial "commons/summary-in-content.html" . -}}
diff --git a/layouts/partials/papers/hero.html b/layouts/partials/papers/hero.html
new file mode 100644
index 00000000..a338c1a5
--- /dev/null
+++ b/layouts/partials/papers/hero.html
@@ -0,0 +1,8 @@
+{{- $title := or .Params.header_text .Title -}}
+{{- partial "header/hero.html"
+      (dict
+        "title" $title
+        "image" .Params.image
+        "sizes" site.Params.image_sizes.sections.papers.hero
+        "context" .
+      ) -}}
\ No newline at end of file
diff --git a/layouts/partials/persons/hero-single.html b/layouts/partials/persons/hero-single.html
index 37e43527..09386e77 100644
--- a/layouts/partials/persons/hero-single.html
+++ b/layouts/partials/persons/hero-single.html
@@ -1,10 +1,24 @@
+{{ $subtitle := "" }}
+{{- $summary := partial "PrepareText" .Params.summary -}}
+{{ if and (eq site.Params.summary.position "hero") $summary }}
+  {{ $subtitle = $summary }}
+{{ end }}
+
 <header class="hero">
   <div class="container">
     {{- if eq site.Params.breadcrumb.position "hero-start" -}}
       {{ partial "header/breadcrumbs.html" . }}
     {{- end -}}
     <div class="content">
-      <h1>{{ safeHTML (partial "CorrectPunctuation" .Title) }}</h1>
+      {{- if $subtitle -}}
+        <hgroup>
+          <h1>{{ partial "PrepareHTML" .Title }}</h1>
+          <p class="lead">{{ partial "PrepareHTML" $subtitle }}</p>
+        </hgroup>
+      {{- else -}}
+        <h1>{{ partial "PrepareHTML" .Title }}</h1>
+      {{- end -}}
+
       {{ if .Params.image }}
         <div class="avatar">
           {{ partial "commons/image.html"
diff --git a/layouts/partials/persons/summary.html b/layouts/partials/persons/summary.html
index 7893d856..85e4edf8 100644
--- a/layouts/partials/persons/summary.html
+++ b/layouts/partials/persons/summary.html
@@ -1 +1 @@
-{{- partial "commons/summary-wrapper.html" . -}}
+{{- partial "commons/summary-in-content.html" . -}}
diff --git a/layouts/partials/posts/summary.html b/layouts/partials/posts/summary.html
index 7893d856..85e4edf8 100644
--- a/layouts/partials/posts/summary.html
+++ b/layouts/partials/posts/summary.html
@@ -1 +1 @@
-{{- partial "commons/summary-wrapper.html" . -}}
+{{- partial "commons/summary-in-content.html" . -}}
diff --git a/layouts/partials/programs/hero-single.html b/layouts/partials/programs/hero-single.html
index c0ed3bb3..52958fc9 100644
--- a/layouts/partials/programs/hero-single.html
+++ b/layouts/partials/programs/hero-single.html
@@ -1,11 +1,23 @@
 {{- $title := or .Params.header_text .Title -}}
+{{ $subtitle := "" }}
+{{- $summary := partial "PrepareText" .Params.summary -}}
+{{ if and (eq site.Params.summary.position "hero") $summary }}
+  {{ $subtitle = $summary }}
+{{ end }}
 <header class="hero hero-program">
   <div class="container">
     {{- if .Params.breadcrumb | default true -}}
       {{ partial "header/breadcrumbs.html" . }}
     {{- end -}}
     <div class="content">
-      <h1>{{ partial "PrepareHTML" $title }}</h1>
+      {{- if $subtitle -}}
+        <hgroup>
+          <h1>{{ partial "PrepareHTML" $title }}</h1>
+          <p class="lead">{{ partial "PrepareHTML" $subtitle }}</p>
+        </hgroup>
+      {{- else -}}
+        <h1>{{ partial "PrepareHTML" $title }}</h1>
+      {{- end -}}
     </div>
   </div>
 
diff --git a/layouts/partials/programs/summary.html b/layouts/partials/programs/summary.html
index 7893d856..85e4edf8 100644
--- a/layouts/partials/programs/summary.html
+++ b/layouts/partials/programs/summary.html
@@ -1 +1 @@
-{{- partial "commons/summary-wrapper.html" . -}}
+{{- partial "commons/summary-in-content.html" . -}}
diff --git a/layouts/partials/sitemap/summary.html b/layouts/partials/sitemap/summary.html
index 7893d856..85e4edf8 100644
--- a/layouts/partials/sitemap/summary.html
+++ b/layouts/partials/sitemap/summary.html
@@ -1 +1 @@
-{{- partial "commons/summary-wrapper.html" . -}}
+{{- partial "commons/summary-in-content.html" . -}}
diff --git a/layouts/persons/single.html b/layouts/persons/single.html
index b5624399..efba062f 100644
--- a/layouts/persons/single.html
+++ b/layouts/persons/single.html
@@ -36,11 +36,9 @@
 
       <div class="informations">
         <div>
-          {{ if (partial "GetTextFromHTML" .Params.summary) }}
-            <div class="lead" itemprop="description">
-              {{ partial "PrepareText" .Params.summary }}
-            </div>
-          {{ end }}
+          {{ partial "persons/summary.html" (dict
+            "context" .
+          ) }}
           {{ if (partial "GetTextFromHTML" .Content) }}
             <div class="rich-text">
               {{ partial "PrepareHTML" .Content }}
-- 
GitLab