From 7f281d3380458ed71f3e35c4decb0d56eb0b931e Mon Sep 17 00:00:00 2001 From: limepotato Date: Thu, 4 Jul 2024 16:52:51 -0600 Subject: [PATCH] lastfm widget --- public/scripts/lastfm.js | 9 +++++++++ src/pages/index.astro | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 public/scripts/lastfm.js diff --git a/public/scripts/lastfm.js b/public/scripts/lastfm.js new file mode 100644 index 0000000..8df8a4f --- /dev/null +++ b/public/scripts/lastfm.js @@ -0,0 +1,9 @@ +let user = 'limepotato'; +let url = 'https://lastfm-last-played.biancarosa.com.br/' + user + '/latest-song'; +let song = document.querySelector('#song'); +fetch(url) + .then(function (response) { + return response.json() + }).then(function (json) { + song.innerHTML = json['track']['name'] + ' - ' + json['track']['artist']['#text']; + }); \ No newline at end of file diff --git a/src/pages/index.astro b/src/pages/index.astro index 8cf4e6f..4f8744f 100755 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -11,7 +11,7 @@ import Layout from "../layouts/Layout.astro";

Welcome to my weird little spot of the internet :3


-
+
+
+ +
+ latest played song on last.fm + powered by @biancarosa/lastfm-last-played +
+
+

About The Me