-
Notifications
You must be signed in to change notification settings - Fork 40
/
gatsby-ssr.js
31 lines (27 loc) · 1.08 KB
/
gatsby-ssr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const React = require('react');
const SITE_DOMAIN = 'novu.co';
const PLAUSIBLE_DOMAIN = 'plausible.io';
const SCRIPT_URI = '/js/script.js';
exports.onRenderBody = ({ setHeadComponents, setHtmlAttributes }) => {
if (process.env.NODE_ENV === 'production') {
const scriptProps = {
'data-domain': SITE_DOMAIN,
src: `https://${PLAUSIBLE_DOMAIN}${SCRIPT_URI}`,
};
setHeadComponents([
// eslint-disable-next-line react/jsx-filename-extension
<link key="plausible-preconnect" rel="preconnect" href={`https://${PLAUSIBLE_DOMAIN}`} />,
<script key="plausible-script" defer {...scriptProps} />,
// See: https://plausible.io/docs/custom-event-goals#1-trigger-custom-events-with-javascript-on-your-site
<script
key="plausible-custom-events"
dangerouslySetInnerHTML={{
__html: `
window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) };
`,
}}
/>,
]);
}
setHtmlAttributes({ lang: 'en', prefix: 'og: http://ogp.me/ns#' });
};