gatsby-core-theme 35.1.6 → 35.1.8

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/CHANGELOG.md CHANGED
@@ -1,3 +1,34 @@
1
+ ## [35.1.8](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v35.1.7...v35.1.8) (2024-08-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * apis translations ([52cb981](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/52cb981a461ef3558202e24f2999b8235a7c0eb1))
7
+ * cards v2 fix ([5bec538](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/5bec5381355d33d5738a608f86dd2f8c53b2d98e))
8
+ * clean ups ([f2322f4](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f2322f4e703addce10834ff71982b43768d72346))
9
+ * conflict ([c00065e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c00065ee5a2d615885a6b587cfa5c1dd30bf42ba))
10
+ * conflict ([c427423](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c4274235ac10dd80903bef1a7f02c589ce2fa182))
11
+ * conflict ([d6cacf8](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/d6cacf86c3df764518dca2416376805b2c135ae4))
12
+ * convert ms to seconds ([45c4d23](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/45c4d23aaad19593d5c3a5ee016151fa1ab74650))
13
+ * null values ([6f1acbb](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6f1acbb84e512132be45b758c8f8557ab4b5a40a))
14
+ * null values ([d14704f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/d14704ff2f3548396c890f2731554e1bdaf68a4a))
15
+ * null values ([11d5928](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/11d592828be89944a1219e15b17341ef7065fa51))
16
+ * remove operator logo from splash screen ([23a0691](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/23a0691c2b2d21deefa5df7635145b1bd10a368d))
17
+ * removed preview mode ([dd99508](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/dd99508dfe3c37b26e339d3944f98b17fdfa69fc))
18
+ * storybook ([a505e39](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a505e3916296569b1faf4e1f0368fefe8663f79d))
19
+ * translation improvements ([577e135](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/577e135632283bb618318ae20551dc415f6d5c3e))
20
+
21
+
22
+ * Merge branch 'v2-apis' into 'master' ([8dc5ec3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/8dc5ec3277d4346d845a42238f03a57baa4ce672))
23
+ * Merge branch 'tm-4676-remove-operator-logo' into 'master' ([9116b88](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9116b88f9cc8d3dbefb52b5bfdeeda7f117351ef))
24
+
25
+ ## [35.1.7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v35.1.6...v35.1.7) (2024-08-16)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * add language code for tracker ssr page ([013b349](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/013b34972254dbd73f96ed63dcd259041188184c))
31
+
1
32
  ## [35.1.6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v35.1.5...v35.1.6) (2024-08-09)
2
33
 
3
34
 
package/gatsby-node.mjs CHANGED
@@ -14,37 +14,35 @@ import { getData, getLocalData, getTranslations, getSiteSettings } from './src/h
14
14
 
15
15
  import { generateTrackerLink } from './src/helpers/generators.mjs';
16
16
  import processor, { processSitemapPages } from './src/helpers/processor/index.mjs';
17
- import { pickAuthorsPageKeys, pickRelationKeys } from './src/constants/pick-keys.mjs';
17
+ import { pickRelationKeys, pickTrackerOperatorKeys } from './src/constants/pick-keys.mjs';
18
18
  import settings from './src/constants/settings.mjs';
19
19
  import { translate } from './src/helpers/getters.mjs';
20
- import { groupBy } from './src/helpers/processor/common.mjs';
20
+ import { clean } from './src/helpers/processor/common.mjs';
21
21
  import { sanitizeOperatorData } from './src/helpers/processor/operators.mjs';
22
22
 
23
23
  const __dirname = dirname(fileURLToPath(import.meta.url));
24
24
  const { cloneDeep, chunk, pick } = loadash;
25
25
 
26
- const isPreview = process.env.GATSBY_PREVIEW_MODE === 'true';
27
- const appName = isPreview ? '/src/components/app-preview.js' : '/src/components/app.js';
28
-
29
26
  let preconnectLinks = null;
30
27
  let pages = null;
31
28
  let htmlSitemapPages = null;
32
- let marketSections = [];
33
- let allMarketSections = null;
34
29
  let prefilledModules = [];
35
30
  let siteInfo = null;
36
31
  let operators = null;
37
- let allMarkets = null;
38
- let translations = {};
39
- let languageKey = null;
32
+
40
33
  let context404 = null;
41
34
  let sports = null;
42
35
  let siteSchema = null;
43
- let templates = null;
44
36
  let authors = null;
45
- let translationsData = null;
46
37
 
47
- let siteSettings = null;
38
+
39
+ let translationsData = null;
40
+ let siteSettingsData = null;
41
+ let allMarketsData = null;
42
+ let allMarketSectionsData = null;
43
+ let schemaData = null;
44
+ let templatesData = null;
45
+ let defaultLanguage = null;
48
46
 
49
47
  function createArchivePage(pageObject, marketSections, prefilledModules, createPage) {
50
48
  const archiveModuleIndex = pageObject.sections.main.modules.findIndex(
@@ -90,17 +88,17 @@ function createArchivePage(pageObject, marketSections, prefilledModules, createP
90
88
  break;
91
89
  default:
92
90
  page.path = `${pageObject.path}/${translate(
93
- translations,
91
+ translationsData[pageObject.language],
94
92
  'archive_page_path',
95
93
  'page'
96
94
  )}/${archive.currentPage}`;
97
95
  page.meta_title += translate(
98
- translations,
96
+ translationsData[pageObject.language],
99
97
  'archive_title_suffix',
100
98
  '- Page [number]'
101
99
  ).replace('[number]', archive.currentPage);
102
100
  page.meta_description += translate(
103
- translations,
101
+ translationsData[pageObject.language],
104
102
  'archive_description_suffix',
105
103
  '- Page [number]'
106
104
  ).replace('[number]', archive.currentPage);
@@ -110,8 +108,8 @@ function createArchivePage(pageObject, marketSections, prefilledModules, createP
110
108
 
111
109
  createPage({
112
110
  path: page.path,
113
- component: `${__dirname}${appName}`,
114
- context: { page, marketSections, prefilledModules, siteInfo, allMarkets },
111
+ component: `${__dirname}/src/components/app.js`,
112
+ context: { page, marketSections, prefilledModules, siteInfo, allMarkets: allMarketsData },
115
113
  });
116
114
  });
117
115
  } else {
@@ -119,8 +117,8 @@ function createArchivePage(pageObject, marketSections, prefilledModules, createP
119
117
  page.hasArchive = true;
120
118
  createPage({
121
119
  path: page.path,
122
- component: `${__dirname}${appName}`,
123
- context: { page, marketSections, prefilledModules, siteInfo, allMarkets },
120
+ component: `${__dirname}/src/components/app.js`,
121
+ context: { page, marketSections, prefilledModules, siteInfo, allMarkets: allMarketsData },
124
122
  });
125
123
  }
126
124
  } else {
@@ -131,8 +129,8 @@ function createArchivePage(pageObject, marketSections, prefilledModules, createP
131
129
  page.sections.main.modules[archiveModuleIndex] = archive;
132
130
  createPage({
133
131
  path: page.path,
134
- component: `${__dirname}${appName}`,
135
- context: { page, marketSections, prefilledModules, siteInfo, allMarkets },
132
+ component: `${__dirname}/src/components/app.js`,
133
+ context: { page, marketSections, prefilledModules, siteInfo, allMarkets: allMarketsData },
136
134
  });
137
135
  }
138
136
  }
@@ -154,20 +152,6 @@ function keygen() {
154
152
  // eslint-disable-next-line import/prefer-default-export
155
153
  export const createPages = async ({ actions: { createPage } }, themeOptions) => {
156
154
  process.env.GATSBY_SITE_NAME = String(themeOptions.siteName);
157
- if (process.env.GATSBY_PREVIEW_MODE === 'true') {
158
- console.log(chalk.magenta('info') + chalk.whiteBright(' preview mode enabled'));
159
- createPage({
160
- path: '/',
161
- component: `${__dirname}${appName}`,
162
- context: {
163
- page: { relation_type: 'page' },
164
- preview: true,
165
- siteInfo,
166
- ...themeOptions,
167
- },
168
- });
169
- return;
170
- }
171
155
 
172
156
  let response = [];
173
157
  if (process.env.LOCAL_DATA === 'false') {
@@ -180,19 +164,21 @@ export const createPages = async ({ actions: { createPage } }, themeOptions) =>
180
164
 
181
165
  const stream = fs.createWriteStream('rewrites.conf');
182
166
  console.log(chalk.magenta('info') + chalk.whiteBright(' creating rewrite rules'));
183
- if (response.redirects) {
184
- response.redirects.forEach((redirect) => {
185
- if (![301, 302, 410].includes(parseInt(redirect.code))) return;
186
- if ([301, 302].includes(parseInt(redirect.code))) {
187
- const redirectName = parseInt(redirect.code) === 301 ? 'permanent' : 'redirect';
188
- stream.write(
189
- `rewrite (?i)^${redirect.from}/?$ ${redirect.to.replace(/[{}]/g, '')} ${redirectName}; \n`
190
- );
191
- }
192
- if (parseInt(redirect.code) === 410) {
193
- stream.write(`location ~ /${redirect.from} { return 410; } \n`);
167
+ if (siteSettingsData.redirects) {
168
+ Object.entries(siteSettingsData.redirects).forEach(
169
+ ([key, value]) => {
170
+ if (![301, 302, 410].includes(parseInt(value.type))) return;
171
+ if ([301, 302].includes(parseInt(value.type))) {
172
+ const redirectName = parseInt(value.type) === 301 ? 'permanent' : 'redirect';
173
+ stream.write(
174
+ `rewrite (?i)^${value.from}/?$ ${value.to.replace(/[{}]/g, '')} ${redirectName}; \n`
175
+ );
176
+ }
177
+ if (parseInt(value.type) === 410) {
178
+ stream.write(`location ~ /${value.from} { return 410; } \n`);
179
+ }
194
180
  }
195
- });
181
+ )
196
182
  }
197
183
  stream.end();
198
184
 
@@ -200,17 +186,14 @@ export const createPages = async ({ actions: { createPage } }, themeOptions) =>
200
186
  console.log(chalk.magenta('info') + chalk.whiteBright(' starting processor'));
201
187
 
202
188
  // add data to modules
203
- const processed = processor.run(response, themeOptions, fs, translationsData);
189
+ const processed = processor.run({
190
+ ...siteSettingsData,
191
+ ...response,
192
+ }, themeOptions, fs, translationsData);
204
193
  pages = processed.pages;
205
194
  siteInfo = processed.general;
195
+ allMarketSectionsData = processed.market_sections;
206
196
  operators = processed.relations.operator;
207
- templates = processed.templates;
208
- // eslint-disable-next-line prefer-destructuring
209
- languageKey = Object.keys(processed.relations.translations)[0];
210
- translations = processed.relations.translations[languageKey];
211
- allMarkets = processed.site_markets;
212
- allMarketSections = processed.market_sections;
213
-
214
197
  htmlSitemapPages = processSitemapPages(pages, processed.site_markets);
215
198
 
216
199
  if (['rage_seo', 'rage_ppc', 'sports'].includes(response.general.type)) {
@@ -242,9 +225,11 @@ export const createPages = async ({ actions: { createPage } }, themeOptions) =>
242
225
  footer: { modules: [] },
243
226
  },
244
227
  });
228
+ let count = 0;
245
229
  Object.keys(processed.pages[siteMarket]).forEach((pageType) => {
246
230
  processed.pages[siteMarket][pageType].forEach((page) => {
247
- marketSections = processed.market_sections[siteMarket];
231
+ count += 1;
232
+ const marketSection = allMarketSectionsData[siteMarket];
248
233
  prefilledModules = processed.prefilled_market_modules[siteMarket];
249
234
 
250
235
  const processedPage = page;
@@ -252,19 +237,16 @@ export const createPages = async ({ actions: { createPage } }, themeOptions) =>
252
237
 
253
238
  siteSchema =
254
239
  page.path === 'preview'
255
- ? (page.siteSchema = Object.values(response.schema || {})[0])
256
- : response.schema[page['market_id']];
240
+ ? (page.siteSchema = Object.values(schemaData || {})[0])
241
+ : schemaData[page['market_id']];
257
242
  authors = response.authors;
258
243
 
259
244
  // siteInfo, siteSchema and authors are added to page for schemaGenerator()
260
245
  page.siteInfo = siteInfo;
261
246
  page.siteSchema = siteSchema;
262
- page.authors = Object.keys(authors || {}).map((key) =>
263
- pick(authors[key], pickAuthorsPageKeys)
264
- );
265
247
 
266
248
  if (hasArchiveModule(page)) {
267
- createArchivePage(page, marketSections, prefilledModules, createPage);
249
+ createArchivePage(page, marketSection, prefilledModules, createPage);
268
250
  return;
269
251
  }
270
252
 
@@ -272,29 +254,30 @@ export const createPages = async ({ actions: { createPage } }, themeOptions) =>
272
254
  return;
273
255
  }
274
256
 
275
- const template = templates[page.template_id];
257
+ const template = templatesData[page.template_id];
276
258
  const autogenerated = template && template.autogenerated_content;
277
- const contextData = {
259
+ const contextData = clean({
278
260
  page,
279
- allMarkets,
280
- marketSections,
261
+ allMarkets: allMarketsData,
262
+ marketSections: marketSection,
281
263
  prefilledModules,
282
264
  siteInfo,
283
265
  autogenerated,
284
266
  siteSchema,
285
267
  authors,
268
+ lang: page.language,
286
269
  ...themeOptions,
287
- };
270
+ });
288
271
 
289
- const pathPrefix = processed.site_markets[siteMarket].path_prefix
290
- ? `${processed.site_markets[siteMarket].path_prefix}/`
272
+ const pathPrefix = allMarketsData[siteMarket].path_prefix
273
+ ? `${allMarketsData[siteMarket].path_prefix}/`
291
274
  : null;
292
275
 
293
276
  if (page.path === '404') {
294
277
  context404 = contextData;
295
278
  } else if (
296
279
  page.path ===
297
- `${pathPrefix || ''}${translate(translations, 'sitemap', 'sitemap')}`
280
+ `${pathPrefix || ''}${translate(translationsData[page.language], 'sitemap', 'sitemap')}`
298
281
  ) {
299
282
  createPage({
300
283
  path: `/${page.path}`,
@@ -302,7 +285,7 @@ export const createPages = async ({ actions: { createPage } }, themeOptions) =>
302
285
  context: {
303
286
  ...contextData,
304
287
  sitemapData: { ...htmlSitemapPages[page.market] },
305
- templates,
288
+ templates: templatesData,
306
289
  },
307
290
  });
308
291
  } else if (page.path === `${pathPrefix || ''}s`) {
@@ -328,8 +311,11 @@ export const createPages = async ({ actions: { createPage } }, themeOptions) =>
328
311
  },
329
312
  });
330
313
  }
314
+
331
315
  });
316
+
332
317
  });
318
+
333
319
  });
334
320
 
335
321
  // Generating Affiliate Tracker Link
@@ -348,7 +334,7 @@ export const createPages = async ({ actions: { createPage } }, themeOptions) =>
348
334
  template: pageTemplate,
349
335
  title: 'Tracker',
350
336
  relation_type: 'page',
351
- language: languageKey,
337
+ language: defaultLanguage,
352
338
  path: tracker,
353
339
  meta_robots: ['noindex', 'nofollow'],
354
340
  };
@@ -368,113 +354,43 @@ export const createPages = async ({ actions: { createPage } }, themeOptions) =>
368
354
  }
369
355
 
370
356
  // Creating Tracking links
371
- if (process.env.GEO_TRACKING) {
372
- const operatorsShortName = groupBy(operators, 'short_name');
373
- const trackerNames = [];
374
- Object.keys(operatorsShortName).forEach((shortname) => {
375
- const operatorsAllMarket = operatorsShortName[shortname];
376
-
377
- Object.keys(operatorsAllMarket).forEach((operator) => {
378
- Object.keys(operatorsAllMarket[operator].links).forEach((link) => {
379
- if (!trackerNames.includes(link)) {
380
- trackerNames.push(link);
381
- }
382
- });
383
- });
384
-
385
- const operatorsByType = groupBy(operatorsAllMarket, 'type');
386
-
387
- Object.keys(operatorsByType).forEach((type) => {
388
- const operatorsByMarket = groupBy(operatorsByType[type], 'market');
389
- console.log(trackerNames);
390
-
391
- trackerNames.forEach((link) => {
392
- const trackerLinkPath = generateTrackerLink(
393
- operatorsByType[type][0],
394
- link,
395
- false,
396
- pageTemplate
397
- )
398
- .toLowerCase()
399
- .replace(' ', '_');
400
- console.log(trackerLinkPath);
401
- const trackerPageObject = {
402
- meta_title: 'Tracker',
403
- template: pageTemplate,
404
- title: 'Tracker',
405
- relation_type: 'page',
406
- language: languageKey,
407
- path: trackerLinkPath,
408
- meta_robots: ['noindex', 'nofollow'],
409
- };
410
-
411
- const trackerComp =
412
- process.env.IS_TRACKING_SSR === 'true'
413
- ? `${__dirname}/src/components/pages/tracker-geo/index-ssr.js`
414
- : `${__dirname}/src/components/pages/tracker-geo/index.js`;
415
-
416
- createPage({
417
- path: trackerLinkPath,
418
- component: trackerComp,
419
- context: {
420
- page: trackerPageObject,
421
- siteInfo,
422
- operator: Object.fromEntries(
423
- Object.entries(operatorsByMarket).map(([key, operator]) => [
424
- key,
425
- pick(cloneDeep(sanitizeOperatorData(operator)), pickRelationKeys.operator)
426
- ])
427
- ),
428
- isTrackeGeo: true,
429
- isLiveStreamProvider: false,
430
- },
431
- });
357
+ Object.keys(operators || {}).forEach((operatorId) => {
358
+ const operator = operators[operatorId];
359
+ const trackerLinks = Object.keys(operator.links);
360
+ const tracker = trackerLinks.map((key) =>
361
+ operator.links[key]
362
+ ? generateTrackerLink(operator, key, false, pageTemplate).toLowerCase().replace(' ', '_')
363
+ : null
364
+ );
365
+ const marketOperator = operator.market.match(/_(\w+)/)[1];
366
+
367
+ tracker.forEach((trackerPath) => {
368
+ // Create splash page
369
+ if (trackerPath) {
370
+ const trackerPageObject = {
371
+ meta_title: 'Tracker',
372
+ template: pageTemplate,
373
+ title: 'Tracker',
374
+ relation_type: 'page',
375
+ language: marketOperator,
376
+ path: trackerPath,
377
+ meta_robots: ['noindex', 'nofollow'],
378
+ };
379
+ createPage({
380
+ path: trackerPath,
381
+ component: `${__dirname}/src/components/app-tracker-ssr.js`,
382
+ context: {
383
+ page: trackerPageObject,
384
+ siteInfo,
385
+ operator: pick(cloneDeep(sanitizeOperatorData(operator, [], [], translationsData[defaultLanguage], [])), pickTrackerOperatorKeys),
386
+ isTracker: true,
387
+ isLiveStreamProvider: false,
388
+ },
432
389
  });
433
- });
434
- });
435
- } else {
436
- Object.keys(operators || {}).forEach((operatorId) => {
437
- const operator = operators[operatorId];
438
- const trackerLinks = Object.keys(operator.links);
439
- const tracker = trackerLinks.map((key) =>
440
- operator.links[key]
441
- ? generateTrackerLink(operator, key, false, pageTemplate).toLowerCase().replace(' ', '_')
442
- : null
443
- );
444
- const marketOperator = operator.market.match(/_(\w+)/)[1];
445
-
446
- const trackerComp =
447
- process.env.IS_TRACKING_SSR === 'true'
448
- ? `${__dirname}/src/components/app-tracker-ssr.js`
449
- : `${__dirname}/src/components/app-tracker.js`;
450
-
451
- tracker.forEach((trackerPath) => {
452
- // Create splash page
453
- if (trackerPath) {
454
- const trackerPageObject = {
455
- meta_title: 'Tracker',
456
- template: pageTemplate,
457
- title: 'Tracker',
458
- relation_type: 'page',
459
- language: languageKey,
460
- path: trackerPath,
461
- meta_robots: ['noindex', 'nofollow'],
462
- };
463
- createPage({
464
- path: trackerPath,
465
- component: trackerComp,
466
- context: {
467
- page: trackerPageObject,
468
- siteInfo,
469
- operator: pick(cloneDeep(sanitizeOperatorData(operator, [], [], translations, [])), pickRelationKeys.operator),
470
- isTracker: true,
471
- isLiveStreamProvider: false,
472
- },
473
- });
474
- }
475
- });
390
+ }
476
391
  });
477
- }
392
+ });
393
+
478
394
  };
479
395
 
480
396
  export const onCreatePage = ({ page, actions }) => {
@@ -483,8 +399,8 @@ export const onCreatePage = ({ page, actions }) => {
483
399
  const oldPage = { ...page };
484
400
  const langCode = page.path.split(`/`)[1];
485
401
  page.matchPath = `/${langCode}/*`;
486
- const marketCode = Object.keys(allMarkets).find(
487
- (key) => allMarkets[key].path_prefix === langCode
402
+ const marketCode = Object.keys(allMarketSectionsData).find(
403
+ (key) => allMarketSectionsData[key].path_prefix === langCode
488
404
  );
489
405
  if (marketCode) {
490
406
  // Recreate the modified page
@@ -494,7 +410,7 @@ export const onCreatePage = ({ page, actions }) => {
494
410
  context: {
495
411
  ...context404,
496
412
  page: { ...context404.page, market: marketCode, language: langCode },
497
- marketSections: allMarketSections[marketCode],
413
+ marketSections: allMarketSectionsData[marketCode],
498
414
  },
499
415
  component: `${__dirname}/src/components/app.js`,
500
416
  });
@@ -510,28 +426,42 @@ export const onCreatePage = ({ page, actions }) => {
510
426
  } else {
511
427
  createPage({
512
428
  path: page.path,
513
- component: `${__dirname}${appName}`,
514
- context: { page, marketSections, prefilledModules, siteInfo },
429
+ component: `${__dirname}/src/components/app.js`,
430
+ context: { page, marketSections: allMarketSectionsData[page.market], prefilledModules, siteInfo },
515
431
  });
516
432
  }
517
433
  };
518
434
 
519
435
  export const onPreBootstrap = async () => {
520
436
  // Get Data from Hercules
521
- siteSettings = await getSiteSettings(process.env.GATSBY_SITE_NAME);
522
-
523
- }
437
+ siteSettingsData = await getSiteSettings(process.env.GATSBY_SITE_NAME);
438
+ allMarketsData = siteSettingsData.site_markets;
439
+ schemaData = siteSettingsData.schema;
440
+ templatesData = siteSettingsData.templates;
441
+ allMarketSectionsData = siteSettingsData.market_sections;
442
+ }
524
443
 
525
444
  export const sourceNodes = async ({ actions, createNodeId, createContentDigest }) => {
526
445
  const { createNode } = actions;
527
- const keys = Object.keys(siteSettings.site_markets)
446
+ const keys = Object.keys(siteSettingsData.site_markets)
528
447
  .map(key => `language_codes[]=${key.split('_')[1]}`)
529
448
  .join('&');
530
- console.log(keys);
449
+
450
+ let defaultMarket = null;
451
+ Object.entries(siteSettingsData.site_markets).forEach(
452
+ ([key, value]) => {
453
+ if(value.path_prefix === null)
454
+ {
455
+ defaultMarket = key;
456
+ }
457
+ }
458
+ )
459
+ defaultLanguage = defaultMarket.split('_')[1];
531
460
  translationsData = await getTranslations(process.env.GATSBY_SITE_NAME, keys);
532
461
 
533
462
  // eslint-disable-next-line array-callback-return
534
463
  Object.keys(translationsData).map((language) => {
464
+ // eslint-disable-next-line array-callback-return
535
465
  Object.entries(translationsData[language]).map((key) => {
536
466
  const translation = {
537
467
  'key': key[0],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "35.1.6",
3
+ "version": "35.1.8",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -3,13 +3,28 @@
3
3
  import React, { useEffect, useState } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import { globalHistory } from '@reach/router';
6
- import { graphql } from 'gatsby';
6
+ import { graphql, useStaticQuery } from 'gatsby';
7
7
  import MainProvider from '~context/MainProvider';
8
8
  import Body from '~pages/body';
9
9
  import HeadData from '~organisms/head';
10
10
  import { getAPIData } from '~helpers/server-data';
11
11
 
12
- const AppSSR = ({ pageContext, serverData, data }) => {
12
+ const AppSSR = ({ pageContext, serverData }) => {
13
+
14
+ const data = useStaticQuery(graphql`
15
+ query {
16
+ translations: allTranslation(filter: {}) {
17
+ edges {
18
+ node {
19
+ key
20
+ language
21
+ value
22
+ }
23
+ }
24
+ }
25
+ }
26
+ `);
27
+
13
28
  const { isPreview } = pageContext;
14
29
  const [previewContext, setPreviewContext] = useState({});
15
30
  const [isLoading, setIsLoading] = useState({});
@@ -63,20 +78,6 @@ const AppSSR = ({ pageContext, serverData, data }) => {
63
78
  );
64
79
  };
65
80
 
66
- export const query = graphql`
67
- query {
68
- translations: allTranslation(filter: {}) {
69
- edges {
70
- node {
71
- key
72
- language
73
- value
74
- }
75
- }
76
- }
77
- }
78
- `;
79
-
80
81
  export const Head = ({ pageContext }) => (
81
82
  <HeadData page={pageContext.page} siteInfo={pageContext.siteInfo} />
82
83
  );
@@ -103,11 +104,12 @@ AppSSR.propTypes = {
103
104
  serverData: PropTypes.any,
104
105
  };
105
106
 
107
+ export default AppSSR;
108
+
106
109
  export async function getServerData(props) {
107
110
  // eslint-disable-next-line no-shadow
108
111
  const { pageContext, url, query, headers } = props;
109
112
  let res = '';
110
113
  res = await getAPIData(pageContext.page, query.s ? url : headers.get('referer'));
111
114
  return res;
112
- }
113
- export default AppSSR;
115
+ }
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  /* eslint-disable react/forbid-prop-types */
3
- import React from 'react';
4
- import { useStaticQuery, graphql } from 'gatsby';
5
- import MainProvider from '~context/MainProvider';
6
- import Tracker from './pages/tracker/index-ssr';
7
- import { getAffiliateLink } from '~helpers/tracker';
8
- import HeadData from '~organisms/head';
3
+ import React from "react";
4
+ import { useStaticQuery, graphql } from "gatsby";
5
+ import MainProvider from "~context/MainProvider";
6
+ import Tracker from "./pages/tracker/index-ssr";
7
+ import { getAffiliateLink } from "~helpers/tracker";
8
+ import HeadData from "~organisms/head";
9
9
 
10
10
  const AppTracker = (props) => {
11
11
  const data = useStaticQuery(graphql`
@@ -22,19 +22,23 @@ const AppTracker = (props) => {
22
22
  }
23
23
  `);
24
24
 
25
+ const { pageContext } = props;
26
+
25
27
  return (
26
- <MainProvider value={{ translations: data.translations }}>
28
+ <MainProvider
29
+ value={{ translations: data.translations, language: [pageContext.page.language] }}
30
+ >
27
31
  <Tracker {...props} />
28
32
  </MainProvider>
29
33
  );
30
34
  };
31
35
 
32
36
  export const Head = ({ pageContext }) => (
33
- <HeadData page={pageContext.page} siteInfo={pageContext.siteInfo} />
37
+ <HeadData page={pageContext.page} authors={pageContext.authors} siteInfo={pageContext.siteInfo} />
34
38
  );
35
39
 
36
40
  export async function getServerData({ pageContext, headers, url }) {
37
- let res = '';
41
+ let res = "";
38
42
  res = await getAffiliateLink(
39
43
  pageContext.operator,
40
44
  pageContext.page.path,
@@ -48,7 +48,7 @@ const App = ({ pageContext, data }) => {
48
48
  return 'Loading...';
49
49
  }
50
50
  }
51
-
51
+
52
52
  return (
53
53
  <MainProvider value={{ translations: data.translations, language: pageContext.page.language }}>
54
54
  <div
@@ -66,8 +66,8 @@ const App = ({ pageContext, data }) => {
66
66
  };
67
67
 
68
68
  export const query = graphql`
69
- query {
70
- translations: allTranslation(filter: {}) {
69
+ query ($lang: String) {
70
+ translations: allTranslation(filter: {language: {eq: $lang}}) {
71
71
  edges {
72
72
  node {
73
73
  key