A shortcode for audio files based on the internal figure shortcode.
I am using the static site generator hugo to build my website.
There is no built in shortcode for audio files, so I created one which fits my needs.
It works with page resorces and absolute urls.
audio.html
Put this file with the following code in your projects layouts/shortcodes folder.
{{- $u := urls.Parse (.Get "src") -}}
{{- $src := $u.String -}}
{{- if not $u.IsAbs -}}
{{- with or (.Page.Resources.Get $u.Path) (resources.Get $u.Path) -}}
{{- $src = .RelPermalink -}}
{{- end -}}
{{- end -}}
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
{{ with (.Get "title") -}}
{{ . }}
{{- end -}}
{{- if or (.Get "caption") (.Get "attr") -}}