Last active
November 6, 2024 15:29
-
-
Save j-un/e7d0b3118556479392bd2269f7059242 to your computer and use it in GitHub Desktop.
[Hugo] Shortcode for Spotify embed code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Parameters: | |
type - (Required) album / track / playlist / artist | |
id - (Required) Target ID | |
width - (Optional) width | |
height - (Optional) height | |
--> | |
{{ if .IsNamedParams }} | |
<iframe src="https://open.spotify.com/embed/{{ .Get "type" }}/{{ .Get "id" }}" | |
width="{{ default "100%" (.Get "width") }}" | |
height="{{ default "380" (.Get "height") }}" | |
frameborder="0" | |
allowtransparency="true" | |
allow="encrypted-media"></iframe> | |
{{ else }} | |
<iframe src="https://open.spotify.com/embed/{{ .Get 0 }}/{{ .Get 1 }}" | |
width="{{ default "100%" (.Get 2) }}" | |
height="{{ default "380" (.Get 3) }}" | |
frameborder="0" | |
allowtransparency="true" | |
allow="encrypted-media"></iframe> | |
{{ end }} |
Place this code snnipet in the following path:
layouts/shortcodes/spotify.html
And, insert like this in a .md page.
{{< spotify type="album" id="5vqILcEeCT0N1DeJBsLrGE" width="100%" height="250" >}}
cool
👍
Thanks
Thank you!
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is the shortcode i'll insert in .md page?