-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathgatsby-ssr.js
36 lines (34 loc) · 923 Bytes
/
gatsby-ssr.js
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
import React from "react";
export const onRenderBody = ({ setHeadComponents, setPostBodyComponents }) => {
const pluginOptions = {
googleAdClientId: `ca-pub-5964640183793435`,
head: true,
};
if (process.env.NODE_ENV !== `production`) {
return null;
}
if (pluginOptions.googleAdClientId === undefined) {
return null;
}
const setComponents = pluginOptions.head
? setHeadComponents
: setPostBodyComponents;
return setComponents([
<script
async
type="text/javascript"
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"
/>,
<script
key={`gatsby-plugin-google-adsense`}
dangerouslySetInnerHTML={{
__html: `
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "${pluginOptions.googleAdClientId}",
enable_page_level_ads: true
});
`,
}}
/>,
]);
};