@griddo/cx 1.75.159 → 1.75.161

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/utils/pages.js +38 -22
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.159",
4
+ "version": "1.75.161",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -66,7 +66,7 @@
66
66
  "react-helmet": "^6.0.0"
67
67
  },
68
68
  "devDependencies": {
69
- "@griddo/eslint-config-back": "^1.75.159",
69
+ "@griddo/eslint-config-back": "^1.75.161",
70
70
  "eslint": "^7.5.0",
71
71
  "eslint-plugin-node": "^11.1.0",
72
72
  "eslint-plugin-react": "7.14.3",
@@ -98,5 +98,5 @@
98
98
  "publishConfig": {
99
99
  "access": "public"
100
100
  },
101
- "gitHead": "6063ff6bcdbd5673c1eba467d6f0898538069ae4"
101
+ "gitHead": "49c079d51e314a57983e5e35e3c634af78283b1f"
102
102
  }
@@ -3,10 +3,19 @@ const fs = require('fs-extra');
3
3
  const { postSearchInfo } = require('./searches');
4
4
  const helpers = require('./helpers.js');
5
5
 
6
+ require('dotenv').config();
7
+
8
+ // Envs
9
+ const GRIDDO_SEARCH_FEATURE = !!JSON.parse(
10
+ process.env.GRIDDO_SEARCH_FEATURE || 'false'
11
+ );
12
+
6
13
  async function renderPage(page, additionalInfo, createPage) {
7
14
  const { multiPageElements, ...cleanPage } = page;
15
+
8
16
  if (!multiPageElements)
9
17
  return await renderSinglePage(cleanPage, additionalInfo, createPage);
18
+
10
19
  await renderMultiplePages(page, additionalInfo, createPage);
11
20
  }
12
21
 
@@ -98,29 +107,32 @@ async function renderSinglePage(page, additionalInfo, createPage) {
98
107
 
99
108
  await createPage(mappedPage);
100
109
 
101
- const exportFile = path.resolve(
102
- __dirname,
103
- '../../dist/',
104
- `./${filepath}index.html`
105
- );
106
-
107
- const content = fs.existsSync(exportFile)
108
- ? fs.readFileSync(exportFile).toString()
109
- : '';
110
-
111
- await postSearchInfo({
112
- title,
113
- description: openGraph.description,
114
- image: openGraph.image,
115
- pageId: id,
116
- languageId,
117
- template: page.template_id || page?.template?.templateType || null,
118
- siteId: page.site,
119
- url: page.fullUrl,
120
- content,
121
- });
110
+ if (GRIDDO_SEARCH_FEATURE) {
111
+ const exportFile = path.resolve(
112
+ __dirname,
113
+ '../../dist/',
114
+ `./${filepath}index.html`
115
+ );
116
+
117
+ const content = fs.existsSync(exportFile)
118
+ ? fs.readFileSync(exportFile).toString()
119
+ : '';
122
120
 
123
- return content;
121
+ await postSearchInfo({
122
+ title,
123
+ description: openGraph.description,
124
+ image: openGraph.image,
125
+ pageId: id,
126
+ languageId,
127
+ template: page.template_id || page?.template?.templateType || null,
128
+ siteId: page.site,
129
+ url: page.fullUrl,
130
+ content,
131
+ });
132
+
133
+ // Este return ???
134
+ // return content;
135
+ }
124
136
  }
125
137
 
126
138
  async function renderListPages(
@@ -208,10 +220,14 @@ async function renderMultiplePages(page, additionalInfo, createPage) {
208
220
  paginatedPage.slug = newCompose;
209
221
  paginatedPage.template.activeSectionSlug = sectionSlug;
210
222
  paginatedPage.template.activeSectionBase = fullUrl;
223
+
211
224
  if (title.trim()) paginatedPage.title = title;
225
+
212
226
  paginatedPage.metaTitle =
213
227
  metaTitle.trim() || title.trim() || paginatedPage.metaTitle;
228
+
214
229
  if (metaDescription.trim()) paginatedPage.metaDescription = metaDescription;
230
+
215
231
  await renderSinglePage(paginatedPage, additionalInfo, createPage);
216
232
  }
217
233
  }