shortcodes: audio (#9)

This commit is contained in:
Vamsi Krishna 2021-07-13 14:36:17 +05:30 committed by GitHub
parent ea75958a39
commit 90c8df3121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,19 @@
{{ $src := .Get 0 }}
{{ $split_src := split $src "." }}
{{ $extension := index $split_src (sub (len $split_src) 1) }}
<audio preload="auto" controls>
{{ if eq $extension "ogg" }}
<source src="{{ $src }}" type="audio/ogg">
Your browser doesn't support Ogg Vorbis audio. :(
<a href="{{ $src }}">Download the audio instead</a>
{{ else if eq $extension "mp3" }}
<source src="{{ $src }}" type="audio/mpeg">
<a href="{{ $src }}">Download the audio instead</a>
{{ else if eq $extension "wav" }}
<source src="{{ $src }}" type="audio/wav">
<a href="{{ $src }}">Download the audio instead</a>
{{ else }}
<a href="{{ $src }}">Download the audio instead</a>
{{ end }}
</audio>