aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/_default
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-11-07 00:19:46 -0500
committertdro <tdro@noreply.example.com>2022-11-07 00:19:46 -0500
commita45739c220c8ee4cf2440b930c5b44c04ffac9f0 (patch)
tree61672f4fe6208cab7d4775f92075478f6f7970d1 /themes/default/layouts/_default
parent4e4004fcfdf72a9927c43bd571c7419122b268d4 (diff)
downloadcanory-a45739c220c8ee4cf2440b930c5b44c04ffac9f0.tar.gz
canory-a45739c220c8ee4cf2440b930c5b44c04ffac9f0.tar.bz2
canory-a45739c220c8ee4cf2440b930c5b44c04ffac9f0.zip
themes/default/layouts/_default/index.json: Avoid invalid data with proper filter
Filter outside of the range to avoid index mismatch.
Diffstat (limited to 'themes/default/layouts/_default')
-rw-r--r--themes/default/layouts/_default/index.json9
1 files changed, 5 insertions, 4 deletions
diff --git a/themes/default/layouts/_default/index.json b/themes/default/layouts/_default/index.json
index 0c9c794..78c0fde 100644
--- a/themes/default/layouts/_default/index.json
+++ b/themes/default/layouts/_default/index.json
@@ -7,8 +7,10 @@
"next_url": "{{ .URL }}",
{{- end }}
"items": [
- {{- range $index, $data := .Paginator.Pages -}}
- {{- if and (ne $data.Type "json") (not .ExpiryDate) (not .Params.unlisted) -}}
+ {{- $notExpired := where .Paginator.Pages "Params.expirydate" "eq" nil -}}
+ {{- $notUnlisted := where .Paginator.Pages "Params.unlisted" "eq" nil -}}
+ {{- $filteredPages := $notExpired | intersect $notUnlisted -}}
+ {{- range $index, $data := $filteredPages -}}
{{- if and $index (gt $index 0) -}},{{- end }}
{
"id": "{{ md5 $data.Permalink }}",
@@ -37,7 +39,6 @@
"content_text": {{ $data.Plain | jsonify }},
"content_html": {{ partial "function-content.html" $data | jsonify }}
}
- {{- end -}}
- {{ end }}
+ {{- end }}
]
}