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
3 changes: 3 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
run: npm ci

- name: Build site
env:
# Google Analytics 4 measurement ID; public (it ships in every page), so not a secret.
PUBLIC_GA_ID: G-C902XCTMKD
run: npm run build

- name: Deploy to Cloudflare Pages
Expand Down
14 changes: 14 additions & 0 deletions src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const cleanPath = Astro.url.pathname.replace(/\.html$/, '').replace(/\/index$/,
const canonical = new URL(cleanPath, Astro.site).toString();
// Shared social card (logo lockup on the dark brand background) until pages get their own.
const ogImage = new URL('/og-default.png', Astro.site).toString();
// Google Analytics 4 measurement ID (G-XXXXXXXXXX), set at build time. No ID, no tag.
const gaId = import.meta.env.PUBLIC_GA_ID;
---
<!doctype html>
<html lang="en" data-theme="dark">
Expand Down Expand Up @@ -107,6 +109,18 @@ const ogImage = new URL('/og-default.png', Astro.site).toString();
<link rel="preload" href={bodyFont} as="font" type="font/woff2" crossorigin />

{jsonLd.length > 0 && <script type="application/ld+json" set:html={JSON.stringify(jsonLd.length === 1 ? jsonLd[0] : jsonLd)} />}

{gaId && (
<>
<script is:inline async src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`}></script>
<script is:inline define:vars={{ gaId }}>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', gaId);
</script>
</>
)}
</head>
<body>
<a class="skip" href="#main">Skip to content</a>
Expand Down
Loading