feat: add tracking
This commit is contained in:
parent
db8b47a7af
commit
1f3640c576
2 changed files with 13 additions and 9 deletions
|
|
@ -2,6 +2,7 @@
|
|||
/* eslint-disable svelte/no-at-html-tags -- JSON-LD is serialized and script-safe */
|
||||
import { page } from '$app/state';
|
||||
import { locale } from '$lib/translations';
|
||||
import { isDevelopment } from '$lib/utils/env';
|
||||
|
||||
/**
|
||||
* @typedef {Object} Props
|
||||
|
|
@ -35,9 +36,7 @@
|
|||
jsonLd = null,
|
||||
} = $props();
|
||||
|
||||
const twitterDescription = $derived(
|
||||
twitterDescriptionProp ?? ogDescription,
|
||||
);
|
||||
const twitterDescription = $derived(twitterDescriptionProp ?? ogDescription);
|
||||
|
||||
const siteName = 'Leonardo Murça';
|
||||
|
||||
|
|
@ -45,13 +44,9 @@
|
|||
`${page.url.origin}${page.url.pathname || '/'}`,
|
||||
);
|
||||
|
||||
const ogLocale = $derived(
|
||||
$locale === 'pt-BR' ? 'pt_BR' : 'en_US',
|
||||
);
|
||||
const ogLocale = $derived($locale === 'pt-BR' ? 'pt_BR' : 'en_US');
|
||||
|
||||
const alternateLocale = $derived(
|
||||
$locale === 'pt-BR' ? 'en_US' : 'pt_BR',
|
||||
);
|
||||
const alternateLocale = $derived($locale === 'pt-BR' ? 'en_US' : 'pt_BR');
|
||||
|
||||
const imageAlt = $derived(ogImageAlt || ogTitle);
|
||||
</script>
|
||||
|
|
@ -94,4 +89,8 @@
|
|||
{#if jsonLd}
|
||||
{@html `<script type="application/ld+json">${jsonLd.replace(/</g, '\\u003c')}</script>`}
|
||||
{/if}
|
||||
|
||||
{#if !isDevelopment()}
|
||||
<script async src="https://hk.leomurca.xyz/hk.js"></script>
|
||||
{/if}
|
||||
</svelte:head>
|
||||
|
|
|
|||
5
src/lib/utils/env.js
Normal file
5
src/lib/utils/env.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
function isDevelopment() {
|
||||
return import.meta.env.MODE === 'development';
|
||||
}
|
||||
|
||||
export { isDevelopment };
|
||||
Loading…
Add table
Reference in a new issue