Today, I accidentally found a good music from Spotify. I want to share it on my blog, so I try this awesome code. Bellow are the what it look like:
Full code from j-un:
This file contains hidden or 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 }} |
Download this html file or copy the code, put it in layouts/shortcodes/spotify.html
. Enjoy it!