1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-30 21:52:05 +02:00
blog/gatsby-ssr.tsx

25 lines
647 B
TypeScript
Raw Normal View History

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