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 }}
@MrAntooo
Copy link

MrAntooo commented Nov 7, 2021

What is the shortcode i'll insert in .md page?

@j-un
Copy link
Author

j-un commented Nov 8, 2021

@MrAntooo

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" >}}

@aimerneige
Copy link

cool

@j-un
Copy link
Author

j-un commented Mar 7, 2023

👍

@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