{{- $source := ($.Page.Resources.ByType "audio").GetMatch (printf "%s" (.Get "name")) }}
{{- $customAlt := .Get "alt" }}


{{- with $source }}
  {{- $caption := default .Title $customAlt }}

  <div class="flex justify-center">
    <figure class="gdoc-markdown__figure">
      <audio controls class="player" preload="auto">
        <source src="{{ .Permalink }}" type="audio/mpeg">
      </audio>
      {{- with $caption }}
        <figcaption>
          {{ . }}
          {{- with $source.Params.credits }}
            {{ printf " (%s)" . | $.Page.RenderString }}
          {{- end }}
        </figcaption>
      {{- end }}
    </figure>
  </div>
{{- end }}
