Plausible analytics support

This commit is contained in:
Realmy 2024-11-12 21:27:49 +01:00
parent d010fa8ec7
commit 36512b6f92
3 changed files with 12 additions and 0 deletions

2
example.env Normal file
View File

@ -0,0 +1,2 @@
PUB_HOSTNAME=vert.sh # only gets used for plausible (for now)
PUB_PLAUSIBLE_URL=https://plausible.example.com # can be empty

View File

@ -7,6 +7,7 @@
import Logo from "$lib/components/visual/svg/Logo.svelte";
import { fly } from "svelte/transition";
import featuredImage from "$lib/assets/VERT_Feature.webp";
import { PUB_HOSTNAME, PUB_PLAUSIBLE_URL } from "$env/static/public";
let { children, data } = $props();
let navWidth = $state(1);
@ -40,6 +41,11 @@
<meta name="theme-color" content="#F2ABEE" />
<meta property="og:image" content={featuredImage} />
<meta property="twitter:image" content={featuredImage} />
{#if PUB_PLAUSIBLE_URL}<script
defer
data-domain={PUB_HOSTNAME || "vert.sh"}
src="{PUB_PLAUSIBLE_URL}/js/script.js"
></script>{/if}
</svelte:head>
<div

View File

@ -12,6 +12,10 @@ const config = {
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
adapter: adapter(),
env: {
publicPrefix: "PUB_",
privatePrefix: "PRI_",
},
},
};