diff --git a/package.json b/package.json
index bf951c8a..09886182 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "coryd.dev",
- "version": "6.6.4",
+ "version": "6.7.0",
"description": "The source for my personal site. Built using 11ty and hosted on Netlify.",
"type": "module",
"scripts": {
diff --git a/src/_includes/partials/now-playing.liquid b/src/_includes/partials/now-playing.liquid
index 7c9ae4d2..78d309a0 100644
--- a/src/_includes/partials/now-playing.liquid
+++ b/src/_includes/partials/now-playing.liquid
@@ -1,2 +1,5 @@
-
- - - -
-` -nowPlayingTemplate.id = "now-playing-template" - -if (!document.getElementById(nowPlayingTemplate.id)) document.body.appendChild(nowPlayingTemplate) - class NowPlaying extends HTMLElement { - static register(tagName) { - if ("customElements" in window) customElements.define(tagName || "now-playing", NowPlaying); + static tagName = 'now-playing' + + static register(tagName, registry) { + if(!registry && ('customElements' in globalThis)) { + registry = globalThis.customElements; + } + registry?.define(tagName || this.tagName, this); + } + + static attr = { + url: 'api-url' + } + + get url() { + return this.getAttribute(NowPlaying.attr.url) || ''; } async connectedCallback() { - this.append(this.template); + if (this.shadowRoot) return; const data = { ...(await this.data) }; - const loading = this.querySelector('[data-key="loading"]') - const content = this.querySelector('[data-key="content"]') + let shadowroot = this.attachShadow({ mode: 'open' }) + let slot = document.createElement('slot') + shadowroot.appendChild(slot) + + const loading = this.querySelector('.loading') + const content = this.querySelector('.content') const value = data['content'] if (!value) { @@ -37,12 +40,8 @@ class NowPlaying extends HTMLElement { } } - get template() { - return document.getElementById(nowPlayingTemplate.id).content.cloneNode(true); - } - get data() { - return fetch('/api/now-playing', { type: 'json' }).then((data) => data.json()).catch((e) => {}) + return fetch(this.url, { type: 'json' }).then((data) => data.json()).catch((e) => {}) } } -