Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
working-directory: web
env:
NODE_ENV: production
PUBLIC_CLOUDFLARE_WEB_ANALYTICS_TOKEN: ${{ vars.CLOUDFLARE_WEB_ANALYTICS_TOKEN || secrets.CLOUDFLARE_WEB_ANALYTICS_TOKEN }}

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
Expand Down
1 change: 1 addition & 0 deletions web/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PUBLIC_CLOUDFLARE_WEB_ANALYTICS_TOKEN=
12 changes: 12 additions & 0 deletions web/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { env } from '$env/dynamic/public';
import type { Snippet } from 'svelte';
import '../app.css';
import { SiteFooter, SiteHeader, Tagline } from '$lib/components';
Expand All @@ -11,6 +12,10 @@
const SOCIAL_TITLE = 'fivethirtyeightindex.com';
const SOCIAL_DESCRIPTION =
'An index of every fivethirtyeight.com article preserved by the Internet Archive.';
const CLOUDFLARE_TOKEN = env.PUBLIC_CLOUDFLARE_WEB_ANALYTICS_TOKEN || '';
const CLOUDFLARE_BEACON = JSON.stringify({
token: CLOUDFLARE_TOKEN
});
</script>

<svelte:head>
Expand All @@ -23,6 +28,13 @@
<meta name="twitter:title" content={SOCIAL_TITLE} />
<meta name="twitter:description" content={SOCIAL_DESCRIPTION} />
<meta name="twitter:image" content={SOCIAL_IMAGE} />
{#if CLOUDFLARE_TOKEN}
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon={CLOUDFLARE_BEACON}
></script>
{/if}
</svelte:head>

<div class="page">
Expand Down
Loading