So we’re doing a few things here. We’re using Nunjucks to set
which array we want to loop over. lastfm
is the name of the data file, recenttracks
is the object that contains our track
s, and each track
has our necessary items. From there, we only render the rest of the template if there are songs to display.
You’ll then want to include this partial in your template like this:
{% include "partials/recently-played.html" %}
And just like that, we’ve fetched our data and rendered it in our template! Now it’s your turn to add some style. This is the moment I felt like a total badass, hope you’re feeling it too.
If you need some help or end up using this on your site, please let me know! You can find me on Twitter as @smithtimmytim. Happy coding!
Documenting new and exciting things I learn how to do with Eleventy.
View Series →