fix(taxonomy): ensure category existence check before accessing parameters
Updated the category terms layout to check for the existence of the "categories" parameter before attempting to access its length, preventing potential errors.
This commit is contained in:
@ -9,10 +9,12 @@
|
||||
<!-- get all parent categories -->
|
||||
{{ $parentCategories := slice }}
|
||||
{{ range $allPages }}
|
||||
{{ if isset .Params "categories" }}
|
||||
{{ if gt (len .Params.categories) 0 }}
|
||||
{{ $parentCategories = $parentCategories | append (index .Params.categories 0) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $parentCategories = $parentCategories | uniq | sort }}
|
||||
|
||||
<!-- create card for each parent category -->
|
||||
@ -23,6 +25,7 @@
|
||||
|
||||
<!-- get all pages and subcategories related to the parent category -->
|
||||
{{ range $allPages }}
|
||||
{{ if isset .Params "categories" }}
|
||||
{{ if gt (len .Params.categories) 0 }}
|
||||
{{ if eq (index .Params.categories 0) $parentName }}
|
||||
{{ $parentPages = $parentPages | append . }}
|
||||
@ -32,6 +35,7 @@
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $subcategories = $subcategories | uniq | sort }}
|
||||
|
||||
<div class="card categories mb-3">
|
||||
|
Reference in New Issue
Block a user