offload now calls + generation to 11ty; add activity feed; cleanup
This commit is contained in:
parent
4bd059bc90
commit
4dd6cc9313
18 changed files with 192 additions and 93 deletions
|
@ -23,6 +23,7 @@
|
|||
<link rel="pingback" href="https://webmention.io/coryd.dev/xmlrpc" />
|
||||
<link type="application/atom+xml" rel="alternate" title="Cory Dransfeldt" href="/feed.xml">
|
||||
<link rel="alternate" type="application/json" title="Cory Dransfeldt" href="/feed.json" />
|
||||
<link rel="alternate" href="/follow.xml" title="Cory Dransfeldt's activity feed" type="application/rss+xml">
|
||||
<script>
|
||||
const isDarkMode = () => localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
if (isDarkMode()) {
|
||||
|
@ -44,43 +45,6 @@
|
|||
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")
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
const track = data.recenttracks.track[0];
|
||||
const artistName = track.artist["#text"];
|
||||
const template = `<a href="${
|
||||
track.url
|
||||
}" class="no-underline dark:text-white text-gray-800 font-normal">${
|
||||
track.name
|
||||
}</a> by <a href="https://ddg.gg?q=!rym ${encodeURIComponent(
|
||||
artistName
|
||||
)}" class="no-underline dark:text-white text-gray-800 font-normal">${artistName}</a>`;
|
||||
|
||||
if (window.localStorage)
|
||||
localStorage.setItem(localStorageKey, template);
|
||||
|
||||
nowPlayingWrapper.innerHTML = "";
|
||||
nowPlayingWrapper.insertAdjacentHTML("beforeEnd", template);
|
||||
});
|
||||
} catch (e) {
|
||||
nowPlayingWrapper.innerHTML = "";
|
||||
}
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Reference in a new issue