diff --git a/.env.development.example b/.env.development.example
index 3b6e114..906b7f1 100644
--- a/.env.development.example
+++ b/.env.development.example
@@ -5,3 +5,6 @@ SITE_URL=http://localhost:3000
# always true in development, set only on prod build
# PREVIEW_MODE=
+
+# plausible analytics url
+PLAUSIBLE_SCRIPT_URL=
diff --git a/.env.production.example b/.env.production.example
index 4c4e253..b83fc74 100644
--- a/.env.production.example
+++ b/.env.production.example
@@ -7,3 +7,6 @@ SITE_URL=https://nemanjam.github.io
# see draft posts and projects, true | false | empty
# optional, default false, set only on prod build
PREVIEW_MODE=
+
+# plausible analytics url
+PLAUSIBLE_SCRIPT_URL=
diff --git a/.github/workflows/bash__deploy-nginx.yml b/.github/workflows/bash__deploy-nginx.yml
index cc29b03..e79b2da 100644
--- a/.github/workflows/bash__deploy-nginx.yml
+++ b/.github/workflows/bash__deploy-nginx.yml
@@ -13,6 +13,7 @@ on:
env:
SITE_URL: 'https://nemanjamitic.com'
+ PLAUSIBLE_SCRIPT_URL: 'https://plausible.arm1.nemanjamitic.com/js/script.js'
SSH_ALIAS: arm1
jobs:
diff --git a/.github/workflows/default__build-push-docker.yml b/.github/workflows/default__build-push-docker.yml
index 20a46ce..7e63800 100644
--- a/.github/workflows/default__build-push-docker.yml
+++ b/.github/workflows/default__build-push-docker.yml
@@ -14,6 +14,7 @@ on:
env:
IMAGE_NAME: ${{ github.event.repository.name }}
SITE_URL: 'https://nmc-docker.arm1.nemanjamitic.com'
+ PLAUSIBLE_SCRIPT_URL: 'https://plausible.arm1.nemanjamitic.com/js/script.js'
jobs:
build:
diff --git a/.github/workflows/default__deploy-nginx.yml b/.github/workflows/default__deploy-nginx.yml
index cc4b392..4bafb14 100644
--- a/.github/workflows/default__deploy-nginx.yml
+++ b/.github/workflows/default__deploy-nginx.yml
@@ -13,6 +13,7 @@ on:
env:
SITE_URL: 'https://nemanjamitic.com'
+ PLAUSIBLE_SCRIPT_URL: 'https://plausible.arm1.nemanjamitic.com/js/script.js'
jobs:
deploy:
diff --git a/.github/workflows/gh-pages__deploy-astro.yml b/.github/workflows/gh-pages__deploy-astro.yml
index f01681c..a3c3659 100644
--- a/.github/workflows/gh-pages__deploy-astro.yml
+++ b/.github/workflows/gh-pages__deploy-astro.yml
@@ -23,6 +23,7 @@ permissions:
# set env vars in Github settings here
env:
SITE_URL: 'https://nemanjam.github.io'
+ PLAUSIBLE_SCRIPT_URL: 'https://plausible.arm1.nemanjamitic.com/js/script.js'
jobs:
# build with astro action, unusable for monorepo
diff --git a/.github/workflows/gh-pages__deploy-manual.yml b/.github/workflows/gh-pages__deploy-manual.yml
index 542c704..22d399d 100644
--- a/.github/workflows/gh-pages__deploy-manual.yml
+++ b/.github/workflows/gh-pages__deploy-manual.yml
@@ -20,6 +20,7 @@ permissions:
# set env vars in Github settings here
env:
SITE_URL: 'https://nemanjam.github.io'
+ PLAUSIBLE_SCRIPT_URL: 'https://plausible.arm1.nemanjamitic.com/js/script.js'
jobs:
build-manual:
diff --git a/astro.config.ts b/astro.config.ts
index 184e89a..fa5c0db 100644
--- a/astro.config.ts
+++ b/astro.config.ts
@@ -1,4 +1,5 @@
import mdx from '@astrojs/mdx';
+import partytown from '@astrojs/partytown';
import react from '@astrojs/react';
import tailwind from '@astrojs/tailwind';
import icon from 'astro-icon';
@@ -32,6 +33,9 @@ export default defineConfig({
// applyBaseStyles: false prevents double loading of tailwind
tailwind({ applyBaseStyles: false }),
icon({ iconDir: 'src/assets/icons' }),
+ partytown({
+ config: { forward: ['dataLayer.push'] },
+ }),
],
markdown: { remarkPlugins },
vite: {
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 5db86fc..5469cb9 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -25,6 +25,10 @@ ARG ARG_SITE_URL
ENV SITE_URL=$ARG_SITE_URL
RUN echo "SITE_URL=$SITE_URL"
+ARG ARG_PLAUSIBLE_SCRIPT_URL
+ENV PLAUSIBLE_SCRIPT_URL=$ARG_PLAUSIBLE_SCRIPT_URL
+RUN echo "PLAUSIBLE_SCRIPT_URL=$PLAUSIBLE_SCRIPT_URL"
+
RUN yarn build
FROM nginx:stable-alpine3.17-slim AS runtime
diff --git a/docs/working-notes/todo3.md b/docs/working-notes/todo3.md
index 620b630..7169c21 100644
--- a/docs/working-notes/todo3.md
+++ b/docs/working-notes/todo3.md
@@ -525,5 +525,10 @@ fix image sizes for gallery and other
-----
gallery scroll pagination, blur loading
odvojen ARG_SITE_URL za x86 i arm
+folder name for slug and index.mdx and images
+
+// plausible
+
+add zod schema that checks node_env for plausible_url instead of optional
------------
```
diff --git a/package.json b/package.json
index 23846a2..ab402e7 100644
--- a/package.json
+++ b/package.json
@@ -7,8 +7,8 @@
"start": "serve ./dist",
"preview": "astro preview",
"build": "astro build",
- "build:nginx": "SITE_URL='https://nemanjamitic.com' astro build",
- "build:nginx:local": "SITE_URL='https://blog.local.nemanjamitic.com' astro build",
+ "build:nginx": "SITE_URL='https://nemanjamitic.com' PLAUSIBLE_SCRIPT_URL: 'https://plausible.arm1.nemanjamitic.com/js/script.js' astro build",
+ "build:nginx:local": "SITE_URL='https://blog.local.nemanjamitic.com' PLAUSIBLE_SCRIPT_URL: 'https://plausible.arm1.nemanjamitic.com/js/script.js' astro build",
"astro": "astro",
"sync": "astro sync",
"lint": "eslint --ext .astro,.tsx,.ts,.js,.mdx src",
@@ -19,12 +19,13 @@
"deploy:nginx:local": "bash scripts/deploy-nginx.sh '~/traefik-proxy/apps/nmc-nginx-with-volume/website' lxc11",
"deploy:docker": "bash scripts/deploy-docker.sh arm1 '~/traefik-proxy/apps/nmc-docker' nemanjamitic/nemanjam.github.io",
"deploy:docker:local": "bash scripts/deploy-docker.sh lxc11 '~/traefik-proxy/apps/nmc-docker' nemanjamitic/nemanjam.github.io",
- "docker:build:push:arm": "docker buildx build -f ./docker/Dockerfile -t nemanjamitic/nemanjam.github.io --build-arg ARG_SITE_URL='https://nmc-docker.arm1.nemanjamitic.com' --platform linux/arm64 --push .",
- "docker:build:push:x86": "docker buildx build -f ./docker/Dockerfile -t nemanjamitic/nemanjam.github.io --build-arg ARG_SITE_URL='https://nmc-docker.local.nemanjamitic.com' --platform linux/amd64 --push .",
+ "docker:build:push:arm": "docker buildx build -f ./docker/Dockerfile -t nemanjamitic/nemanjam.github.io --build-arg ARG_SITE_URL='https://nmc-docker.arm1.nemanjamitic.com' ARG_PLAUSIBLE_SCRIPT_URL='https://plausible.arm1.nemanjamitic.com/js/script.js' --platform linux/arm64 --push .",
+ "docker:build:push:x86": "docker buildx build -f ./docker/Dockerfile -t nemanjamitic/nemanjam.github.io --build-arg ARG_SITE_URL='https://nmc-docker.local.nemanjamitic.com' ARG_PLAUSIBLE_SCRIPT_URL='https://plausible.arm1.nemanjamitic.com/js/script.js' --platform linux/amd64 --push .",
"docker:push": "docker push nemanjamitic/nemanjam.github.io"
},
"dependencies": {
"@astrojs/mdx": "^3.1.3",
+ "@astrojs/partytown": "^2.1.2",
"@astrojs/react": "^3.6.1",
"@astrojs/sitemap": "^3.1.6",
"@astrojs/tailwind": "^5.1.0",
diff --git a/src/components/BaseHead.astro b/src/components/BaseHead.astro
index 1e41fa0..aeb0e9b 100644
--- a/src/components/BaseHead.astro
+++ b/src/components/BaseHead.astro
@@ -13,7 +13,7 @@ import { filterUndefined } from '@/utils/objects';
import type { Metadata } from '@/types/common';
-const { AUTHOR_NAME } = CONFIG_CLIENT;
+const { AUTHOR_NAME, PLAUSIBLE_SCRIPT_URL } = CONFIG_CLIENT;
export interface BaseHeadProps {
metadata: Metadata;
@@ -25,7 +25,7 @@ const { metadata } = Astro.props as BaseHeadProps;
// site: SITE_URL var + '/'
// url: full page url, cannonical url, per page
const { url } = Astro; // objects
-const { host } = url;
+const { host } = url; // host - nemanjamitic.com
const handledMetadata = handleTitle(metadata);
@@ -103,12 +103,16 @@ const ogImageUrl = new URL(image, url);
{/* Analytics */}
-
-
+ {
+ PLAUSIBLE_SCRIPT_URL && (
+ <>
+
+
+ >
+ )
+ }
+
+ {/* Theme */}
{/* MUST be inside