From 128ab388f3128f2b94fcaccf3f5c489188df66b5 Mon Sep 17 00:00:00 2001 From: wukko Date: Sun, 14 Jul 2024 22:50:18 +0600 Subject: [PATCH] web: add env variable & plausible functionality --- web/src/lib/env.ts | 9 ++++++ web/src/routes/+layout.svelte | 10 +++++++ .../settings/general/privacy/+page.svelte | 29 ++++++++++--------- 3 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 web/src/lib/env.ts diff --git a/web/src/lib/env.ts b/web/src/lib/env.ts new file mode 100644 index 00000000..a5f08382 --- /dev/null +++ b/web/src/lib/env.ts @@ -0,0 +1,9 @@ +import { env } from "$env/dynamic/public"; + +const variables = { + HOST: env.PUBLIC_HOST, + PLAUSIBLE_HOST: env.PUBLIC_PLAUSIBLE_HOST, + PLAUSIBLE_ENABLED: env.PUBLIC_HOST && env.PUBLIC_PLAUSIBLE_HOST, +} + +export default variables; diff --git a/web/src/routes/+layout.svelte b/web/src/routes/+layout.svelte index e203f1de..20eeabbc 100644 --- a/web/src/routes/+layout.svelte +++ b/web/src/routes/+layout.svelte @@ -2,6 +2,7 @@ import "@fontsource/ibm-plex-mono/400.css"; import "@fontsource/ibm-plex-mono/500.css"; + import env from "$lib/env"; import settings from "$lib/state/settings"; import { device, app } from "$lib/device"; import { locale } from "$lib/i18n/translations"; @@ -23,6 +24,15 @@ {#if device.is.mobile} {/if} + + {#if env.PLAUSIBLE_ENABLED} + + {/if}
diff --git a/web/src/routes/settings/general/privacy/+page.svelte b/web/src/routes/settings/general/privacy/+page.svelte index c6f65a7f..00eacbca 100644 --- a/web/src/routes/settings/general/privacy/+page.svelte +++ b/web/src/routes/settings/general/privacy/+page.svelte @@ -1,4 +1,5 @@ - - -
- - {$t("settings.privacy.analytics.learnmore")} - -
-
+{#if env.PLAUSIBLE_ENABLED} + + +
+ + {$t("settings.privacy.analytics.learnmore")} + +
+
+{/if}