forked from me4502/gatsby-plugin-react-helmet-async
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-ssr.js
32 lines (32 loc) · 1.32 KB
/
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
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapRootElement = exports.onRenderBody = void 0;
var react_1 = __importDefault(require("react"));
var react_helmet_async_1 = require("react-helmet-async");
var context = {};
var onRenderBody = function (_a) {
var setHeadComponents = _a.setHeadComponents, setHtmlAttributes = _a.setHtmlAttributes, setBodyAttributes = _a.setBodyAttributes;
var helmet = context.helmet;
if (helmet != null) {
setHeadComponents([
helmet.base.toComponent(),
helmet.title.toComponent(),
helmet.meta.toComponent(),
helmet.link.toComponent(),
helmet.style.toComponent(),
helmet.script.toComponent(),
helmet.noscript.toComponent(),
]);
setHtmlAttributes(helmet.htmlAttributes.toComponent());
setBodyAttributes(helmet.bodyAttributes.toComponent());
}
};
exports.onRenderBody = onRenderBody;
var wrapRootElement = function (_a) {
var element = _a.element;
return (react_1.default.createElement(react_helmet_async_1.HelmetProvider, { context: context }, element));
};
exports.wrapRootElement = wrapRootElement;