gatsby-core-theme 11.0.5 → 12.0.0-beta.2

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,49 @@
1
+ # [12.0.0-beta.2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v12.0.0-beta.1...v12.0.0-beta.2) (2022-09-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * passed serverData to main and header component ([946db07](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/946db077f48fadb7714a8a66c2ac1520a9c4ce0e))
7
+ * passed serverData to main and header component ([2f70176](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2f70176c7075a71ed28faf87f1c037a0b05b9da2))
8
+
9
+
10
+ * Merge branch 'tm-2643-sports-site' into 'beta' ([f9e3c03](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f9e3c03264e0e7dfebaa87c68b5997408bf4169e))
11
+
12
+ # [12.0.0-beta.1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v11.0.6...v12.0.0-beta.1) (2022-09-07)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * added checks to prevent useless p and div elements ([85e2197](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/85e2197b7dc8d5bedf5c9ce9d9fb0b3f1efa4ae5))
18
+ * aligned beta branch with master ([e5461e0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/e5461e04e40441793f58a599e63c946348284d37))
19
+ * sports site changes ([d833e1e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/d833e1ee8b8b7ce6359954e1de004292572a76b9))
20
+
21
+
22
+ ### chore
23
+
24
+ * **release:** 10.0.2-beta.1 [skip ci] ([fdac7b3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/fdac7b3866a7038758f8b72f5a56dde928b85365))
25
+
26
+
27
+ * Merge branch 'tm-2643-sports-site' into 'beta' ([859b8db](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/859b8db7d2b87efa47b557ba3cec5cb412b3e0d3))
28
+ * Merge branch 'tm-2987-gatsby-upgrade' into 'beta' ([59f9b28](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/59f9b288f99cd61f3a3064480861efc9f1263559))
29
+
30
+
31
+ ### Features
32
+
33
+ * added sports site SSR logic ([15cc0d2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/15cc0d205bd1f9b3f95333b331481f07a4c91c90))
34
+
35
+ ## [11.0.6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v11.0.5...v11.0.6) (2022-09-02)
36
+
37
+
38
+ ### Bug Fixes
39
+
40
+ * update button and author-box ([3eec6da](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/3eec6da80b37568a47ead1a15ad1811612b10828))
41
+ * update button component ([60cd4d1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/60cd4d1148517bdd4ef51cc265561b8137cfdcfa))
42
+ * update button component in order to accept props ([25cc1e3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/25cc1e31df9e468be966e3b1a7414e84dc5bace3))
43
+
44
+
45
+ * Merge branch 'tm-3024-contact-us' into 'master' ([46e0b23](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/46e0b238e9c0c4da12a90c2dd072e6fc0fb039c7))
46
+
1
47
  ## [11.0.5](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v11.0.4...v11.0.5) (2022-08-31)
2
48
 
3
49
 
package/gatsby-config.js CHANGED
@@ -42,7 +42,6 @@ module.exports = {
42
42
  ],
43
43
  },
44
44
  },
45
- // `gatsby-plugin-preact`,
46
45
  `gatsby-plugin-image`,
47
46
  ],
48
47
  };
@@ -169,7 +169,7 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
169
169
  translations = processed.relations.translations[languageKey];
170
170
  htmlSitemapPages = processSitemapPages(pages, processed.site_markets);
171
171
 
172
- if (['rage_seo', 'rage_ppc'].includes(response.general.type)) {
172
+ if (['rage_seo', 'rage_ppc', 'sports'].includes(response.general.type)) {
173
173
  sports = Object.keys(response.relations['sports_data'].sports).map(
174
174
  (key) => response.relations['sports_data'].sports[key]
175
175
  );
@@ -248,9 +248,15 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
248
248
  context: { ...contextData, sitemapData: { ...htmlSitemapPages }, templates },
249
249
  });
250
250
  } else {
251
+ const component =
252
+ (page.type === 'event' || page.type === 'tournament') &&
253
+ ['sports'].includes(response.general.type)
254
+ ? require.resolve('./src/components/app-ssr.js')
255
+ : require.resolve('./src/components/app.js');
256
+
251
257
  createPage({
252
258
  path: page.path.charAt(0) === '/' ? page.path : `/${page.path}`,
253
- component: require.resolve('./src/components/app.js'),
259
+ component,
254
260
  context: {
255
261
  ...contextData,
256
262
  isPreview: page.path === 'preview',
@@ -261,6 +267,7 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
261
267
  });
262
268
  });
263
269
 
270
+ // Generating Affiliate Tracker Links
264
271
  if (['rage_seo', 'rage_ppc'].includes(response.general.type)) {
265
272
  Object.keys(
266
273
  (processed.relations &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "11.0.5",
3
+ "version": "12.0.0-beta.2",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -0,0 +1,97 @@
1
+ /* eslint-disable react/forbid-prop-types */
2
+ import React, { useEffect, useState } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { globalHistory } from '@reach/router';
5
+ import TranslationsProvider from '~context/TranslationsProvider';
6
+ import Body from '~pages/body';
7
+ import Head from '~organisms/head';
8
+ import { getAPIData } from '~helpers/server-data';
9
+
10
+ const AppSSR = ({ pageContext, serverData }) => {
11
+ const { translations = {}, isPreview } = pageContext;
12
+ const [previewContext, setPreviewContext] = useState({});
13
+ const [isLoading, setIsLoading] = useState({});
14
+ async function getData(searchParams, staticPath = null) {
15
+ const { getPreview } = await import('~helpers/api');
16
+ getPreview(
17
+ pageContext.siteName,
18
+ !staticPath ? searchParams.get('path') || '/' : staticPath,
19
+ pageContext
20
+ ).then((previewResponse) => {
21
+ if (previewResponse.page) {
22
+ // siteInfo and siteSchema are added to page for schemaGenerator()
23
+ previewResponse.page.siteInfo = pageContext.siteInfo;
24
+ previewResponse.page.siteSchema = pageContext.siteSchema;
25
+ }
26
+ setPreviewContext(previewResponse);
27
+ setIsLoading(false);
28
+ });
29
+ }
30
+
31
+ useEffect(() => {
32
+ if (isPreview) {
33
+ setIsLoading(true);
34
+ const searchParams =
35
+ typeof window !== 'undefined' ? new URLSearchParams(window.location.search) : null;
36
+ if (!searchParams.get('path')) {
37
+ window.location = `${window.location.origin}/preview?path=/`;
38
+ }
39
+ getData(searchParams);
40
+ globalHistory.listen(({ location }) => {
41
+ setIsLoading(true);
42
+
43
+ getData(null, location.search.replace('?path=', ''));
44
+ });
45
+ }
46
+ // eslint-disable-next-line react-hooks/exhaustive-deps
47
+ }, []);
48
+
49
+ if (isPreview) {
50
+ if (isLoading) {
51
+ return 'Loading...';
52
+ }
53
+ }
54
+
55
+ return (
56
+ <>
57
+ <TranslationsProvider value={{ translations }}>
58
+ <Head
59
+ page={isPreview ? previewContext.page : pageContext.page}
60
+ siteInfo={isPreview ? previewContext.siteInfo : pageContext.siteInfo}
61
+ />
62
+ <Body pageContext={isPreview ? previewContext : pageContext} serverData={serverData} />
63
+ </TranslationsProvider>
64
+ </>
65
+ );
66
+ };
67
+
68
+ AppSSR.propTypes = {
69
+ pageContext: PropTypes.shape({
70
+ siteName: PropTypes.string,
71
+ isTracker: PropTypes.bool,
72
+ isPreview: PropTypes.bool,
73
+ page: PropTypes.shape({
74
+ id: PropTypes.number,
75
+ path: PropTypes.string,
76
+ }),
77
+ translations: PropTypes.object,
78
+ siteInfo: PropTypes.shape({
79
+ robots_txt: PropTypes.string,
80
+ site_logo: PropTypes.string,
81
+ site_name: PropTypes.string,
82
+ }),
83
+ siteSchema: PropTypes.shape({
84
+ site_name: PropTypes.string,
85
+ }),
86
+ }),
87
+ serverData: PropTypes.shape({
88
+ props: PropTypes.string,
89
+ }),
90
+ };
91
+
92
+ export async function getServerData({ pageContext, url }) {
93
+ let res = '';
94
+ res = await getAPIData(pageContext.page, url);
95
+ return res;
96
+ }
97
+ export default AppSSR;
@@ -55,10 +55,6 @@ const App = ({ pageContext }) => {
55
55
 
56
56
  const TrackerContent = isTracker ? loadable(() => import(`~pages/tracker`)) : null;
57
57
 
58
- if (pageContext.siteInfo?.site_name === 'playcasino.co.za') {
59
- translations.play_now = 'Play now';
60
- }
61
-
62
58
  return isTracker ? (
63
59
  <>
64
60
  <Head page={pageContext.page} siteInfo={pageContext.siteInfo} />
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
9
9
  import { translate, imagePrettyUrl, getAltText } from '~helpers/getters';
10
10
  import styles from './author-box.module.scss';
11
11
  import LazyImage from '~hooks/lazy-image';
12
- import Link from '~hooks/link';
12
+ import Button from '~atoms/button';
13
13
  import { Context } from '~context/TranslationsProvider';
14
14
 
15
15
  export default function AuthorBox({ author, preElement = null }) {
@@ -35,72 +35,77 @@ export default function AuthorBox({ author, preElement = null }) {
35
35
  />
36
36
  )}
37
37
  <span className={styles.name}>{author.name}</span>
38
- <p className={styles.title}>{author.author_title}</p>
38
+ {author.author_title && <p className={styles.title}>{author.author_title}</p>}
39
39
  </div>
40
40
  <div className={styles.description}>
41
41
  <div className={styles.links}>
42
- <p className={styles.contactLinks}>
43
- {author.email_address && (
44
- <a
45
- href={`mailto:${author.email_address}`}
46
- className="author-gtm"
47
- target="_blank"
48
- rel="nofollow noreferrer"
49
- >
50
- {translate(translations, 'email', 'Email')}
51
- </a>
52
- )}
53
- {author.personal_website && (
54
- <a
55
- href={author.personal_website}
56
- className="author-gtm"
57
- target="_blank"
58
- rel="nofollow noreferrer"
59
- >
60
- {translate(translations, 'website', 'Website')}
61
- </a>
62
- )}
63
- {author.additional_url && (
64
- <a
65
- href={author.additional_url}
66
- className="author-gtm"
67
- target="_blank"
68
- rel="nofollow noreferrer"
69
- >
70
- {translate(translations, 'contact', 'Contact')}
71
- </a>
72
- )}
73
- </p>
74
- <p className={styles.socialIcons}>
75
- {socialLinks
76
- .filter((socialLink) => socialLink.link)
77
- .map((filteredLinks) => (
78
- // eslint-disable-next-line jsx-a11y/control-has-associated-label
42
+ {(author.email_address || author.personal_website || author.additional_url) && (
43
+ <p className={styles.contactLinks}>
44
+ {author.email_address && (
79
45
  <a
80
- href={filteredLinks.link}
46
+ href={`mailto:${author.email_address}`}
81
47
  className="author-gtm"
82
48
  target="_blank"
83
49
  rel="nofollow noreferrer"
84
- key={`author-box-link-${filteredLinks.id}`}
85
- aria-label={`${filteredLinks.id} Link`}
86
50
  >
87
- {filteredLinks.icon}
51
+ {translate(translations, 'email', 'Email')}
88
52
  </a>
89
- ))}
90
- </p>
53
+ )}
54
+ {author.personal_website && (
55
+ <a
56
+ href={author.personal_website}
57
+ className="author-gtm"
58
+ target="_blank"
59
+ rel="nofollow noreferrer"
60
+ >
61
+ {translate(translations, 'website', 'Website')}
62
+ </a>
63
+ )}
64
+ {author.additional_url && (
65
+ <a
66
+ href={author.additional_url}
67
+ className="author-gtm"
68
+ target="_blank"
69
+ rel="nofollow noreferrer"
70
+ >
71
+ {translate(translations, 'contact', 'Contact')}
72
+ </a>
73
+ )}
74
+ </p>
75
+ )}
76
+ {socialLinks.length > 0 && (
77
+ <p className={styles.socialIcons}>
78
+ {socialLinks
79
+ .filter((socialLink) => socialLink.link)
80
+ .map((filteredLinks) => (
81
+ // eslint-disable-next-line jsx-a11y/control-has-associated-label
82
+ <a
83
+ href={filteredLinks.link}
84
+ className="author-gtm"
85
+ target="_blank"
86
+ rel="nofollow noreferrer"
87
+ key={`author-box-link-${filteredLinks.id}`}
88
+ aria-label={`${filteredLinks.id} Link`}
89
+ >
90
+ {filteredLinks.icon}
91
+ </a>
92
+ ))}
93
+ </p>
94
+ )}
91
95
  <div
92
96
  className={styles.biography}
93
97
  dangerouslySetInnerHTML={{ __html: author.biography }}
94
98
  />
95
99
  </div>
96
100
  {author.profile_page_path && (
97
- <Link
101
+ <Button
102
+ primaryColor={false}
98
103
  to={author.profile_page_path}
99
- title="Read More"
104
+ btnText="Read More"
100
105
  className={`${styles.button} author-gtm`}
101
106
  >
102
107
  {translate(translations, 'read_more', 'Read More')}
103
- </Link>
108
+ </Button>
104
109
  )}
105
110
  </div>
106
111
  </div>
@@ -18,6 +18,7 @@ function Button({
18
18
  disabled = false,
19
19
  tertiary = false,
20
20
  noStyle = false,
21
+ icon = null,
21
22
  gtmClass = '',
22
23
  }) {
23
24
  const classes = `${styles.ctaBtn} ${primaryColor ? styles.primary : styles.secondary} ${
@@ -37,6 +38,7 @@ function Button({
37
38
  disabled={disabled}
38
39
  >
39
40
  {btnText}
41
+ {icon && icon}
40
42
  </button>
41
43
  );
42
44
  }
@@ -45,6 +47,7 @@ function Button({
45
47
  return (
46
48
  <Link className={`${classes} ${gtmClass}`} to={to} title={btnTitle} aria-label={btnTitle}>
47
49
  {btnText}
50
+ {icon && icon}
48
51
  </Link>
49
52
  );
50
53
  }
@@ -60,12 +63,14 @@ function Button({
60
63
  rel="nofollow noreferrer"
61
64
  >
62
65
  {btnText}
66
+ {icon && icon}
63
67
  </a>
64
68
  );
65
69
  }
66
70
 
67
71
  Button.propTypes = {
68
72
  to: PropTypes.string,
73
+ icon: PropTypes.func,
69
74
  btnText: PropTypes.oneOfType([PropTypes.string, PropTypes.any]),
70
75
  primaryColor: PropTypes.bool,
71
76
  invertColors: PropTypes.bool,
@@ -5,7 +5,7 @@ import Module from '~molecules/module';
5
5
  import styles from './main.module.scss';
6
6
  import keygen from '~helpers/keygen';
7
7
 
8
- const Main = ({ section = {}, pageContext = {} }) => {
8
+ const Main = ({ section = {}, pageContext = {}, serverData = {} }) => {
9
9
  const { page } = pageContext;
10
10
  const SearchPage = page.path === 's' ? loadable(() => import(`~pages/search`)) : null;
11
11
  const HtmlSitemap = page.path === 'sitemap' ? loadable(() => import(`~atoms/sitemap`)) : null;
@@ -18,7 +18,13 @@ const Main = ({ section = {}, pageContext = {} }) => {
18
18
  {HtmlSitemap && <HtmlSitemap pageContext={pageContext} />}
19
19
  {section.modules &&
20
20
  section.modules.map((module) => (
21
- <Module key={keygen()} module={module} page={page} pageContext={pageContext} />
21
+ <Module
22
+ key={keygen()}
23
+ module={module}
24
+ page={page}
25
+ pageContext={pageContext}
26
+ serverData={serverData}
27
+ />
22
28
  ))}
23
29
  {AuthorBox && <AuthorBox author={page.author} />}
24
30
  {SearchPage && <SearchPage page={page} />}
@@ -38,6 +44,7 @@ Main.propTypes = {
38
44
  path: PropTypes.string,
39
45
  }),
40
46
  pageContext: PropTypes.shape({}),
47
+ serverData: PropTypes.shape({}),
41
48
  };
42
49
 
43
50
  export default Main;
@@ -10,7 +10,7 @@ import Navigation from '~organisms/navigation';
10
10
  import ScrollToTop from '~atoms/scroll-to-top';
11
11
  import CookieConsent from '~organisms/cookie-consent';
12
12
 
13
- function Body({ pageContext, children }) {
13
+ function Body({ pageContext, children, serverData }) {
14
14
  const getBodySection = (name) => getSection(name, pageContext);
15
15
  const { template } = pageContext.page;
16
16
  const is404 = pageContext?.page?.path?.includes('404');
@@ -41,8 +41,10 @@ function Body({ pageContext, children }) {
41
41
  return (
42
42
  <>
43
43
  {navigation && <Navigation template={template} section={navigation} />}
44
- {!is404 && <Header section={pageContext} />}
45
- {main && !children && <Main section={main} pageContext={pageContext} />}
44
+ {!is404 && <Header serverData={serverData} section={pageContext} />}
45
+ {main && !children && (
46
+ <Main serverData={serverData} section={main} pageContext={pageContext} />
47
+ )}
46
48
  {children && <main>{children}</main>}
47
49
  <ScrollToTop />
48
50
  <Footer template={template} section={footer} />
@@ -53,6 +55,8 @@ function Body({ pageContext, children }) {
53
55
 
54
56
  Body.propTypes = {
55
57
  children: PropTypes.element,
58
+ // eslint-disable-next-line react/forbid-prop-types
59
+ serverData: PropTypes.shape({}),
56
60
  pageContext: PropTypes.shape({
57
61
  page: PropTypes.shape({
58
62
  id: PropTypes.number,
@@ -25,7 +25,7 @@ const Tracker = ({
25
25
  }) => {
26
26
  const { operator } = pageContext;
27
27
 
28
- const trackerLinks = Object.keys(operator.links);
28
+ const trackerLinks = operator ? Object.keys(operator.links) : [];
29
29
 
30
30
  let tracker = '';
31
31
  for (let i = 0; i < trackerLinks.length; i += 1) {
@@ -42,7 +42,12 @@ export function processSitemapPages(pages, markets) {
42
42
  Object.keys(pages[market]).forEach((pageType) => {
43
43
  const filteredPages = pages[market][pageType].filter((page) => {
44
44
  if (page.type === 'event') {
45
- return page.relation.event && page.robot_options && page.robot_options.page_index === 1;
45
+ return (
46
+ page.relation &&
47
+ page.relation.event &&
48
+ page.robot_options &&
49
+ page.robot_options.page_index === 1
50
+ );
46
51
  }
47
52
  return page.robot_options && page.robot_options.page_index === 1;
48
53
  });
@@ -218,7 +223,7 @@ export default {
218
223
  }
219
224
  });
220
225
 
221
- rageSportType = ['rage_seo', 'rage_ppc'].includes(data.general.type);
226
+ rageSportType = ['rage_seo', 'rage_ppc', 'sports'].includes(data.general.type);
222
227
  themeType = data.general.type ? data.general.type : null;
223
228
 
224
229
  const searchEnabled =
@@ -117,7 +117,7 @@ export function addSportsDataToPage(sportsData, page, themeType) {
117
117
  relation.schedule = sportsData.schedule;
118
118
  }
119
119
  // rage-seo pages data
120
- if (themeType === 'rage_seo') {
120
+ if (themeType === 'rage_seo' || themeType === 'sports') {
121
121
  if (pageType === 'homepage') {
122
122
  relation.schedule = sportsData.schedule.soccer || null;
123
123
  relation.featured_events = sportsData.featured_events.soccer || null;
@@ -0,0 +1,8 @@
1
+ /* eslint-disable import/prefer-default-export */
2
+ export async function getAPIData() {
3
+ const res = await fetch(`https://random-data-api.com/api/appliance/random_appliance/`);
4
+ const data = await res.json();
5
+ return {
6
+ props: data.equipment,
7
+ };
8
+ }