From ec91f5a04cafff2b8e4263f3c59b34bf599e8ba5 Mon Sep 17 00:00:00 2001
From: alexisben <alex@noesya.coop>
Date: Wed, 15 Feb 2023 11:19:29 +0100
Subject: [PATCH] handle block pages grid template outside block context

---
 layouts/partials/blocks/templates/pages/grid.html | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/layouts/partials/blocks/templates/pages/grid.html b/layouts/partials/blocks/templates/pages/grid.html
index 10e0a57d..54c096d8 100644
--- a/layouts/partials/blocks/templates/pages/grid.html
+++ b/layouts/partials/blocks/templates/pages/grid.html
@@ -3,7 +3,14 @@
 
 <div class="grid">
   {{ range .pages }}
-    {{- $page := partial "GetPageByUrl" .page -}}
+    {{- $page := false -}}
+    {{/*  Check if . is a map or page url, necessary when pages/grid is called outside block context */}}
+    {{ if reflect.IsMap . }}
+      {{- $page = partial "GetPageByUrl" .page -}}
+    {{ else }}
+      {{- $page =  partial "GetPageByUrl" . -}}
+    {{ end }}
+
     {{ with $page }}
       <article>
         <h3>
-- 
GitLab