@griddo/cx 1.63.5 → 1.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gatsby-node.js +5 -1
- package/gatsby-ssr.js +67 -11
- package/package.json +4 -3
- package/src/utils/pages.js +2 -0
package/gatsby-node.js
CHANGED
|
@@ -95,7 +95,9 @@ exports.createPages = async ({ actions }) => {
|
|
|
95
95
|
|
|
96
96
|
site.languages = siteLangs;
|
|
97
97
|
|
|
98
|
-
const {
|
|
98
|
+
const {
|
|
99
|
+
cloudinaryName,
|
|
100
|
+
} = SettingsService.settings;
|
|
99
101
|
|
|
100
102
|
NavService.navigations = {
|
|
101
103
|
headers,
|
|
@@ -116,6 +118,7 @@ exports.createPages = async ({ actions }) => {
|
|
|
116
118
|
};
|
|
117
119
|
|
|
118
120
|
const showBasicMetaRobots = process.env.showBasicMetaRobots !== 'off';
|
|
121
|
+
const siteScript = siteInfo.siteScript;
|
|
119
122
|
|
|
120
123
|
let additionalInfo = {
|
|
121
124
|
baseUrl,
|
|
@@ -130,6 +133,7 @@ exports.createPages = async ({ actions }) => {
|
|
|
130
133
|
showBasicMetaRobots,
|
|
131
134
|
BUILD_MODE,
|
|
132
135
|
sitePages,
|
|
136
|
+
siteScript
|
|
133
137
|
};
|
|
134
138
|
|
|
135
139
|
helpers.log('info', 'VALID PAGES -->', validPagesIds);
|
package/gatsby-ssr.js
CHANGED
|
@@ -1,32 +1,88 @@
|
|
|
1
1
|
/* eslint-disable node/no-missing-require */
|
|
2
|
-
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import parse from 'html-react-parser';
|
|
3
4
|
const { ssr } = require('components');
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
let analyticsScript = [];
|
|
7
|
+
let analyticsDimensions = [];
|
|
8
|
+
|
|
9
|
+
export const wrapPageElement = ({ props }) => {
|
|
10
|
+
if (ssr.wrapPageElement) {
|
|
11
|
+
return ssr.wrapPageElement(props);
|
|
12
|
+
}
|
|
13
|
+
const {
|
|
14
|
+
pageContext: {
|
|
15
|
+
siteScript,
|
|
16
|
+
page: {
|
|
17
|
+
dimensions
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
} = props;
|
|
21
|
+
|
|
22
|
+
//Añadir el script. Dependiendo de si lo que recibe es el trackingId o el script
|
|
23
|
+
const src = `https://www.googletagmanager.com/gtag/js?id=${siteScript}`;
|
|
24
|
+
const scriptCode = siteScript.includes('<script') ? [parse(siteScript)] : [<script async key="site-script" dangerouslySetInnerHTML={{__html: siteScript}}/>]
|
|
25
|
+
|
|
26
|
+
analyticsScript=siteScript && siteScript.startsWith('UA-') ?
|
|
27
|
+
[<script async src={src}></script>]
|
|
28
|
+
:
|
|
29
|
+
(siteScript ? scriptCode : []);
|
|
30
|
+
;
|
|
31
|
+
|
|
32
|
+
//Las dimensiones o DataLayer
|
|
33
|
+
const dimensionValues = JSON.stringify(dimensions?.values);
|
|
34
|
+
analyticsDimensions = dimensionValues && (dimensions?.values) !== null ?
|
|
35
|
+
[<script
|
|
36
|
+
async
|
|
37
|
+
key="site-script"
|
|
38
|
+
dangerouslySetInnerHTML={{
|
|
39
|
+
__html: `dataLayer.push(${dimensionValues})`
|
|
40
|
+
}}/>]
|
|
41
|
+
:
|
|
42
|
+
[]
|
|
43
|
+
;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const onRenderBody = props => {
|
|
6
47
|
if (ssr.onRenderBody) {
|
|
7
48
|
ssr.onRenderBody(props);
|
|
8
49
|
}
|
|
50
|
+
const {
|
|
51
|
+
setHeadComponents,
|
|
52
|
+
setPreBodyComponents,
|
|
53
|
+
setPostBodyComponents,
|
|
54
|
+
setHtmlAttributes,
|
|
55
|
+
setBodyAttributes,
|
|
56
|
+
setBodyProps,
|
|
57
|
+
} = props;
|
|
58
|
+
|
|
59
|
+
const additionalHeadComponents = [
|
|
60
|
+
<script>window.dataLayer = window.dataLayer || [];</script>
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
const additionalBodyComponents = [
|
|
64
|
+
...analyticsScript,
|
|
65
|
+
...analyticsDimensions
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
setHeadComponents([...additionalHeadComponents]);
|
|
69
|
+
setPostBodyComponents([...additionalBodyComponents]);
|
|
70
|
+
|
|
9
71
|
};
|
|
10
72
|
|
|
11
|
-
|
|
73
|
+
export const onPreRenderHTML = props => {
|
|
12
74
|
if (ssr.onPreRenderHTML) {
|
|
13
75
|
ssr.onPreRenderHTML(props);
|
|
14
76
|
}
|
|
15
77
|
};
|
|
16
78
|
|
|
17
|
-
|
|
79
|
+
export const replaceRenderer = props => {
|
|
18
80
|
if (ssr.replaceRenderer) {
|
|
19
81
|
ssr.replaceRenderer(props);
|
|
20
82
|
}
|
|
21
83
|
};
|
|
22
84
|
|
|
23
|
-
|
|
24
|
-
if (ssr.wrapPageElement) {
|
|
25
|
-
return ssr.wrapPageElement(props);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
exports.wrapRootElement = props => {
|
|
85
|
+
export const wrapRootElement = props => {
|
|
30
86
|
if (ssr.wrapRootElement) {
|
|
31
87
|
return ssr.wrapRootElement(props);
|
|
32
88
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/cx",
|
|
3
3
|
"description": "Griddo SSG based on Gatsby",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.64.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"gatsby-plugin-remove-generator": "^1.2.0",
|
|
55
55
|
"gatsby-plugin-sass": "^5.8.0",
|
|
56
56
|
"gatsby-plugin-styled-components": "^5.8.0",
|
|
57
|
+
"html-react-parser": "^1.4.10",
|
|
57
58
|
"js2xmlparser": "^4.0.1",
|
|
58
59
|
"node-sass": "^7.0.1",
|
|
59
60
|
"opn": "^6.0.0",
|
|
@@ -63,7 +64,7 @@
|
|
|
63
64
|
"react-helmet": "^6.0.0"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
|
-
"@griddo/eslint-config-back": "^1.
|
|
67
|
+
"@griddo/eslint-config-back": "^1.64.0",
|
|
67
68
|
"eslint": "^7.5.0",
|
|
68
69
|
"eslint-plugin-node": "^11.1.0",
|
|
69
70
|
"eslint-plugin-react": "7.14.3",
|
|
@@ -95,5 +96,5 @@
|
|
|
95
96
|
"publishConfig": {
|
|
96
97
|
"access": "public"
|
|
97
98
|
},
|
|
98
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "b2c93c5e58cd328cdeb86ed13744cec37f591d94"
|
|
99
100
|
}
|
package/src/utils/pages.js
CHANGED
|
@@ -25,6 +25,7 @@ async function renderSinglePage(page, additionalInfo, createPage) {
|
|
|
25
25
|
showBasicMetaRobots,
|
|
26
26
|
BUILD_MODE,
|
|
27
27
|
sitePages,
|
|
28
|
+
siteScript
|
|
28
29
|
} = additionalInfo;
|
|
29
30
|
|
|
30
31
|
// 3 - Build final page object
|
|
@@ -72,6 +73,7 @@ async function renderSinglePage(page, additionalInfo, createPage) {
|
|
|
72
73
|
componentsVersion,
|
|
73
74
|
showBasicMetaRobots,
|
|
74
75
|
sitePages,
|
|
76
|
+
siteScript,
|
|
75
77
|
|
|
76
78
|
// NAVIGATION SECTIONS
|
|
77
79
|
header,
|