diff --git a/README.md b/README.md index a71c03f4..289a794a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # coryd.dev -[![vercel-scheduled-build](https://github.com/cdransf/coryd.dev/actions/workflows/vercel-scheduled-build.yaml/badge.svg)](https://github.com/cdransf/coryd.dev/actions/workflows/vercel-scheduled-build.yaml) [![scheduled-syndication](https://github.com/cdransf/social-utils/actions/workflows/scheduled.yaml/badge.svg)](https://github.com/cdransf/social-utils/actions/workflows/scheduled.yaml) +[![scheduled-build](https://github.com/cdransf/coryd.dev/actions/workflows/scheduled-build.yaml/badge.svg)](https://github.com/cdransf/coryd.dev/actions/workflows/scheduled-build.yaml) [![scheduled-syndication](https://github.com/cdransf/social-utils/actions/workflows/scheduled.yaml/badge.svg)](https://github.com/cdransf/social-utils/actions/workflows/scheduled.yaml) Hi! I'm Cory. 👋🏻 diff --git a/src/_includes/base.liquid b/src/_includes/base.liquid index bc9e22e5..7b4bed17 100644 --- a/src/_includes/base.liquid +++ b/src/_includes/base.liquid @@ -42,6 +42,43 @@ document.documentElement.classList.add('dark') } }); + + ;(function () { + const nowPlayingWrapper = document.getElementById("now-playing"); + if (nowPlayingWrapper) { + try { + const localStorageKey = "CD_NOW_PLAYING"; + const cachedTemplate = localStorage.getItem(localStorageKey); + + if (window.localStorage && cachedTemplate) { + nowPlayingWrapper.innerHTML = ""; + nowPlayingWrapper.insertAdjacentHTML("beforeEnd", cachedTemplate); + } + + fetch("https://utils.coryd.dev/api/music?limit=1&period=7day") + .then((response) => response.json()) + .then((data) => { + const track = data.recenttracks.track[0]; + const artistName = track.artist["#text"]; + const template = `${ + track.name + } by ${artistName}`; + + if (window.localStorage) + localStorage.setItem(localStorageKey, template); + + nowPlayingWrapper.innerHTML = ""; + nowPlayingWrapper.insertAdjacentHTML("beforeEnd", template); + }); + } catch (e) { + nowPlayingWrapper.innerHTML = ""; + } + } + })(); diff --git a/src/_includes/now-topper.liquid b/src/_includes/now-topper.liquid index d134a56a..7a20d8da 100644 --- a/src/_includes/now-topper.liquid +++ b/src/_includes/now-topper.liquid @@ -2,4 +2,12 @@

Now

I'm a software developer in Camarillo, California. I enjoy hanging out with my beautiful family and 4 rescue dogs, technology, automation, music, writing, reading and tv and movies.

{{ status.emoji }} {{ status.content }}

+

+ + {% heroicon "solid" "music-note" "Now playing" "width=20 height=20" %} + + + Loading track + +