From b368b43eaa5e612ed35403705f7ea40f292271a1 Mon Sep 17 00:00:00 2001 From: Dwayne Charrington Date: Fri, 13 Dec 2024 11:01:54 +1000 Subject: [PATCH] fix(site): improve page rendering logic refactored the way pages are processed by storing regular pages in a variable and calculating their length. this simplifies the loop and ensures proper comma placement between items. --- themes/aurelia-theme/layouts/_default/index.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/themes/aurelia-theme/layouts/_default/index.json b/themes/aurelia-theme/layouts/_default/index.json index bfbca4c..eca66e9 100644 --- a/themes/aurelia-theme/layouts/_default/index.json +++ b/themes/aurelia-theme/layouts/_default/index.json @@ -1,7 +1,8 @@ { "pages": [ - {{- range $index, $page := .Site.RegularPages -}} - {{- if $index -}}, {{- end }} + {{- $pages := .Site.RegularPages -}} + {{- $len := len $pages -}} + {{- range $index, $page := $pages -}} { "title": {{ $page.Title | jsonify }}, "content": {{ $page.Plain | jsonify }}, @@ -9,7 +10,7 @@ "summary": {{ $page.Summary | jsonify }}, "type": {{ $page.Type | jsonify }}, "section": {{ $page.Section | jsonify }} - } + }{{- if not (eq (add $index 1) $len) -}},{{- end -}} {{- end -}} ] } \ No newline at end of file