From 522e98dfd8dd267a5b5c5e13ac39668547ed4fec Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Tue, 19 Mar 2024 17:50:45 +0100
Subject: [PATCH] better sitemap

---
 assets/sass/_theme/sections/sitemap.sass      | 17 ++++++++++-
 layouts/pages/sitemap.html                    | 30 ++++++++++++++-----
 .../pages/sitemap_recursive_pages.html        | 10 +++++++
 3 files changed, 49 insertions(+), 8 deletions(-)
 create mode 100644 layouts/partials/pages/sitemap_recursive_pages.html

diff --git a/assets/sass/_theme/sections/sitemap.sass b/assets/sass/_theme/sections/sitemap.sass
index f5b664fc..169f8660 100644
--- a/assets/sass/_theme/sections/sitemap.sass
+++ b/assets/sass/_theme/sections/sitemap.sass
@@ -1,3 +1,4 @@
+// C'est vraiment utilisé qqpart ça ?    
 .sitemap__section
     .content
         > div
@@ -10,4 +11,18 @@
                 @include media-breakpoint-up(desktop)
                     margin-bottom: 7.5rem
                 li
-                    margin-bottom: 1rem
\ No newline at end of file
+                    margin-bottom: 1rem
+.block-sitemap
+    ul 
+        list-style-type: none
+        li
+            position: relative
+            ul
+                margin-left: $spacing-3
+                li
+                    a
+                        @include icon(list-hyphen)
+                        &::before
+                            position: absolute
+                            left: pxToRem(-24)
+                            font-size: pxToRem(24)
diff --git a/layouts/pages/sitemap.html b/layouts/pages/sitemap.html
index be610d37..163b1c20 100644
--- a/layouts/pages/sitemap.html
+++ b/layouts/pages/sitemap.html
@@ -22,17 +22,13 @@
     {{ partial "contents/list.html" . }}
 
     {{ range .Site.Sections }}
-      {{ if ne .Type "sitemap" }}
+      {{ if and (ne .Type "sitemap") (ne .Type "pages") }}
         {{ $permalink := .Permalink }}
         <div class="block block-sitemap" id="{{ .Type }}">
           <div class="container">
-            <div class="block-content">
-              {{ $isPageRoot := eq .RelPermalink "/pages/"}}
-              
+            <div class="block-content">              
               <h2>
-                {{ if not $isPageRoot }}<a href="{{ $permalink }}">{{ end }}
-                  {{ safeHTML .Title }}
-                  {{ if not $isPageRoot }}</a>{{ end }}
+                <a href="{{ $permalink }}">{{ safeHTML .Title }}</a>
               </h2>
               <ul>
                 {{ range where .Site.Pages "Section" .Type }}
@@ -46,5 +42,25 @@
         </div>
       {{ end }}
     {{ end }}
+
+    <div class="block block-sitemap" id="pages">
+      <div class="container">
+        <div class="block-content">              
+          <h2>Pages</h2>
+          <ul>
+            {{ range (where .Site.Pages "Type" "pages") }}
+              {{ if eq .Parent.Path "/pages" }}
+                <li>
+                  <a href="{{ .Permalink }}">{{ safeHTML .Title }}</a>
+                  {{ if .Pages }}
+                    {{ partial "pages/sitemap_recursive_pages" .}}
+                  {{ end }}
+                </li>
+              {{ end }}
+            {{ end }}
+          </ul>
+        </div>
+      </div>
+    </div>
   </div>
 {{ end }}
diff --git a/layouts/partials/pages/sitemap_recursive_pages.html b/layouts/partials/pages/sitemap_recursive_pages.html
new file mode 100644
index 00000000..84761ebf
--- /dev/null
+++ b/layouts/partials/pages/sitemap_recursive_pages.html
@@ -0,0 +1,10 @@
+<ul>
+  {{ range .Pages }}
+    <li>
+      <a href="{{ .Permalink }}">{{ safeHTML .Title }}</a>
+      {{ if .Pages }}
+        {{ partial "pages/sitemap_recursive_pages.html" . }}
+      {{ end }}
+    </li>
+  {{ end }}
+</ul>
-- 
GitLab