diff --git a/src/lib/components/project.svelte b/src/lib/components/project.svelte index d5930eb..4fd97ec 100644 --- a/src/lib/components/project.svelte +++ b/src/lib/components/project.svelte @@ -1,11 +1,13 @@ - +
- Project + {name} {#if $$slots.desc}
diff --git a/src/lib/goatcounter.js b/src/lib/goatcounter.js new file mode 100644 index 0000000..c93b05c --- /dev/null +++ b/src/lib/goatcounter.js @@ -0,0 +1,29 @@ +/** + * @param {HTMLElement} elem + * @param {{ click?: string, title?: string, referrer?: string }} [opts] + */ +export function goatCounter(elem, opts) { + if(!('goatcounter' in window)) return; + if (elem.dataset.goatcounterBound && elem.dataset.goatcounterBound !== 'false') + return + const counter = function() { + // @ts-ignore + window.goatcounter.count({ + event: true, + // @ts-ignore + path: (opts.click || elem.dataset.goatcounterClick || elem.name || elem.id || ''), + title: (opts.title || elem.dataset.goatcounterTitle || elem.title || (elem.innerHTML || '').substring(0, 200) || ''), + referrer: (opts.referrer || elem.dataset.goatcounterReferrer || elem.dataset.goatcounterReferral || ''), + }) + } + elem.addEventListener("click", counter, false); + elem.addEventListener("auxclick", counter, false); + elem.dataset.goatcounterBound = 'true' + return { + destroy() { + elem.removeEventListener("click", counter, false); + elem.removeEventListener("auxclick", counter, false); + elem.dataset.goatcounterBound = 'false' + } + } +} \ No newline at end of file diff --git a/src/routes/index.svelte b/src/routes/index.svelte index 6bde3c4..b3623fb 100644 --- a/src/routes/index.svelte +++ b/src/routes/index.svelte @@ -48,7 +48,6 @@ -

I'm a young developer making appTypeHover = "websites"} on:mouseleave={() => appTypeHover == "websites" && (appTypeHover = null)}>websites, @@ -79,6 +78,7 @@ grayscale={appTypeHover && appTypeHover === "bots"} width={2050} height={1080} + name="Heaventaker" > Heaventaker - Helltaker fan game @@ -97,6 +97,7 @@ extradark width={1920} height={940} + name="Animasher" > Animasher - Platform for creating and sharing animations @@ -118,6 +119,7 @@ grayscale={appTypeHover && appTypeHover !== "websites"} width={803} height={382} + name="Mangades reader" > Mangades - Mangadex downloader and viewer @@ -136,6 +138,7 @@ grayscale={appTypeHover && appTypeHover === "applications"} width={1080} height={720} + name="igni discord bot" > igni - The universal Discord bot