@griddo/cx 1.75.258 → 10.1.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/build/index.js CHANGED
@@ -25,7 +25,7 @@ GFS4: `),console.error(e)});z[Z]||(ws=global[Z]||[],xs(z,ws),z.close=function(e)
25
25
  \u2502 Access credentials failure \u2502
26
26
  \u2502 Check that the login details are correct in your .env file \u2502
27
27
  \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F
28
- `)),process.exit(1)}}},Ar=new Kn;var el=K(Yn()),tl=K(gt()),rl=K(Gt());var yp=K(gt()),Vu=K(Gt()),gp=K(gn()),Yu=K(Wu());var Ju="1.75.258";Vu.default.config();var vp=!!process.env.GRIDDO_BUILD_LOGS&&!!JSON.parse(process.env.GRIDDO_BUILD_LOGS)||!!process.env.LOGS&&!!JSON.parse(process.env.LOGS);function Ku(e){let t=e.length,r=e.length+2,n=" ".repeat(Math.floor((r-t)/2)),i=`\u256D${"\u2500".repeat(r)}\u256E
28
+ `)),process.exit(1)}}},Ar=new Kn;var el=K(Yn()),tl=K(gt()),rl=K(Gt());var yp=K(gt()),Vu=K(Gt()),gp=K(gn()),Yu=K(Wu());var Ju="10.1.0";Vu.default.config();var vp=!!process.env.GRIDDO_BUILD_LOGS&&!!JSON.parse(process.env.GRIDDO_BUILD_LOGS)||!!process.env.LOGS&&!!JSON.parse(process.env.LOGS);function Ku(e){let t=e.length,r=e.length+2,n=" ".repeat(Math.floor((r-t)/2)),i=`\u256D${"\u2500".repeat(r)}\u256E
29
29
  `,s=`
30
30
  \u2570${"\u2500".repeat(r)}\u256F`,o=`\u2502${n}${e}${n}\u2502`;console.log(`${i}${o}${s}`)}function fi(e){vp&&console.info(e.replace(/(\s)\s+/g,"$1"))}function Xu(e){return new Promise(t=>setTimeout(t,e))}function Dr(e,t=3){return(e/1e3).toFixed(t)}function hi(e){return"site"in e&&e.site?e?.site:void 0}function di(...e){let t=performance.now();return e.forEach(r=>r()),Dr(performance.now()-t)}function Qu(){let e=`
31
31
  \xB7\xB7
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.75.258",
4
+ "version": "10.1.0",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -68,7 +68,7 @@
68
68
  "react-helmet": "^6.0.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@griddo/eslint-config-back": "^1.75.258",
71
+ "@griddo/eslint-config-back": "^10.1.0",
72
72
  "@types/babel__core": "^7.20.0",
73
73
  "@types/babel__preset-env": "^7.9.2",
74
74
  "@types/csvtojson": "^2.0.0",
@@ -116,5 +116,5 @@
116
116
  "publishConfig": {
117
117
  "access": "public"
118
118
  },
119
- "gitHead": "e9fae470aa191231028673382f67dee530baa6a8"
119
+ "gitHead": "9c3c0cf154929716b3f9782fb4d7b3b88d2988a2"
120
120
  }
@@ -6,6 +6,7 @@ import parse from "html-react-parser";
6
6
  import * as React from "react";
7
7
 
8
8
  import { cleanCommaSeparated, composeAnalytics, formatImage } from "./utils";
9
+ import { filterHeadIntegrations } from "../utils/integrations";
9
10
 
10
11
  /**
11
12
  * Gatsby Head API
@@ -18,7 +19,7 @@ const Head = (props: CustomHeadProps) => {
18
19
  renderDate,
19
20
  locale,
20
21
  openGraph,
21
- page: { disableHrefLangs, fullUrl, defaultLang },
22
+ page: { disableHrefLangs, fullUrl, defaultLang, integrations = [] },
22
23
  pageMetadata,
23
24
  siteMetadata,
24
25
  siteOptions,
@@ -105,6 +106,8 @@ const Head = (props: CustomHeadProps) => {
105
106
  ?.url) ||
106
107
  null;
107
108
 
109
+ const headIntegrations = filterHeadIntegrations(integrations);
110
+
108
111
  return (
109
112
  <>
110
113
  {/* Uncomment with Gatsby 5.5.0 */}
@@ -197,6 +200,9 @@ const Head = (props: CustomHeadProps) => {
197
200
  {analyticsScriptCode}
198
201
  </script>
199
202
  )}
203
+
204
+ {headIntegrations &&
205
+ headIntegrations.map((integrationBody) => parse(integrationBody))}
200
206
  </>
201
207
  );
202
208
  };
@@ -5,9 +5,12 @@ import { Page as RenderGriddoPage } from "@griddo/core";
5
5
  // @ts-expect-error components is unknown
6
6
  import { components, SiteProvider, templates } from "components";
7
7
  import { Link, navigate } from "gatsby";
8
+ import parse from "html-react-parser";
8
9
  import * as React from "react";
9
10
  import { Helmet } from "react-helmet";
10
11
 
12
+ import { filterPositionIntegrations } from "../utils/integrations";
13
+
11
14
  // Gatsby Head
12
15
  export { Head } from "./Head";
13
16
 
@@ -35,6 +38,15 @@ const Template = (data: TemplateProps) => {
35
38
  const header = data.pageContext.header as Core.HeaderModule;
36
39
  const footer = data.pageContext.footer as Core.FooterModule;
37
40
 
41
+ const integrationsPreBody = filterPositionIntegrations(
42
+ page.integrations || [],
43
+ "start"
44
+ );
45
+ const integrationsPostBody = filterPositionIntegrations(
46
+ page.integrations || [],
47
+ "end"
48
+ );
49
+
38
50
  return (
39
51
  <SiteProvider
40
52
  apiUrl={page.apiUrl}
@@ -62,6 +74,10 @@ const Template = (data: TemplateProps) => {
62
74
  </Helmet>
63
75
 
64
76
  {/* Render every page */}
77
+ {integrationsPreBody &&
78
+ integrationsPreBody.map((integrationBody) =>
79
+ parse(integrationBody, { trim: true })
80
+ )}
65
81
  <RenderGriddoPage
66
82
  apiUrl={page.apiUrl}
67
83
  content={page}
@@ -71,6 +87,10 @@ const Template = (data: TemplateProps) => {
71
87
  library={library}
72
88
  pageLanguages={page.pageLanguages}
73
89
  />
90
+ {integrationsPostBody &&
91
+ integrationsPostBody.map((integrationBody) =>
92
+ parse(integrationBody, { trim: true })
93
+ )}
74
94
  </SiteProvider>
75
95
  );
76
96
  };
@@ -0,0 +1,37 @@
1
+ import type { Core } from "@griddo/core";
2
+
3
+ import { get } from "../utils/api";
4
+
5
+ /**
6
+ * Integrations Service
7
+ */
8
+ class IntegrationsService {
9
+ private baseURL?: string;
10
+ private ENDPOINTS: { pageIntegrations: string[] };
11
+
12
+ constructor() {
13
+ this.baseURL = process.env.API_URL;
14
+ this.ENDPOINTS = {
15
+ pageIntegrations: [`${this.baseURL}/page/`, `/integrations`],
16
+ };
17
+ }
18
+
19
+ /**
20
+ * Get settings for a full domain render.
21
+ */
22
+ async getPageIntegrations(pageId: number) {
23
+ const {
24
+ pageIntegrations: [prefix, suffix],
25
+ } = this.ENDPOINTS;
26
+
27
+ const response = await get<Core.PageIntegration[]>({
28
+ endpoint: `${prefix}${pageId}${suffix}`,
29
+ });
30
+
31
+ return response;
32
+ }
33
+ }
34
+
35
+ const integrationsService = new IntegrationsService();
36
+
37
+ export { integrationsService as IntegrationsService };
@@ -17,6 +17,7 @@ import fsx from "fs-extra";
17
17
  import pLimit from "p-limit";
18
18
 
19
19
  import { DistributorService } from "./distributors";
20
+ import { IntegrationsService } from "./integrations";
20
21
  import { NavigationService } from "./navigation";
21
22
  import { RobotsService } from "./robots";
22
23
  import { SettingsService } from "./settings";
@@ -241,6 +242,10 @@ class StoreService {
241
242
  cacheKey: RENDER_ID,
242
243
  });
243
244
 
245
+ page.integrations = await IntegrationsService.getPageIntegrations(
246
+ pageId
247
+ );
248
+
244
249
  // MultiPage Query
245
250
  // Where the pair `hasGriddoMultiPage:true` prop exists, this function
246
251
  // will process the schema and return a multiPageElemtens array to use
@@ -0,0 +1,34 @@
1
+ import { PageIntegration } from "@griddo/core/dist/types/core";
2
+
3
+ export const filterBodyIntegrationFromPosition = (
4
+ integrations: PageIntegration[],
5
+ position: "start" | "end"
6
+ ) =>
7
+ integrations
8
+ ?.filter(
9
+ (integration) =>
10
+ integration.contentBody !== null &&
11
+ integration.contentBody !== "" &&
12
+ integration.contentBodyPosition === position
13
+ )
14
+ .map((integration) => integration.contentBody!) || [];
15
+
16
+ export const filterHeadIntegrations = (integrations: PageIntegration[]) =>
17
+ integrations
18
+ ?.filter(
19
+ (integration) =>
20
+ integration.contentHead !== null && integration.contentHead !== ""
21
+ )
22
+ .map((integration) => integration.contentHead!) || [];
23
+
24
+ export const filterPositionIntegrations = (
25
+ integrations: PageIntegration[],
26
+ position: "head" | "start" | "end"
27
+ ) => {
28
+ switch (position) {
29
+ case "head":
30
+ return filterHeadIntegrations(integrations);
31
+ default:
32
+ return filterBodyIntegrationFromPosition(integrations, position);
33
+ }
34
+ };