From 0cb5d90fa2ba96efff15bcaa58eacdc94f50b1f8 Mon Sep 17 00:00:00 2001 From: Sammy Shear Date: Fri, 22 Mar 2024 22:14:42 -0400 Subject: [PATCH] Google Analytics and fixed astro config site --- astro.config.mjs | 13 +++++++++++-- package.json | 1 + pnpm-lock.yaml | 21 +++++++++++++++++++++ src/components/GoogleAnalytics.astro | 23 +++++++++++++++++++++++ src/layouts/Layout.astro | 3 +++ 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 src/components/GoogleAnalytics.astro diff --git a/astro.config.mjs b/astro.config.mjs index 53b4d61..e2197c4 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -5,10 +5,19 @@ import robotsTxt from "astro-robots-txt"; import sitemap from "@astrojs/sitemap"; import compressor from "astro-compressor"; +import partytown from "@astrojs/partytown"; + // https://astro.build/config export default defineConfig({ - site: "https://localhost:4321", - integrations: [tailwind(), react(), robotsTxt(), sitemap(), compressor()], + site: "https://sshear.dev", + integrations: [ + tailwind(), + react(), + robotsTxt(), + sitemap(), + compressor(), + partytown({ config: { forward: ["dataLayer.push"] } }) + ], markdown: { shikiConfig: { themes: { diff --git a/package.json b/package.json index b7c40ac..1b28653 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ }, "dependencies": { "@astrojs/check": "^0.5.9", + "@astrojs/partytown": "^2.0.4", "@astrojs/react": "^3.1.0", "@astrojs/sitemap": "^3.1.1", "@astrojs/tailwind": "^5.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4e76166..266f8c6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ dependencies: '@astrojs/check': specifier: ^0.5.9 version: 0.5.9(prettier-plugin-astro@0.13.0)(prettier@3.2.5)(typescript@5.4.2) + '@astrojs/partytown': + specifier: ^2.0.4 + version: 2.0.4 '@astrojs/react': specifier: ^3.1.0 version: 3.1.0(@types/react-dom@18.2.22)(@types/react@18.2.67)(react-dom@18.2.0)(react@18.2.0)(vite@5.1.6) @@ -163,6 +166,13 @@ packages: - supports-color dev: false + /@astrojs/partytown@2.0.4: + resolution: {integrity: sha512-yC1smFLOBn7CWNAzaigXAr4bSJSgRJYF4g9jDuSR0NbShLd1SVUpRm9QOmOIrfSFGh2YtZEW8gnwvI5SZw+WmA==} + dependencies: + '@builder.io/partytown': 0.8.2 + mrmime: 1.0.1 + dev: false + /@astrojs/prism@3.0.0: resolution: {integrity: sha512-g61lZupWq1bYbcBnYZqdjndShr/J3l/oFobBKPA3+qMat146zce3nz2kdO4giGbhYDt4gYdhmoBz0vZJ4sIurQ==} engines: {node: '>=18.14.1'} @@ -474,6 +484,12 @@ packages: to-fast-properties: 2.0.0 dev: false + /@builder.io/partytown@0.8.2: + resolution: {integrity: sha512-WKGE+SO0qUGirW8J+xOWkHeCkfFEoPPvHnFkcdMl+MY3kDbAcTwjZCzjg27JCvoD0h8fH47FR7DSIss0/S5lyg==} + engines: {node: '>=18.0.0'} + hasBin: true + dev: false + /@catppuccin/tailwindcss@0.1.6(tailwindcss@3.4.1): resolution: {integrity: sha512-V+Y0AwZ5SSyvOVAcDl7Ng30xy+m82OKnEJ+9+kcZZ7lRyXuZrAb2GScdq9XR3v+ggt8qiZ/G4TvaC9cJ88AAXA==} peerDependencies: @@ -2813,6 +2829,11 @@ packages: dev: false optional: true + /mrmime@1.0.1: + resolution: {integrity: sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw==} + engines: {node: '>=10'} + dev: false + /ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} dev: false diff --git a/src/components/GoogleAnalytics.astro b/src/components/GoogleAnalytics.astro new file mode 100644 index 0000000..5cac619 --- /dev/null +++ b/src/components/GoogleAnalytics.astro @@ -0,0 +1,23 @@ +--- +type Props = { measurementId: string } +const props = Astro.props as Props +const measurementId = props.measurementId +--- + + diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 3164469..b0102b1 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -1,5 +1,7 @@ --- import { SITE } from "../config"; +import GoogleAnalytics from "../components/GoogleAnalytics.astro"; + export interface Props { title?: string; author?: string; @@ -16,6 +18,7 @@ const { +