1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 | exports.__esModule = true;
|
5 | exports.onRenderBody = void 0;
|
6 | var _react = _interopRequireDefault(require("react"));
|
7 | var _gatsbyScript = require("gatsby-script");
|
8 | var _getForwards = require("./utils/get-forwards");
|
9 | var _integration = require("@builder.io/partytown/integration");
|
10 | const onRenderBody = ({
|
11 | pathname,
|
12 | setHeadComponents
|
13 | }) => {
|
14 | const collectedScripts = _gatsbyScript.collectedScriptsByPage.get(pathname);
|
15 | if (!(collectedScripts !== null && collectedScripts !== void 0 && collectedScripts.length)) {
|
16 | return;
|
17 | }
|
18 | const forwards = (0, _getForwards.getForwards)(collectedScripts);
|
19 |
|
20 |
|
21 | setHeadComponents([_react.default.createElement("script", {
|
22 | key: "partytown",
|
23 | "data-partytown": "",
|
24 | suppressHydrationWarning: true,
|
25 | dangerouslySetInnerHTML: {
|
26 | __html: `
|
27 | ${(0, _integration.partytownSnippet)({
|
28 | forward: forwards
|
29 | })}
|
30 | document.currentScript.dataset.partytown=""
|
31 | `
|
32 | }
|
33 | })]);
|
34 |
|
35 |
|
36 | _gatsbyScript.collectedScriptsByPage.delete(pathname);
|
37 | };
|
38 | exports.onRenderBody = onRenderBody;
|
39 |
|
\ | No newline at end of file |