{{ $filename := add (add "shortcodes/accordion-" (.Get "number")) ".json" }}

{{ with .Site.GetPage .Page.File.Path }}

    {{ $resource := (.Resources.GetMatch $filename).RelPermalink }}
    {{ $fields := getJSON "content" $resource }}

  <div class="accordion" id="accordionExample">
    {{$counter := 0}}
    {{ range $fields}}

    {{ $heading := add "heading" (string $counter) }}
    {{ $collapse := add "collapse" (string $counter) }}

    <div class="accordion-item">
      <div class="accordion-header" id="{{$heading}}">
        <a class="accordion-button collapsed" role="button" data-bs-toggle="collapse" data-bs-target="#{{$collapse}}" aria-expanded="false" aria-controls="{{$collapse}}">
          {{ .title }}
        </a>
      </div>
      <div id="{{$collapse}}" class="accordion-collapse collapse" aria-labelledby="{{$heading}}" data-bs-parent="#accordionExample">
        <div class="accordion-body">
          {{ if reflect.IsSlice .content }}
            {{ range .content }}
              <p>{{ . }}</p>
            {{ end }}
          {{ else }}
            {{ .content }}
          {{ end }}
        </div>
      </div>
    </div>

    {{$counter = add $counter 1}}
    
    {{ end }}

  </div>
  
{{end}}
