-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathgatsby-ssr.js
More file actions
57 lines (52 loc) · 1.84 KB
/
gatsby-ssr.js
File metadata and controls
57 lines (52 loc) · 1.84 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const React = require('react');
const SITE_DOMAIN = 'novu.co';
const PLAUSIBLE_DOMAIN = 'plausible.io';
const SCRIPT_URI = '/js/script.js';
exports.onRenderBody = ({ setHeadComponents, setHtmlAttributes }) => {
const headComponents = [
<script
key="plain-live-chat"
dangerouslySetInnerHTML={{
__html: `
(function(d, script) {
script = d.createElement('script');
script.async = false;
script.onload = function(){
Plain.init({
appId: 'liveChatApp_01KJAVQQ5YRKY7NNZDEZV6KHED',
hideBranding: true,
threadDetails: {
tierIdentifier: { externalId: "marketing_page" },
},
});
};
script.src = 'https://chat.cdn-plain.com/index.js';
d.getElementsByTagName('head')[0].appendChild(script);
}(document));
`,
}}
/>,
];
if (process.env.NODE_ENV === 'production') {
const scriptProps = {
'data-domain': SITE_DOMAIN,
src: `https://${PLAUSIBLE_DOMAIN}${SCRIPT_URI}`,
};
headComponents.push(
// 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) };
`,
}}
/>
);
}
setHeadComponents(headComponents);
setHtmlAttributes({ lang: 'en', prefix: 'og: http://ogp.me/ns#' });
};