diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 938fe7f..2ebafe5 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -39,6 +39,9 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
+ build-args: |
+ PLAUSIBLE_CUSTOM_DOMAIN=${{ secrets.PLAUSIBLE_CUSTOM_DOMAIN }}
+ VERSION=v${{ steps.get_version.outputs.VERSION }}
tags: |
${{ secrets.REGISTRY_NAME }}/dwysokinski.me:latest
${{ secrets.REGISTRY_NAME }}/dwysokinski.me:${{ steps.get_version.outputs.VERSION }}
diff --git a/Dockerfile b/Dockerfile
index e31b42c..8ce5de6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,9 @@
FROM node:14.18.1-alpine as build-deps
-ENV NODE_ENV=production
+ARG PLAUSIBLE_CUSTOM_DOMAIN=""
+
+ENV PLAUSIBLE_CUSTOM_DOMAIN=$PLAUSIBLE_CUSTOM_DOMAIN \
+ NODE_ENV=production
RUN apk --no-cache add shadow \
gcc \
diff --git a/gatsby-browser.js b/gatsby-browser.js
index 01e21b7..7f9387a 100644
--- a/gatsby-browser.js
+++ b/gatsby-browser.js
@@ -1 +1,12 @@
import '@kichiyaki/roboto';
+
+export const onRouteUpdate = ({ location }) => {
+ if (
+ process.env.NODE_ENV !== `production` ||
+ typeof window.plausible !== `object`
+ ) {
+ return;
+ }
+
+ window.plausible('pageview');
+};
diff --git a/gatsby-config.js b/gatsby-config.js
index fdb39c0..a2a5e20 100644
--- a/gatsby-config.js
+++ b/gatsby-config.js
@@ -1,4 +1,5 @@
-const siteUrl = 'https://dwysokinski.me';
+const DOMAIN = process.env.DOMAIN;
+const SITE_URL = 'https://' + DOMAIN;
module.exports = {
siteMetadata: {
@@ -6,10 +7,12 @@ module.exports = {
description: `Dawid Wysokiński - Full Stack Web Developer | Back End Developer | Front End Developer | Golang Developer | React Developer | JavaScript Developer`,
authorTwitter: `@Dawid56143781`,
authorFullName: 'Dawid Wysokiński',
- siteUrl,
+ siteUrl: SITE_URL,
email: 'contact@dwysokinski.me',
github: 'https://github.com/Kichiyaki',
facebook: 'https://www.facebook.com/dawidwysokinski00',
+ domain: DOMAIN,
+ plausibleCustomDomain: process.env.PLAUSIBLE_CUSTOM_DOMAIN,
},
plugins: [
`gatsby-plugin-react-helmet`,
@@ -25,7 +28,7 @@ module.exports = {
{
resolve: `gatsby-plugin-manifest`,
options: {
- name: `dwysokinski.me`,
+ name: DOMAIN,
short_name: `dw`,
start_url: `/`,
background_color: `#303030`,
@@ -53,8 +56,8 @@ module.exports = {
{
resolve: 'gatsby-plugin-robots-txt',
options: {
- host: siteUrl,
- sitemap: siteUrl + '/sitemap.xml',
+ host: SITE_URL,
+ sitemap: SITE_URL + '/sitemap.xml',
env: {
development: {
policy: [{ userAgent: '*', disallow: ['/'] }],
diff --git a/gatsby-node.js b/gatsby-node.js
deleted file mode 100644
index 2f42665..0000000
--- a/gatsby-node.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * Implement Gatsby's Node APIs in this file.
- *
- * See: https://www.gatsbyjs.org/docs/node-apis/
- */
-
-// You can delete this file if you're not using it
diff --git a/gatsby-ssr.js b/gatsby-ssr.js
index b17b8fc..31df84e 100644
--- a/gatsby-ssr.js
+++ b/gatsby-ssr.js
@@ -1,7 +1,34 @@
-/**
- * Implement Gatsby's SSR (Server Side Rendering) APIs in this file.
- *
- * See: https://www.gatsbyjs.org/docs/ssr-apis/
- */
+import React from 'react';
-// You can delete this file if you're not using it
+export const onRenderBody = ({ setHeadComponents, ...rest }) => {
+ if (process.env.NODE_ENV !== 'production') {
+ return null;
+ }
+
+ const plausibleDomain = process.env.PLAUSIBLE_CUSTOM_DOMAIN ?? 'plausible.io';
+ const domain = process.env.DOMAIN ?? 'localhost';
+
+ const scriptProps = {
+ async: true,
+ defer: true,
+ 'data-domain': domain,
+ src: `https://${plausibleDomain}/js/plausible.js`,
+ };
+
+ return setHeadComponents([
+ // ,
+ ,
+ ,
+ ]);
+};
diff --git a/src/components/Seo.js b/src/components/Seo.js
index 5bfcbf5..092996f 100644
--- a/src/components/Seo.js
+++ b/src/components/Seo.js
@@ -103,7 +103,7 @@ function Seo({ description, lang, meta, title, pathname }) {
+ />
);
}