Browse Source

feat(shortcode): enable cross-referencing audio

Adds id param to audio shortcode

Hashes are prefixed in the form `#audio-<ID>`

E.g. add `id="my-talk"` when calling the audio shortcode and then reference it using [link to my talk audio](#audio-my-talk)
George Cushen 3 years ago
parent
commit
d325991ffb
2 changed files with 5 additions and 5 deletions
  1. 1 1
      .editorconfig
  2. 4 4
      wowchemy/layouts/shortcodes/audio.html

+ 1 - 1
.editorconfig

@@ -16,5 +16,5 @@ max_line_length = 100
 [*.md]
 trim_trailing_whitespace = false
 
-[{layouts/shortcodes/*.html, layouts/_default/_markup/*.html}]
+[{*/layouts/shortcodes/*.html, */layouts/_default/_markup/*.html}]
 insert_final_newline = false

+ 4 - 4
wowchemy/layouts/shortcodes/audio.html

@@ -19,8 +19,8 @@
   {{ $audio = $audio | relURL }}
 {{ end }}
 
-{{ with $audio }}
-  <audio controls>
-    <source src="{{ . }}" type="audio/{{$audio_type}}">
+{{ if $audio }}
+  <audio controls {{ with (.Get "id") }}id="audio-{{.|urlize}}"{{end}}>
+    <source src="{{$audio}}" type="audio/{{$audio_type}}">
   </audio>
-{{ end }}
+{{ end }}