mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-25 03:14:01 +01:00
27 lines
706 B
TypeScript
27 lines
706 B
TypeScript
import React from 'react'
|
|
import { GatsbySSR } from 'gatsby'
|
|
import wrapPageElementWithLayout from './src/helpers/wrapPageElement'
|
|
import { UMAMI_SCRIPT_URL, UMAMI_WEBSITE_ID } from './src/helpers/umami'
|
|
|
|
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} />
|
|
])
|
|
}
|