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/400.css";
|
||||||
import "@fontsource/ibm-plex-mono/500.css";
|
import "@fontsource/ibm-plex-mono/500.css";
|
||||||
|
|
||||||
|
import env from "$lib/env";
|
||||||
import settings from "$lib/state/settings";
|
import settings from "$lib/state/settings";
|
||||||
import { device, app } from "$lib/device";
|
import { device, app } from "$lib/device";
|
||||||
import { locale } from "$lib/i18n/translations";
|
import { locale } from "$lib/i18n/translations";
|
||||||
|
@ -23,6 +24,15 @@
|
||||||
{#if device.is.mobile}
|
{#if device.is.mobile}
|
||||||
<meta name="theme-color" content={statusBarColors[$currentTheme]}>
|
<meta name="theme-color" content={statusBarColors[$currentTheme]}>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if env.PLAUSIBLE_ENABLED}
|
||||||
|
<script
|
||||||
|
defer
|
||||||
|
data-domain="{env.HOST}"
|
||||||
|
src="https://{env.PLAUSIBLE_HOST}/js/script.js"
|
||||||
|
>
|
||||||
|
</script>
|
||||||
|
{/if}
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div style="display: contents" data-theme={$currentTheme} lang="{$locale}">
|
<div style="display: contents" data-theme={$currentTheme} lang="{$locale}">
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import env from "$lib/env";
|
||||||
import { t } from "$lib/i18n/translations";
|
import { t } from "$lib/i18n/translations";
|
||||||
|
|
||||||
import SettingsCategory from "$components/settings/SettingsCategory.svelte";
|
import SettingsCategory from "$components/settings/SettingsCategory.svelte";
|
||||||
|
@ -6,7 +7,8 @@
|
||||||
import OuterLink from "$components/misc/OuterLink.svelte";
|
import OuterLink from "$components/misc/OuterLink.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<SettingsCategory sectionId="privacy" title={$t("settings.privacy.analytics")}>
|
{#if env.PLAUSIBLE_ENABLED}
|
||||||
|
<SettingsCategory sectionId="analytics" title={$t("settings.privacy.analytics")}>
|
||||||
<SettingsToggle
|
<SettingsToggle
|
||||||
settingContext="privacy"
|
settingContext="privacy"
|
||||||
settingId="disableAnalytics"
|
settingId="disableAnalytics"
|
||||||
|
@ -19,6 +21,7 @@
|
||||||
</OuterLink>
|
</OuterLink>
|
||||||
</div>
|
</div>
|
||||||
</SettingsCategory>
|
</SettingsCategory>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.learn-more-plausible {
|
.learn-more-plausible {
|
||||||
|
|
Loading…
Reference in a new issue