diff --git a/netlify/edge-functions/now-playing.js b/netlify/edge-functions/now-playing.js index e44ee9cb..ef87f436 100644 --- a/netlify/edge-functions/now-playing.js +++ b/netlify/edge-functions/now-playing.js @@ -17,7 +17,7 @@ export default async () => { return Response.json({ artist: track['artistName'], title: track['name'], - emoji: '🎧', + text: `🎧 ${track['name']} by ${track['artistName']}`, }) } diff --git a/src/_includes/partials/now/playing.liquid b/src/_includes/partials/now/playing.liquid index eebdb0ec..073ffd8c 100644 --- a/src/_includes/partials/now/playing.liquid +++ b/src/_includes/partials/now/playing.liquid @@ -3,6 +3,6 @@ {% tablericon 'loader-2' 'Loading...' %} - +

\ No newline at end of file diff --git a/src/assets/scripts/script.js b/src/assets/scripts/script.js index 9b647c2c..37a1aff6 100644 --- a/src/assets/scripts/script.js +++ b/src/assets/scripts/script.js @@ -1,14 +1,13 @@ ;(async function () { const nowPlaying = document.getElementById('now-playing') + if (nowPlaying) { - const emoji = document.getElementById('now-playing-emoji') const content = document.getElementById('now-playing-content') const loading = document.getElementById('now-playing-loading') + const populateNowPlaying = (data) => { loading.style.display = 'none' - emoji.innerText = data.emoji - content.innerText = `${data.title} by ${data.artist}` - emoji.classList.remove('hidden') + content.innerText = data.text content.classList.remove('hidden') } @@ -19,12 +18,13 @@ /* quiet catch */ } - const res = await fetch('/api/now-playing', { + const data = await fetch('/api/now-playing', { type: 'json', - }).catch(() => { - loading.style.display = 'none' }) - const data = await res.json() + .then((data) => data.json()) + .catch(() => { + loading.style.display = 'none' + }) try { localStorage.setItem('now-playing', JSON.stringify(data))