Last active
September 13, 2025 14:44
-
-
Save macram/3992b578a19d08e87c09a071a184ffe3 to your computer and use it in GitHub Desktop.
Hugo shortcode to show most played artists on Last.FM
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
| {{ if .Get "period" }} | |
| {{ if .Get "user" }} | |
| {{ $apikey := "" }} | |
| {{ $username := .Get "user" }} | |
| {{ $baseUrl := "https://ws.audioscrobbler.com/2.0/?method=user.gettopartists&format=json" }} | |
| {{ $period := .Get "period" }} | |
| {{ $limit := .Get "limit" | default "5" }} | |
| {{ $url := printf "%s%s%s%s%s%s%s%s%s" $baseUrl "&user=" $username "&api_key=" $apikey "&period=" $period "&limit=" $limit }} | |
| {{ with resources.GetRemote $url | transform.Unmarshal }} | |
| {{ range first 1 .topartists.artist }}<a href="{{ .url }}">{{ trim .name " " }}</a>{{ end }} | |
| {{ if gt (int $limit) 2 }} | |
| {{ $middleElements := after 1 .topartists.artist | first (sub (int $limit) 2) }} | |
| {{ range $middleElements }}, <a href="{{ .url }}">{{ trim .name " " }}</a>{{ end }} | |
| {{ range last 1 .topartists.artist }}y <a href="{{ .url }}">{{ trim .name " " }}</a>{{ end }}. | |
| {{ end }} | |
| {{ end }} | |
| {{ end }} | |
| {{ end }} |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some info (in Spanish) in https://www.manumateos.dev/posts/shortcode-para-mostrar-artistas-mas-escuchados-last-fm/