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,8 +9,10 @@
|
|||||||
<!-- get all parent categories -->
|
<!-- get all parent categories -->
|
||||||
{{ $parentCategories := slice }}
|
{{ $parentCategories := slice }}
|
||||||
{{ range $allPages }}
|
{{ range $allPages }}
|
||||||
{{ if gt (len .Params.categories) 0 }}
|
{{ if isset .Params "categories" }}
|
||||||
{{ $parentCategories = $parentCategories | append (index .Params.categories 0) }}
|
{{ if gt (len .Params.categories) 0 }}
|
||||||
|
{{ $parentCategories = $parentCategories | append (index .Params.categories 0) }}
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ $parentCategories = $parentCategories | uniq | sort }}
|
{{ $parentCategories = $parentCategories | uniq | sort }}
|
||||||
@ -23,11 +25,13 @@
|
|||||||
|
|
||||||
<!-- get all pages and subcategories related to the parent category -->
|
<!-- get all pages and subcategories related to the parent category -->
|
||||||
{{ range $allPages }}
|
{{ range $allPages }}
|
||||||
{{ if gt (len .Params.categories) 0 }}
|
{{ if isset .Params "categories" }}
|
||||||
{{ if eq (index .Params.categories 0) $parentName }}
|
{{ if gt (len .Params.categories) 0 }}
|
||||||
{{ $parentPages = $parentPages | append . }}
|
{{ if eq (index .Params.categories 0) $parentName }}
|
||||||
{{ if gt (len .Params.categories) 1 }}
|
{{ $parentPages = $parentPages | append . }}
|
||||||
{{ $subcategories = $subcategories | append (index .Params.categories 1) }}
|
{{ if gt (len .Params.categories) 1 }}
|
||||||
|
{{ $subcategories = $subcategories | append (index .Params.categories 1) }}
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
Reference in New Issue
Block a user