gatsby-core-theme 1.6.0 → 1.6.4

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.
@@ -45,6 +45,7 @@ module.exports = {
45
45
  '~hooks': path.resolve(__dirname, '../src/hooks'),
46
46
  '~tests': path.resolve(__dirname, '../tests'),
47
47
  '~context': path.resolve(__dirname, '../src/context'),
48
+ '~constants': path.resolve(__dirname, '../src/constants'),
48
49
  };
49
50
 
50
51
  config.resolve.alias['$virtual/lazy-client-sync-requires'] = path.resolve(
package/CHANGELOG.md CHANGED
@@ -1,3 +1,65 @@
1
+ ## [1.6.4](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.6.3...v1.6.4) (2021-11-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * general issues ([419d8d3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/419d8d36f7bfe153e7e07d2ad2b92cd19e597aa1))
7
+
8
+
9
+ ### Code Refactoring
10
+
11
+ * align cards on search, dropdown z-index on mobile when open, lazyload force load on tab click ([1e44fa7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/1e44fa74f6e6ac63169a9bca9affa40f96a7d3cc))
12
+
13
+
14
+ * Merge branch 'tm-2478-search' into 'master' ([26e1a6e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/26e1a6ebd7632a4b866d9e02f8edf58cca5a17f6))
15
+ * Merge branch 'tm-2478-search' of git.ilcd.rocks:team-floyd/themes/gatsby-themes into tm-2478-search ([725ec14](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/725ec145917d2d7eb436f90cbb87a5427300166d))
16
+ * Merge branch 'master' into tm-2478-search ([9be2cb8](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9be2cb83d0948f9925b8e199064e075a44fc2f6d))
17
+
18
+ ## [1.6.3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.6.2...v1.6.3) (2021-11-18)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * html sitemap filters ([58892f4](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/58892f4a694be085c32ea80daef50f7c59ee8d87))
24
+
25
+ ## [1.6.2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.6.1...v1.6.2) (2021-11-17)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * filter events fnc error build ([9324fdf](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9324fdf9e99233b9857d9b60dd7973466f5df6ba))
31
+
32
+
33
+ * Merge branch 'fix-showcased-event' into 'master' ([a2d4959](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a2d49594cc73321dffd5258e2094e84c255151b0))
34
+
35
+ ## [1.6.1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.6.0...v1.6.1) (2021-11-17)
36
+
37
+
38
+ ### Bug Fixes
39
+
40
+ * fixed outdated showcased events ([a11df67](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a11df675e280f106e93c0dd760186b939baff47f))
41
+ * lazy image fix when src is null ([3f2a8b2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/3f2a8b21831e22b0ca9c3253a0dfa381ee9dd23d))
42
+
43
+
44
+ ### Code Refactoring
45
+
46
+ * implement generateSchemaObject and checkSchemaProp in schema ([52066db](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/52066db3235af1c72e01f666babb13d2d86b0e74))
47
+ * implement month and year placeholders for meta_title ([89fb697](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/89fb6976c2fa55946a72d53f3944105dd89e660e))
48
+ * remove double slash for contactPoint url in schema ([01e0cdc](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/01e0cdcc28a05079da048609b2e556624ac4f6c3))
49
+ * remove log ([183ff76](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/183ff769e0fa3b32b5122c07e979215a20684d59))
50
+ * update generateMetaTitle with translations ([4c458a1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4c458a1a914b22c62354279034405733bed53521))
51
+
52
+
53
+ * Merge branch 'tm-2594-month-year-placeholders' into 'master' ([f2c58eb](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f2c58ebe51e7cf3ef9319b9f90557e310c08f6d4))
54
+ * Merge branch 'fix-showcased-events' into 'master' ([78cfcc0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/78cfcc0ae51c4f93c1531e58c479c2869ba8032c))
55
+ * Merge branch 'tm-2588-lazy-image-fix' into 'master' ([5d414d0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/5d414d0ec4f32cfe8b9aa95edbbc9deaf716ad0e))
56
+ * Merge branch 'tm-2589-update-schema-and-fix-duplicates' into 'master' ([c63dd13](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c63dd13d230cd3e9558cdee4c275ee6b4092e726))
57
+
58
+
59
+ ### Tests
60
+
61
+ * added test for meta title generator ([02295b2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/02295b20a37c6e09b62f27345fafc8667612ac18))
62
+
1
63
  # [1.6.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.5.0...v1.6.0) (2021-11-12)
2
64
 
3
65
 
@@ -4,7 +4,7 @@
4
4
  import { cloneDeep, chunk, pick } from 'lodash';
5
5
  import chalk from 'chalk';
6
6
  import { getData, getLocalData } from './src/helpers/api';
7
- import { generateTrackerLink } from './src/helpers/generators';
7
+ import { generateMetaTitle, generateTrackerLink } from './src/helpers/generators';
8
8
  import processor, { processSitemapPages } from './src/helpers/processor';
9
9
  import { pickAuthorsPageKeys } from './src/constants/pick-keys';
10
10
 
@@ -210,6 +210,8 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
210
210
  page.authors = Object.keys(authors || {}).map((key) =>
211
211
  pick(authors[key], pickAuthorsPageKeys)
212
212
  );
213
+ // Done for matrix-theme sites for [MONTH][YEAR] auto update
214
+ page.meta_title = page.meta_title && generateMetaTitle(page.meta_title, translations);
213
215
 
214
216
  const contextData = {
215
217
  page,
@@ -362,6 +364,7 @@ exports.onCreateWebpackConfig = ({ actions, plugins, getConfig }) => {
362
364
  '~hooks': path.resolve(__dirname, 'src/hooks'),
363
365
  '~tests': path.resolve(__dirname, 'tests'),
364
366
  '~context': path.resolve(__dirname, 'src/context'),
367
+ '~constants': path.resolve(__dirname, 'src/constants'),
365
368
  },
366
369
  },
367
370
  });
package/jest.config.js CHANGED
@@ -15,6 +15,7 @@ module.exports = {
15
15
  '^~hooks(.*)$': '<rootDir>/src/hooks$1',
16
16
  '^~tests(.*)$': '<rootDir>/tests$1',
17
17
  '^~context(.*)$': '<rootDir>/src/context$1',
18
+ '^~constants(.*)$': '<rootDir>/src/constants$1',
18
19
  // JSON Data
19
20
  'data.json': '<rootDir>/__mocks__/search-data.json',
20
21
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "1.6.0",
3
+ "version": "1.6.4",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -78,7 +78,10 @@ export default function AuthorBox({ author }) {
78
78
  </a>
79
79
  ))}
80
80
  </p>
81
- <p className={styles.biography}>{author.biography}</p>
81
+ <div
82
+ className={styles.biography}
83
+ dangerouslySetInnerHTML={{ __html: author.biography }}
84
+ />
82
85
  </div>
83
86
  {author.profile_page_path && (
84
87
  <Link
@@ -15,7 +15,9 @@ const Archive = ({ module, PaginationComponent, page, loadMore, gtmClass = '' })
15
15
 
16
16
  useEffect(() => {
17
17
  if (module.pagination_type === 'load_more') {
18
- const items = module.items.filter((item, index) => index < parseInt(loadMore.limit));
18
+ const items = module.items.filter(
19
+ (item, index) => index < parseInt(loadMore ? loadMore.limit : 9)
20
+ );
19
21
  setModuleItems(items);
20
22
  }
21
23
  }, [module, module.items, loadMore]);
@@ -24,7 +26,7 @@ const Archive = ({ module, PaginationComponent, page, loadMore, gtmClass = '' })
24
26
  let items = [...module.items];
25
27
  if (items.length > moduleItems.length) {
26
28
  items = items.filter(
27
- (item, index) => index < moduleItems.length + parseInt(loadMore.increment)
29
+ (item, index) => index < moduleItems.length + parseInt(loadMore ? loadMore.increment : 9)
28
30
  );
29
31
  setModuleItems(items);
30
32
  }
@@ -2,15 +2,15 @@
2
2
  display: grid;
3
3
 
4
4
  @include min(mobile) {
5
- grid-template-columns: repeat(var(--cards-mob-column), 1fr);
5
+ grid-template-columns: repeat(var(--cards-mob-column), minmax(0,1fr));
6
6
  }
7
7
 
8
8
  @include min(tablet) {
9
- grid-template-columns: repeat(var(--cards-tablet-column), 1fr);
9
+ grid-template-columns: repeat(var(--cards-tablet-column), minmax(0,1fr));
10
10
  }
11
11
 
12
12
  @include min(desktop) {
13
- grid-template-columns: repeat(var(--cards-desktop-column), 1fr);
13
+ grid-template-columns: repeat(var(--cards-desktop-column), minmax(0,1fr));
14
14
  }
15
15
  column-gap: 0.8rem;
16
16
  @include min(desktop) {
@@ -0,0 +1,15 @@
1
+ /* eslint-disable import/prefer-default-export */
2
+ export const months = [
3
+ 'January',
4
+ 'February',
5
+ 'March',
6
+ 'April',
7
+ 'May',
8
+ 'June',
9
+ 'July',
10
+ 'August',
11
+ 'September',
12
+ 'October',
13
+ 'November',
14
+ 'December',
15
+ ];
@@ -1,4 +1,5 @@
1
- // eslint-disable-next-line
1
+ import { months } from '../constants/common';
2
+
2
3
  export function generateTrackerLink(operator, trackerType) {
3
4
  const defaultTrackerFormat = process.env.TRACKER_LINK_FORMAT_MAIN;
4
5
  const trackerFormat = process.env.TRACKER_LINK_FORMAT_NON_MAIN;
@@ -19,3 +20,18 @@ export function generateTrackerLink(operator, trackerType) {
19
20
  return `/${trackerArr.join('/')}`;
20
21
  }
21
22
  }
23
+
24
+ export function generateMetaTitle(metaTitle, translations) {
25
+ const date = new Date();
26
+ const month = months[date.getMonth()];
27
+ const year = date.getFullYear();
28
+
29
+ return metaTitle.replace(
30
+ /\[MONTH\]|\[YEAR\]/gi,
31
+ (match) =>
32
+ ({
33
+ '[MONTH]': (translations && translations[month]) || month,
34
+ '[YEAR]': year,
35
+ }[match])
36
+ );
37
+ }
@@ -1,4 +1,5 @@
1
- import { generateTrackerLink } from './generators';
1
+ import { generateTrackerLink, generateMetaTitle } from './generators';
2
+ import { months } from '~constants/common';
2
3
 
3
4
  describe('Generate Tracker Link Helper', () => {
4
5
  test('generateTrackerLink main', () => {
@@ -14,3 +15,26 @@ describe('Generate Tracker Link Helper', () => {
14
15
  expect(trackerLink).toEqual('/no/visit/bet365/casino/non_main');
15
16
  });
16
17
  });
18
+
19
+ describe('Generate Meta Title Helper', () => {
20
+ test('generateMetaTitle main', () => {
21
+ const metaTitle = generateMetaTitle('meta title [MONTH] [YEAR]');
22
+ const date = new Date();
23
+ expect(metaTitle).not.toContain('[MONTH]');
24
+ expect(metaTitle).not.toContain('[YEAR]');
25
+ expect(metaTitle).toContain(date.getFullYear());
26
+ expect(metaTitle).toContain(months[date.getMonth()]);
27
+ });
28
+ test('generateMetaTitle translated', () => {
29
+ const translateMonths = months.reduce(
30
+ (translated, month) => ({ ...translated, [month]: `translate${month.substring(0, 1)}` }),
31
+ {}
32
+ );
33
+ const metaTitle = generateMetaTitle('meta title [MONTH] [YEAR]', translateMonths);
34
+ const date = new Date();
35
+
36
+ expect(metaTitle).not.toContain('[MONTH]');
37
+ expect(metaTitle).not.toContain('[YEAR]');
38
+ expect(metaTitle).toContain(translateMonths[months[date.getMonth()]]);
39
+ });
40
+ });
@@ -39,9 +39,11 @@ export function processSitemapPages(pages, markets) {
39
39
  pageListByMarket[market] = [];
40
40
  let pageList = [];
41
41
  Object.keys(pages[market]).forEach((pageType) => {
42
- pageList = pageList.concat(
43
- pages[market][pageType].map((row) => pick(row, pickHTMLSitemapPageKeys))
42
+ const filteredPages = pages[market][pageType].filter(
43
+ (page) => page.robot_options && page.robot_options.page_index === 1
44
44
  );
45
+
46
+ pageList = pageList.concat(filteredPages.map((row) => pick(row, pickHTMLSitemapPageKeys)));
45
47
  });
46
48
 
47
49
  pageListByMarket[market] = groupBy(pageList, 'template_id');
@@ -58,7 +58,9 @@ export function prepareSportsData(sportsData) {
58
58
  });
59
59
 
60
60
  Object.keys(sportsData.showcased_events).forEach((sportKey) => {
61
- sportsData.showcased_events[sportKey] = sportsData.showcased_events[sportKey]
61
+ const filteredEventIds = filterEvents(sportsData.showcased_events[sportKey], sportsData.events);
62
+
63
+ sportsData.showcased_events[sportKey] = filteredEventIds
62
64
  .map((eventId) => sportsData.events[eventId])
63
65
  .filter((event) => event);
64
66
  });
@@ -104,15 +104,17 @@ export function filterEvents(tournamentEvents, events) {
104
104
  const futureEvents = [];
105
105
  const today = new Date().setHours(0, 0, 0, 0);
106
106
  tournamentEvents.forEach((eventId) => {
107
- const eventDate = new Date(
108
- `${events[eventId].date.year_number}-${zeroPadding(
109
- events[eventId].date.month_number,
110
- 2
111
- )}-${zeroPadding(events[eventId].date.day_number, 2)}`
112
- );
107
+ if (events[eventId]) {
108
+ const eventDate = new Date(
109
+ `${events[eventId].date.year_number}-${zeroPadding(
110
+ events[eventId].date.month_number,
111
+ 2
112
+ )}-${zeroPadding(events[eventId].date.day_number, 2)}`
113
+ );
113
114
 
114
- if (eventDate >= today) {
115
- futureEvents.push(eventId);
115
+ if (eventDate >= today) {
116
+ futureEvents.push(eventId);
117
+ }
116
118
  }
117
119
  });
118
120
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-use-before-define */
2
1
  import { getGameRating, getUrl, getLanguage } from './getters';
3
2
 
4
3
  /* HardCoded Start */
@@ -53,20 +52,30 @@ const socialLinks = [
53
52
  'youtube',
54
53
  ];
55
54
 
56
- export function schemaGenerator(page = {}, pageImage) {
57
- const jsonSchema = [
58
- // Page Schema
59
- page.seo_json_schema,
60
- // Breadcrumbs Schema
61
- page.breadcrumbs?.length ? breadcrumbsSchema(page.breadcrumbs) : null,
62
- // Modules Schemas
63
- webPageSchema(page, pageImage),
64
- organizationSchema(page, pageImage),
65
- templateSchemas(page),
66
- ...(page.sections?.main?.modules ? moduleSchemas(page.sections.main.modules) : [null]),
67
- ];
55
+ function checkSchemaProp(prop) {
56
+ return (
57
+ (!Array.isArray(prop) || (Array.isArray(prop) && prop.length)) &&
58
+ prop !== undefined &&
59
+ prop !== null &&
60
+ prop !== ''
61
+ );
62
+ }
68
63
 
69
- return jsonSchema;
64
+ export function generateSchemaObject(schema) {
65
+ return Object.keys(schema).reduce((obj, key) => {
66
+ if (
67
+ Object.prototype.toString.call(schema[key]) === '[object Object]' &&
68
+ Object.keys(schema[key]).length
69
+ ) {
70
+ obj[key] = generateSchemaObject(schema[key]);
71
+ }
72
+
73
+ if (checkSchemaProp(schema[key])) {
74
+ obj[key] = schema[key];
75
+ }
76
+
77
+ return obj;
78
+ }, {});
70
79
  }
71
80
 
72
81
  export function breadcrumbsSchema(breadcrumbs) {
@@ -83,7 +92,7 @@ export function breadcrumbsSchema(breadcrumbs) {
83
92
  })),
84
93
  };
85
94
 
86
- return JSON.stringify(schema);
95
+ return JSON.stringify(generateSchemaObject(schema));
87
96
  }
88
97
 
89
98
  export function webPageSchema(page, pageImage) {
@@ -118,7 +127,7 @@ export function webPageSchema(page, pageImage) {
118
127
  contactType: 'Author',
119
128
  name: author.name || '',
120
129
  email: author.email_address || '',
121
- url: `${getUrl('/')}/${author.profile_page_path}`,
130
+ url: `${getUrl('/')}${author.profile_page_path}`,
122
131
  })),
123
132
  sameAs: socialLinks
124
133
  .map((socialLink) => page.siteSchema?.[socialLink])
@@ -140,7 +149,7 @@ export function webPageSchema(page, pageImage) {
140
149
  schema.keywords = page.seo_keywords;
141
150
  }
142
151
 
143
- return JSON.stringify(schema);
152
+ return JSON.stringify(generateSchemaObject(schema));
144
153
  }
145
154
 
146
155
  export function organizationSchema(page, pageImage) {
@@ -155,7 +164,7 @@ export function organizationSchema(page, pageImage) {
155
164
  .filter((socialLink) => socialLink),
156
165
  };
157
166
 
158
- return JSON.stringify(schema);
167
+ return JSON.stringify(generateSchemaObject(schema));
159
168
  }
160
169
 
161
170
  export function moduleSchemas(modules) {
@@ -175,7 +184,7 @@ export function moduleSchemas(modules) {
175
184
  })),
176
185
  };
177
186
 
178
- return JSON.stringify(moduleSchema);
187
+ return JSON.stringify(generateSchemaObject(moduleSchema));
179
188
  }
180
189
  default: {
181
190
  return null;
@@ -214,7 +223,7 @@ export function templateSchemas(page) {
214
223
  },
215
224
  };
216
225
 
217
- return JSON.stringify(schema);
226
+ return JSON.stringify(generateSchemaObject(schema));
218
227
  }
219
228
  case 'operator': {
220
229
  const schema = {
@@ -249,7 +258,7 @@ export function templateSchemas(page) {
249
258
  },
250
259
  };
251
260
 
252
- return JSON.stringify(schema);
261
+ return JSON.stringify(generateSchemaObject(schema));
253
262
  }
254
263
  case 'game': {
255
264
  const rating = Math.floor(getGameRating(page.relation) * 2);
@@ -288,9 +297,25 @@ export function templateSchemas(page) {
288
297
  },
289
298
  };
290
299
 
291
- return JSON.stringify(schema);
300
+ return JSON.stringify(generateSchemaObject(schema));
292
301
  }
293
302
  default:
294
303
  return null;
295
304
  }
296
305
  }
306
+
307
+ export function schemaGenerator(page = {}, pageImage) {
308
+ const jsonSchema = [
309
+ // Page Schema
310
+ page.seo_json_schema,
311
+ // Breadcrumbs Schema
312
+ page.breadcrumbs?.length ? breadcrumbsSchema(page.breadcrumbs) : null,
313
+ // Modules Schemas
314
+ webPageSchema(page, pageImage),
315
+ organizationSchema(page, pageImage),
316
+ templateSchemas(page),
317
+ ...(page.sections?.main?.modules ? moduleSchemas(page.sections.main.modules) : [null]),
318
+ ];
319
+
320
+ return jsonSchema;
321
+ }
@@ -111,8 +111,8 @@ describe('Schema Helper', () => {
111
111
  expect(json.author.contactPoint[1]['@type']).toEqual('ContactPoint');
112
112
  expect(json.author.contactPoint[0].contactType).toEqual('Author');
113
113
  expect(json.author.contactPoint[1].contactType).toEqual('Author');
114
- expect(json.author.contactPoint[0].url).toEqual(`${getUrl('/')}/author_a/author_page`);
115
- expect(json.author.contactPoint[1].url).toEqual(`${getUrl('/')}/author_b/author_page`);
114
+ expect(json.author.contactPoint[0].url).toEqual(`${getUrl('/')}author_a/author_page`);
115
+ expect(json.author.contactPoint[1].url).toEqual(`${getUrl('/')}author_b/author_page`);
116
116
  expect(json.author.contactPoint[0].name).toEqual('Author_A');
117
117
  expect(json.author.contactPoint[1].name).toEqual('Author_B');
118
118
  expect(json.author.contactPoint[0].email).toEqual('email_a@email.com');
@@ -21,7 +21,7 @@ export default function LazyImage({
21
21
  }) {
22
22
  const [errorImage, setErrorImage] = useState(false);
23
23
 
24
- if (defaultImg && errorImage === true) {
24
+ if ((defaultImg && !src) || errorImage === true) {
25
25
  return defaultImg;
26
26
  }
27
27
 
@@ -1,5 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import { forceCheck } from 'react-lazyload';
3
4
  import TabList from './tab/tab-list';
4
5
  import styles from './tabs.module.scss';
5
6
 
@@ -24,6 +25,7 @@ const Tabs = ({
24
25
 
25
26
  function onClickTabItem(tabId) {
26
27
  setActiveTab(tabId);
28
+ forceCheck();
27
29
  }
28
30
 
29
31
  return (
@@ -11,7 +11,7 @@
11
11
  opacity: 1;
12
12
  z-index: map-get($z-index, modal);
13
13
  &.list {
14
- z-index: map-get($z-index, above-content);
14
+ z-index: map-get($z-index, --scroll-to-top-index);
15
15
  }
16
16
  }
17
17
  }
@@ -13,6 +13,9 @@ export default function getPageDataList(length) {
13
13
  template_id: '5',
14
14
  name: 'Rizk Casino',
15
15
  logo_url: '#',
16
+ robot_options: {
17
+ page_index: 1,
18
+ },
16
19
  banner: '313df295c19d7c5f137ceda9d0cc5df7.jpeg',
17
20
  meta_title: 'my meta title',
18
21
  language: 'en',