1
Files
2025/themes/default/layouts/shortcodes/sound.html

29 lines
1009 B
HTML

{{- $soundData := .Get 0 -}}
{{- $alignment := .Get 1 | default "center" -}}
{{- $dataFile := .Page.Resources.Get (printf "data/sounds/%s.yaml" $soundData) -}}
{{- if $dataFile -}}
{{- $data := $dataFile.Content | transform.Unmarshal -}}
{{- $audio := .Page.Resources.Get $data.file -}}
{{- if $audio -}}
<figure class="custom-sound {{ $alignment }}">
<audio controls preload="metadata">
<source src="{{ $audio.RelPermalink }}">
Votre navigateur ne prend pas en charge la lecture audio.
</audio>
{{- if or $data.title (or $data.description $data.attribution) }}
<figcaption>
{{- with $data.title }}
<p><strong>{{ . }}</strong></p>
{{- end }}
{{- with $data.description }}
<p>{{ . | markdownify }}</p>
{{- end }}
{{- with $data.attribution }}
<p class="details"><strong>Attribution :</strong> <em>{{ . | markdownify }}</em></p>
{{- end }}
</figcaption>
{{- end }}
</figure>
{{- end -}}
{{- end -}}