mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
web: add env variable & plausible functionality
This commit is contained in:
parent
436b735d2a
commit
128ab388f3
3 changed files with 35 additions and 13 deletions
9
web/src/lib/env.ts
Normal file
9
web/src/lib/env.ts
Normal file
|
@ -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;
|
|
@ -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}
|
||||
<meta name="theme-color" content={statusBarColors[$currentTheme]}>
|
||||
{/if}
|
||||
|
||||
{#if env.PLAUSIBLE_ENABLED}
|
||||
<script
|
||||
defer
|
||||
data-domain="{env.HOST}"
|
||||
src="https://{env.PLAUSIBLE_HOST}/js/script.js"
|
||||
>
|
||||
</script>
|
||||
{/if}
|
||||
</svelte:head>
|
||||
|
||||
<div style="display: contents" data-theme={$currentTheme} lang="{$locale}">
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<script lang="ts">
|
||||
import env from "$lib/env";
|
||||
import { t } from "$lib/i18n/translations";
|
||||
|
||||
import SettingsCategory from "$components/settings/SettingsCategory.svelte";
|
||||
|
@ -6,19 +7,21 @@
|
|||
import OuterLink from "$components/misc/OuterLink.svelte";
|
||||
</script>
|
||||
|
||||
<SettingsCategory sectionId="privacy" title={$t("settings.privacy.analytics")}>
|
||||
<SettingsToggle
|
||||
settingContext="privacy"
|
||||
settingId="disableAnalytics"
|
||||
title={$t("settings.privacy.analytics.title")}
|
||||
description={$t("settings.privacy.analytics.description")}
|
||||
/>
|
||||
<div class="subtext learn-more-plausible">
|
||||
<OuterLink href="https://plausible.io/privacy-focused-web-analytics">
|
||||
{$t("settings.privacy.analytics.learnmore")}
|
||||
</OuterLink>
|
||||
</div>
|
||||
</SettingsCategory>
|
||||
{#if env.PLAUSIBLE_ENABLED}
|
||||
<SettingsCategory sectionId="analytics" title={$t("settings.privacy.analytics")}>
|
||||
<SettingsToggle
|
||||
settingContext="privacy"
|
||||
settingId="disableAnalytics"
|
||||
title={$t("settings.privacy.analytics.title")}
|
||||
description={$t("settings.privacy.analytics.description")}
|
||||
/>
|
||||
<div class="subtext learn-more-plausible">
|
||||
<OuterLink href="https://plausible.io/privacy-focused-web-analytics">
|
||||
{$t("settings.privacy.analytics.learnmore")}
|
||||
</OuterLink>
|
||||
</div>
|
||||
</SettingsCategory>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.learn-more-plausible {
|
||||
|
|
Loading…
Reference in a new issue