diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..1075eb9 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +POSTHOG_API_KEY=fill_in_key_for_metrics diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b09fff2..1bcb55a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,9 +1,11 @@ name: Deploy to GitHub Pages on: - # Runs on pushes targeting the default branch + # Runs on pushes and PRs targeting the default branch push: branches: ["main"] + pull_request: + branches: ["main"] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -22,7 +24,7 @@ concurrency: env: BUILD_PATH: "." # default value when not using subfolders - # BUILD_PATH: subfolder + POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} jobs: build: @@ -74,6 +76,8 @@ jobs: path: ${{ env.BUILD_PATH }}/dist deploy: + # Only deploy from the main branch, or when manually triggered + if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} diff --git a/astro.config.mjs b/astro.config.mjs index de63eff..f1abb3f 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -5,7 +5,7 @@ export default defineConfig({ site: "https://www.sfcivictech.org", base: "", trailingSlash: "ignore", - compressHTML: false, + compressHTML: true, integrations: [ icon({ iconDir: "src/assets/icons", diff --git a/src/components/Metadata.astro b/src/components/Metadata.astro index 401f2b2..873fd18 100644 --- a/src/components/Metadata.astro +++ b/src/components/Metadata.astro @@ -16,7 +16,7 @@ const { meta: { const tags = Object.entries(meta) .map(([key, value]) => metaTag(key, value)) - .join("\n"); + .join("\n\t\t"); const ogTags = Object.entries({ title, url, @@ -28,9 +28,9 @@ const ogTags = Object.entries({ }) .map(([key, value]) => value ? ogMetaTag(key, value) : null) .filter(Boolean) - .join("\n"); + .join("\n\t\t"); --- - - + + diff --git a/src/components/MetricsSnippet.astro b/src/components/MetricsSnippet.astro new file mode 100644 index 0000000..b183fbd --- /dev/null +++ b/src/components/MetricsSnippet.astro @@ -0,0 +1,8 @@ +--- +const phKey = import.meta.env.POSTHOG_API_KEY; +--- + + diff --git a/src/layouts/Page.astro b/src/layouts/Page.astro index 9dd54e0..f280c75 100644 --- a/src/layouts/Page.astro +++ b/src/layouts/Page.astro @@ -2,6 +2,7 @@ import { base } from "@/utils/urls"; import Metadata from "@/components/Metadata.astro"; import type { MetadataProp } from "@/components/Metadata.astro"; +import MetricsSnippet from "@/components/MetricsSnippet.astro"; import "@picocss/pico"; import "./global.css"; @@ -40,8 +41,8 @@ const baseURL = import.meta.env.BASE_URL.replace(/([^/])$/, "$1/"); title="SF Civic Tech" href={new URL("rss.xml", Astro.site)} /> - + {pageTitle}