2022-11-17 19:29:27 +01:00
|
|
|
import React from 'react'
|
2022-11-11 03:31:54 +01:00
|
|
|
import { GatsbySSR } from 'gatsby'
|
2022-11-17 19:29:27 +01:00
|
|
|
import { UMAMI_SCRIPT_URL, UMAMI_WEBSITE_ID } from './src/helpers/umami'
|
2023-01-29 22:58:19 +01:00
|
|
|
import wrapPageElementWithLayout from './src/helpers/wrapPageElement'
|
2022-11-11 03:31:54 +01:00
|
|
|
|
|
|
|
export const wrapPageElement: GatsbySSR['wrapPageElement'] =
|
|
|
|
wrapPageElementWithLayout
|
2022-11-17 19:29:27 +01:00
|
|
|
|
2022-11-19 17:31:07 +01:00
|
|
|
export const onRenderBody = ({ setPostBodyComponents, setHtmlAttributes }) => {
|
2022-11-19 22:01:53 +01:00
|
|
|
setHtmlAttributes({ lang: 'en' })
|
|
|
|
|
2022-11-17 19:29:27 +01:00
|
|
|
const isEnabled = process.env.NODE_ENV === 'production'
|
|
|
|
|
|
|
|
if (!isEnabled) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
2022-11-19 17:31:07 +01:00
|
|
|
const umamiOptions = {
|
2022-11-17 19:29:27 +01:00
|
|
|
src: UMAMI_SCRIPT_URL,
|
|
|
|
'data-website-id': UMAMI_WEBSITE_ID
|
|
|
|
}
|
|
|
|
|
2022-11-19 17:31:07 +01:00
|
|
|
setPostBodyComponents([
|
|
|
|
<script key="umami-script" async defer {...umamiOptions} />
|
2022-11-17 19:29:27 +01:00
|
|
|
])
|
|
|
|
}
|