gatsby-core-theme 22.0.11 → 22.0.12

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,14 @@
1
+ ## [22.0.12](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v22.0.11...v22.0.12) (2023-06-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 404 bug ([d31e875](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/d31e87550db9791ff19c265821ebcbdf72728a06))
7
+ * 404 pages for multiple markets ([06621e2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/06621e281677788cdfd6f8766ad05e0854135ae4))
8
+
9
+
10
+ * Merge branch 'tm-3524-404-pages-fix' into 'master' ([0f00d4a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/0f00d4a75b0b069780a5670f7d1eddb3e1c1d71d))
11
+
1
12
  ## [22.0.11](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v22.0.10...v22.0.11) (2023-06-14)
2
13
 
3
14
 
@@ -26,7 +26,9 @@ let marketSections = [];
26
26
  let prefilledModules = [];
27
27
  let siteInfo = null;
28
28
  let operators = null;
29
+ let allMarkets = null;
29
30
  let translations = null;
31
+ let allTranslations = null;
30
32
  let languageKey = null;
31
33
  let context404 = null;
32
34
  let sports = null;
@@ -185,6 +187,8 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
185
187
  // eslint-disable-next-line prefer-destructuring
186
188
  languageKey = Object.keys(processed.relations.translations)[0];
187
189
  translations = processed.relations.translations[languageKey];
190
+ allTranslations = processed.relations.translations;
191
+ allMarkets = processed.site_markets;
188
192
  htmlSitemapPages = processSitemapPages(pages, processed.site_markets);
189
193
 
190
194
  if (['rage_seo', 'rage_ppc', 'sports'].includes(response.general.type)) {
@@ -220,7 +224,7 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
220
224
  processed.pages[siteMarket][pageType].forEach((page) => {
221
225
  marketSections = processed.market_sections[siteMarket];
222
226
  prefilledModules = processed.prefilled_market_modules[siteMarket];
223
- const allMarkets = processed.site_markets;
227
+
224
228
  const processedPage = page;
225
229
  processedPage.preconnect_links = preconnectLinks;
226
230
 
@@ -429,9 +433,32 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
429
433
  };
430
434
 
431
435
  exports.onCreatePage = ({ page, actions }) => {
432
- const { createPage } = actions;
436
+ const { createPage, deletePage } = actions;
437
+
438
+ if (page.path.match(/^\/[a-z]{2}\/404\/$/)) {
439
+ const oldPage = { ...page };
440
+ const langCode = page.path.split(`/`)[1];
441
+ page.matchPath = `/${langCode}/*`;
433
442
 
434
- if (page.path.includes('404')) {
443
+ const marketCode = Object.keys(allMarkets).find(
444
+ (key) => allMarkets[key].path_prefix === langCode
445
+ );
446
+
447
+ if (marketCode) {
448
+ // Recreate the modified page
449
+ deletePage(oldPage);
450
+ createPage({
451
+ ...page,
452
+ context: {
453
+ ...context404,
454
+ page: { ...context404.page, market: marketCode },
455
+ translations: allTranslations[langCode],
456
+ },
457
+ });
458
+ } else {
459
+ deletePage(oldPage);
460
+ }
461
+ } else if (page.path.includes('404')) {
435
462
  createPage({
436
463
  path: page.path,
437
464
  component: require.resolve('./src/components/app.js'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "22.0.11",
3
+ "version": "22.0.12",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -1,14 +1,24 @@
1
1
  /* eslint-disable react/no-unescaped-entities */
2
- import React from 'react';
2
+ import React, { useContext } from 'react';
3
+ import { Context } from 'gatsby-core-theme/src/context/MainProvider';
3
4
  import styles from './not-found.module.scss';
5
+ import { translate } from '~helpers/getters';
4
6
 
5
- const NotFound = () => (
6
- <div className={styles.wrapper || ''}>
7
- <div className={styles.textBlock || ''}>
8
- <p>Oops! We can't seem to find that page anymore.</p>
9
- <p>While you're here though, why not check out these top South African Casinos:</p>
7
+ const NotFound = () => {
8
+ const { translations } = useContext(Context) || {};
9
+
10
+ return (
11
+ <div className={styles.wrapper || ''}>
12
+ <h2>{translate(translations, 'main_404_title', 'Oops, Something Went Wrong.')}</h2>
13
+ <div className={styles.textBlock || ''}>
14
+ {translate(
15
+ translations,
16
+ 'second_404_title',
17
+ 'It seems the page you are looking for does not exist. Try these useful links:'
18
+ )}
19
+ </div>
10
20
  </div>
11
- </div>
12
- );
21
+ );
22
+ };
13
23
 
14
24
  export default NotFound;
@@ -1,13 +1,10 @@
1
1
  .wrapper {
2
- display: flex;
2
+ @include flex-align(center, center);
3
+ flex-direction: column;
3
4
  grid-area: main;
4
5
  padding: 0 2.4rem;
5
6
  margin-top: 8rem;
6
7
 
7
- @include min(laptop){
8
- margin-top: 0;
9
- }
10
-
11
8
  .textBlock{
12
9
  @include min(tablet){
13
10
  max-width: 60%;
@@ -14,7 +14,7 @@ const Main = ({ section = {}, pageContext = {}, serverData = {}, exclOperator =
14
14
 
15
15
  return (
16
16
  <main className={styles.modulePage || ''}>
17
- {NotFound && <NotFound />}
17
+ {NotFound && <NotFound pageContext={pageContext} />}
18
18
  {HtmlSitemap && <HtmlSitemap pageContext={pageContext} />}
19
19
  {section.modules &&
20
20
  section.modules.map((module) => (
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ import App from 'gatsby-core-theme/src/components/app';
5
+
6
+ const PageNotFound = ({ pageContext }) => <App pageContext={pageContext} />;
7
+
8
+ PageNotFound.propTypes = {
9
+ pageContext: PropTypes.shape({
10
+ page: PropTypes.shape({
11
+ path: PropTypes.string,
12
+ }),
13
+ }).isRequired,
14
+ };
15
+
16
+ export default PageNotFound;