Skip to content

Instantly share code, notes, and snippets.

@j-un
Last active November 6, 2024 15:29
Show Gist options
  • Save j-un/e7d0b3118556479392bd2269f7059242 to your computer and use it in GitHub Desktop.
Save j-un/e7d0b3118556479392bd2269f7059242 to your computer and use it in GitHub Desktop.
[Hugo] Shortcode for Spotify embed code
<!--
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 }}
@Abeluis
Copy link

Abeluis commented May 27, 2023

Thanks

@yunyit
Copy link

yunyit commented Dec 19, 2023

Thank you!

@HuangxinDong
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment