{{ $filename := add (add "shortcodes/accordion-" (.Get "number")) ".json" }} {{ with .Site.GetPage .Page.File.Path }} {{ $resource := (.Resources.GetMatch $filename).RelPermalink }} {{ $fields := getJSON "content" $resource }}
{{$counter := 0}} {{ range $fields}} {{ $heading := add "heading" (string $counter) }} {{ $collapse := add "collapse" (string $counter) }}
{{ if reflect.IsSlice .content }} {{ range .content }}

{{ . }}

{{ end }} {{ else }} {{ .content }} {{ end }}
{{$counter = add $counter 1}} {{ end }}
{{end}}