From 47eb76b906d602a58ee9d76747c89e262dc773f3 Mon Sep 17 00:00:00 2001
From: claraRigo <clararigaud0@gmail.com>
Date: Thu, 29 Aug 2024 10:42:05 +0200
Subject: [PATCH] Page Campus Correction du bug  (#542)

---
 assets/sass/_theme/sections/diplomas.sass     |  5 +++-
 layouts/locations/term.html                   | 16 +----------
 layouts/partials/locations/diplomas.html      | 28 ++++++++++++-------
 layouts/partials/locations/program.html       | 19 +++++++++++++
 .../partials/locations/template-program.html  | 20 -------------
 5 files changed, 42 insertions(+), 46 deletions(-)
 create mode 100644 layouts/partials/locations/program.html
 delete mode 100644 layouts/partials/locations/template-program.html

diff --git a/assets/sass/_theme/sections/diplomas.sass b/assets/sass/_theme/sections/diplomas.sass
index e4cbaefd..f70edc41 100644
--- a/assets/sass/_theme/sections/diplomas.sass
+++ b/assets/sass/_theme/sections/diplomas.sass
@@ -11,6 +11,7 @@ ul.diplomas
             padding-bottom: $spacing-3
             padding-top: $spacing-3
             border-bottom: 1px solid var(--color-border)
+            @include hover-translate-icon
             @include icon(arrow-right-line, after)
                 align-self: center
                 margin-left: auto
@@ -193,14 +194,16 @@ ul.diplomas
                             gap: var(--grid-gutter)
                         &:not(:first-child)
                             border-top: 1px solid var(--color-border)
+                            margin-top: $spacing-3
                             padding-top: $spacing-3
                         .program-content
                             width: 100%
                             @include media-breakpoint-up(xl)
                                 width: columns(8)        
                             > a
+                                @include stretched-link(before)
+                                @include hover-translate-icon
                                 @include icon(arrow-right-line, after)
-                                    align-self: end
                                     margin-left: $spacing-1
                             .description
                                 padding-top: $spacing-2 
diff --git a/layouts/locations/term.html b/layouts/locations/term.html
index 99a40a47..56d82241 100644
--- a/layouts/locations/term.html
+++ b/layouts/locations/term.html
@@ -12,22 +12,8 @@
       ) }}
 
     {{ partial "contents/list.html" . }}
-
     <div class="container">
-
-      {{ with .Params.diplomas }}
-
-        {{/*  Get diplomas collection from diploma's paths  */}}
-        {{ $diplomas := slice }}
-        {{ range . }}
-          {{ with site.GetPage (printf "/diplomas/%s" .path) }}
-            {{ $diplomas = $diplomas | append . }}
-          {{ end }}
-        {{ end }}
-
-        {{ partial "locations/diplomas.html" ( dict "diplomas" $diplomas ) }}
-      {{ end }}
-      {{ partial "commons/pagination.html" . }}
+      {{ partial "partials/locations/diplomas.html" .Params}}
     </div>
   </div>
   {{ if and .Params.contact_details.geolocation.longitude .Params.contact_details.geolocation.latitude }}
diff --git a/layouts/partials/locations/diplomas.html b/layouts/partials/locations/diplomas.html
index 88da2678..95b0d448 100644
--- a/layouts/partials/locations/diplomas.html
+++ b/layouts/partials/locations/diplomas.html
@@ -1,17 +1,25 @@
-{{ $diplomas := .diplomas }}
+{{/*  Get programs associated to location  */}}
+{{ $programs := .programs }}
 <ul class="diplomas">
-  {{ range $diplomas }}
+{{ range .diplomas }}
+  {{ $path := .path }}
+  {{ with site.GetPage (printf "/diplomas/%s" .path) }}
     <li>
       <a href="{{ .Permalink }}" aria-label="{{ i18n "commons.more_aria" (dict "Title" .Title) }}">
         {{- partial "PrepareHTML" .Title -}}
       </a>
-      <div class="content">
-        <ol class="programs">
-          {{- range .Params.programs -}}
-            {{- template "partials/locations/template-program.html" . -}}
-          {{- end -}}
-        </ol>
-      </div>
+      {{ if $programs }}
+        <div class="content">
+          <ol class="programs">
+            {{- range $programs -}}
+              {{ $program := site.GetPage (printf "/programs%s" .) }}
+              {{ if (eq $path $program.Params.diplomas)}}
+                {{- partial "partials/locations/program.html" $program.Params -}}
+              {{ end }}
+            {{- end -}}
+          </ol>
+        </div>
+      {{ end }}
     </li>
   {{ end }}
-</ul>
\ No newline at end of file
+{{ end }}
\ No newline at end of file
diff --git a/layouts/partials/locations/program.html b/layouts/partials/locations/program.html
new file mode 100644
index 00000000..0f138f75
--- /dev/null
+++ b/layouts/partials/locations/program.html
@@ -0,0 +1,19 @@
+<li>
+  <div class="program-content">
+    <a href="{{ .hugo.permalink }}" title="{{ safeHTML (i18n "commons.more_aria" (dict "Title" .title)) }}">
+      {{- partial "PrepareHTML" .Title -}}
+    </a>
+    <div class="description">
+      {{- .summary | safeHTML}}
+    </div>
+  </div>
+  <div class="media">
+    {{- if .image -}}
+      {{- partial "commons/image.html"
+        (dict
+            "image"    .image
+            "sizes"    site.Params.image_sizes.sections.programs.item
+        ) -}}
+    {{- end -}}
+  </div>
+</li>
\ No newline at end of file
diff --git a/layouts/partials/locations/template-program.html b/layouts/partials/locations/template-program.html
deleted file mode 100644
index 2d29238b..00000000
--- a/layouts/partials/locations/template-program.html
+++ /dev/null
@@ -1,20 +0,0 @@
-{{ $program := site.GetPage (printf "/programs%s" .slug) }}
-<li>
-  <div class="program-content">
-    <a href="{{ .path }}" title="{{ safeHTML (i18n "commons.more_aria" (dict "Title" .label)) }}">
-      {{- partial "PrepareHTML" .label -}}
-    </a>
-    <div class="description">
-      {{- $program.Params.summary }}
-    </div>
-  </div>
-  <div class="media">
-    {{- if $program.Params.image -}}
-      {{- partial "commons/image.html"
-        (dict
-            "image"    $program.Params.image
-            "sizes"    site.Params.image_sizes.sections.programs.item
-        ) -}}
-    {{- end -}}
-  </div>
-</li>
-- 
GitLab