add @kichiyaki/gatsby-plugin-plausible

This commit is contained in:
Dawid Wysokiński 2021-11-11 08:36:12 +01:00
parent 53faf59222
commit 0c0acf56fe
Signed by: Kichiyaki
GPG Key ID: EF14026D247EB867
6 changed files with 20 additions and 49 deletions

View File

@ -41,7 +41,7 @@ jobs:
context: .
build-args: |
PLAUSIBLE_CUSTOM_DOMAIN=${{ secrets.PLAUSIBLE_CUSTOM_DOMAIN }}
VERSION=v${{ steps.get_version.outputs.VERSION }}
VERSION=${{ steps.get_version.outputs.VERSION }}
tags: |
${{ secrets.REGISTRY_NAME }}/dwysokinski.me:latest
${{ secrets.REGISTRY_NAME }}/dwysokinski.me:${{ steps.get_version.outputs.VERSION }}

View File

@ -1,12 +1 @@
import '@kichiyaki/roboto';
export const onRouteUpdate = ({ location }) => {
if (
process.env.NODE_ENV !== `production` ||
typeof window.plausible !== `object`
) {
return;
}
window.plausible('pageview');
};

View File

@ -1,4 +1,4 @@
const DOMAIN = process.env.DOMAIN;
const DOMAIN = 'dwysokinski.me';
const SITE_URL = 'https://' + DOMAIN;
module.exports = {
@ -12,7 +12,6 @@ module.exports = {
github: 'https://github.com/Kichiyaki',
facebook: 'https://www.facebook.com/dawidwysokinski00',
domain: DOMAIN,
plausibleCustomDomain: process.env.PLAUSIBLE_CUSTOM_DOMAIN,
},
plugins: [
`gatsby-plugin-react-helmet`,
@ -68,5 +67,12 @@ module.exports = {
},
},
},
{
resolve: `@kichiyaki/gatsby-plugin-plausible`,
options: {
domain: DOMAIN,
customDomain: process.env.PLAUSIBLE_CUSTOM_DOMAIN,
},
},
],
};

View File

@ -1,34 +0,0 @@
import React from 'react';
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([
// <link
// key="gatsby-plugin-plausible-preconnect"
// rel="preconnect"
// href={`https://${plausibleDomain}`}
// />,
<script key="plausible-script" {...scriptProps} />,
<script
key="plausible-custom-events"
dangerouslySetInnerHTML={{
__html: `
window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) };
`,
}}
/>,
]);
};

View File

@ -5,6 +5,7 @@
"version": "0.1.0",
"author": "Dawid Wysokiński <xyztojajestem@gmail.com>",
"dependencies": {
"@kichiyaki/gatsby-plugin-plausible": "^0.0.8",
"@kichiyaki/roboto": "^1.0.0",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",

View File

@ -1646,6 +1646,15 @@
"@babel/runtime" "^7.7.2"
regenerator-runtime "^0.13.3"
"@kichiyaki/gatsby-plugin-plausible@^0.0.8":
version "0.0.8"
resolved "https://registry.yarnpkg.com/@kichiyaki/gatsby-plugin-plausible/-/gatsby-plugin-plausible-0.0.8.tgz#94f53c5a8f768b934228e4f43c5493c38885152b"
integrity sha512-DO03Z6NHRiwh8XHJtBJcLxMZ1a8cDjYM0inuGmNI33ea7fV4wdGVF5uHidlbdlls2hLfYPDkjOc0y2Yz3Ff/nw==
dependencies:
"@babel/runtime" "^7.9.2"
minimatch "3.0.4"
react "^17.0.2"
"@kichiyaki/roboto@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@kichiyaki/roboto/-/roboto-1.0.0.tgz#6f5dfb40e2423940588946c952490b123ca8088b"
@ -10269,7 +10278,7 @@ react-transition-group@^4.4.0:
loose-envify "^1.4.0"
prop-types "^15.6.2"
react@^17.0.1:
react@^17.0.1, react@^17.0.2:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037"
integrity sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==