mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-22 09:56:51 +01:00
27 lines
706 B
TypeScript
27 lines
706 B
TypeScript
import React from 'react'
|
|
import { GatsbySSR } from 'gatsby'
|
|
import { UMAMI_SCRIPT_URL, UMAMI_WEBSITE_ID } from './src/helpers/umami'
|
|
import wrapPageElementWithLayout from './src/helpers/wrapPageElement'
|
|
|
|
export const wrapPageElement: GatsbySSR['wrapPageElement'] =
|
|
wrapPageElementWithLayout
|
|
|
|
export const onRenderBody = ({ setPostBodyComponents, setHtmlAttributes }) => {
|
|
setHtmlAttributes({ lang: 'en' })
|
|
|
|
const isEnabled = process.env.NODE_ENV === 'production'
|
|
|
|
if (!isEnabled) {
|
|
return null
|
|
}
|
|
|
|
const umamiOptions = {
|
|
src: UMAMI_SCRIPT_URL,
|
|
'data-website-id': UMAMI_WEBSITE_ID
|
|
}
|
|
|
|
setPostBodyComponents([
|
|
<script key="umami-script" async defer {...umamiOptions} />
|
|
])
|
|
}
|