gatsby-core-theme 1.6.10 → 1.6.11

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,21 @@
1
+ ## [1.6.11](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.6.10...v1.6.11) (2021-11-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 404 ([2355a82](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2355a8216c6431f34bac5f6cc8dd5302446fb0f4))
7
+ * helmet ([6299dc5](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6299dc536bcf7d3fac7ab89326fd0c6b42a692c9))
8
+ * helmet ([2a05f83](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2a05f83042de1490a64f5606052104d59dfb6768))
9
+ * preview ([5153a58](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/5153a581700032ddad095e6a6e9593df8ac8dc8b))
10
+ * preview func ([16bb0dc](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/16bb0dca646eb50da48ad98a09fe9d5022757177))
11
+ * tracker pages ([07c6e3c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/07c6e3c7d86190d82989ff270364a7ba940950c2))
12
+ * tracker pages ([6defb88](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6defb88aeac9d9f71051e8c9f739dc4b8d41f80d))
13
+ * tracker pages ([a61f2a8](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a61f2a8db973fd5ba8098171e554883ac502e0a5))
14
+ * tracker pages ([e68afc4](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/e68afc4321955393f58da1dc7cb079dfc9383db1))
15
+
16
+
17
+ * Merge branch 'master' of git.ilcd.rocks:team-floyd/themes/gatsby-themes ([7ffdc47](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7ffdc47fcc468429cd2ac02e482d53aa558e7c97))
18
+
1
19
  ## [1.6.10](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.6.9...v1.6.10) (2021-11-25)
2
20
 
3
21
 
@@ -243,19 +243,26 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
243
243
  } else {
244
244
  createPage({
245
245
  path: page.path.charAt(0) === '/' ? page.path : `/${page.path}`,
246
- component: require.resolve(
247
- page.path === 'preview'
248
- ? './src/components/app-preview.js'
249
- : './src/components/app.js'
250
- ),
246
+ component: require.resolve('./src/components/app.js'),
251
247
  context: {
252
248
  ...contextData,
253
249
  siteSchema,
254
250
  translations,
251
+ isPreview: page.path === 'preview',
255
252
  },
256
253
  });
257
254
  }
258
255
 
256
+ const trackerPageObject = {
257
+ meta_title: 'Tracker',
258
+ template: 'tracker',
259
+ title: 'Tracker',
260
+ type: 'page',
261
+ language: languageKey,
262
+ path: '',
263
+ meta_robots: ['noindex', 'nofollow'],
264
+ };
265
+
259
266
  // Operator tracker pages
260
267
  if (page.type === 'operator') {
261
268
  const operator = operators[page.relation_id];
@@ -265,10 +272,11 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
265
272
  );
266
273
  tracker.forEach((trackerPath) => {
267
274
  // Create splash page
275
+ trackerPageObject['path'] = trackerPath;
268
276
  createPage({
269
277
  path: trackerPath,
270
- component: require.resolve('./src/components/pages/tracker/'),
271
- context: { operator },
278
+ component: require.resolve('./src/components/app.js'),
279
+ context: { page: trackerPageObject, operator, isTracker: true },
272
280
  });
273
281
  });
274
282
  }
@@ -288,7 +296,7 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
288
296
  providerData.forEach((provider) => {
289
297
  createPage({
290
298
  path: provider.tracker,
291
- component: require.resolve('./src/components/pages/tracker/'),
299
+ component: require.resolve('./src/components/app.js'),
292
300
  context: {
293
301
  provider: provider.providerObject,
294
302
  },
@@ -307,7 +315,7 @@ exports.onCreatePage = ({ page, actions }) => {
307
315
  if (page.path.includes('404')) {
308
316
  createPage({
309
317
  path: page.path,
310
- component: require.resolve('./src/pages/404/'),
318
+ component: require.resolve('./src/components/app.js'),
311
319
  context: context404,
312
320
  });
313
321
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "1.6.10",
3
+ "version": "1.6.11",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -1,15 +1,28 @@
1
+ /* eslint-disable no-unused-vars */
1
2
  import React, { useEffect, useState } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import { globalHistory } from '@reach/router';
4
5
 
5
- import Body from '~pages/body';
6
- import Head from '~organisms/head';
7
- import { getPreview } from '~helpers/api';
6
+ // import Body from '~pages/body';
7
+ // import Head from '~organisms/head';
8
+ // import { getPreview } from '~helpers/api';
8
9
 
9
10
  const AppPreview = ({ pageContext }) => {
10
11
  const [previewContext, setPreviewContext] = useState({});
11
12
  const [isLoading, setIsLoading] = useState({});
12
13
 
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
+ setPreviewContext(previewResponse);
22
+ setIsLoading(false);
23
+ });
24
+ }
25
+
13
26
  useEffect(() => {
14
27
  setIsLoading(true);
15
28
  const searchParams =
@@ -17,23 +30,28 @@ const AppPreview = ({ pageContext }) => {
17
30
  if (!searchParams.get('path')) {
18
31
  window.location = `${window.location.origin}/preview?path=/`;
19
32
  }
20
- getPreview(pageContext.siteName, searchParams.get('path') || '/', pageContext).then(
21
- (previewResponse) => {
22
- setPreviewContext(previewResponse);
23
- setIsLoading(false);
24
- }
25
- );
33
+
34
+ getData(searchParams);
35
+ // let { hi, bye } = await import('./say.js');
36
+ // getPreview(pageContext.siteName, searchParams.get('path') || '/', pageContext).then(
37
+ // (previewResponse) => {
38
+ // setPreviewContext(previewResponse);
39
+ // setIsLoading(false);
40
+ // }
41
+ // );
26
42
 
27
43
  globalHistory.listen(({ location }) => {
28
44
  setIsLoading(true);
29
- getPreview(pageContext.siteName, location.search.replace('?path=', ''), pageContext)
30
- .then((previewResponse) => {
31
- setPreviewContext(previewResponse);
32
- setIsLoading(false);
33
- })
34
- .catch(() => {
35
- alert('failed to load..');
36
- });
45
+
46
+ getData(null, location.search.replace('?path=', ''));
47
+ // getPreview(pageContext.siteName, location.search.replace('?path=', ''), pageContext)
48
+ // .then((previewResponse) => {
49
+ // setPreviewContext(previewResponse);
50
+ // setIsLoading(false);
51
+ // })
52
+ // .catch(() => {
53
+ // alert('failed to load..');
54
+ // });
37
55
  });
38
56
  // eslint-disable-next-line
39
57
  }, [pageContext.siteName]);
@@ -44,8 +62,8 @@ const AppPreview = ({ pageContext }) => {
44
62
 
45
63
  return (
46
64
  <>
47
- <Head page={previewContext.page} siteInfo={previewContext.siteInfo} />
48
- <Body pageContext={previewContext} />
65
+ {/* <Head page={previewContext.page} siteInfo={previewContext.siteInfo} />
66
+ <Body pageContext={previewContext} /> */}
49
67
  </>
50
68
  );
51
69
  };
@@ -1,24 +1,95 @@
1
1
  /* eslint-disable react/forbid-prop-types */
2
- import React from 'react';
2
+ import React, { useEffect, useState } from 'react';
3
3
  import PropTypes from 'prop-types';
4
+ import loadable from '@loadable/component';
5
+ import { globalHistory } from '@reach/router';
4
6
  import TranslationsProvider from '~context/TranslationsProvider';
5
7
  import Body from '~pages/body';
6
8
  import Head from '~organisms/head';
7
9
 
8
10
  const App = ({ pageContext }) => {
9
- const { translations } = pageContext;
10
- return (
11
- <TranslationsProvider value={{ translations }}>
11
+ const { translations, isTracker, isPreview } = pageContext;
12
+ const [previewContext, setPreviewContext] = useState({});
13
+ const [isLoading, setIsLoading] = useState({});
14
+
15
+ async function getData(searchParams, staticPath = null) {
16
+ const { getPreview } = await import('~helpers/api');
17
+ getPreview(
18
+ pageContext.siteName,
19
+ !staticPath ? searchParams.get('path') || '/' : staticPath,
20
+ pageContext
21
+ ).then((previewResponse) => {
22
+ setPreviewContext(previewResponse);
23
+ setIsLoading(false);
24
+ });
25
+ }
26
+
27
+ useEffect(() => {
28
+ if (isPreview) {
29
+ setIsLoading(true);
30
+ const searchParams =
31
+ typeof window !== 'undefined' ? new URLSearchParams(window.location.search) : null;
32
+ if (!searchParams.get('path')) {
33
+ window.location = `${window.location.origin}/preview?path=/`;
34
+ }
35
+ getData(searchParams);
36
+ // let { hi, bye } = await import('./say.js');
37
+ // getPreview(pageContext.siteName, searchParams.get('path') || '/', pageContext).then(
38
+ // (previewResponse) => {
39
+ // setPreviewContext(previewResponse);
40
+ // setIsLoading(false);
41
+ // }
42
+ // );
43
+
44
+ globalHistory.listen(({ location }) => {
45
+ setIsLoading(true);
46
+
47
+ getData(null, location.search.replace('?path=', ''));
48
+ // getPreview(pageContext.siteName, location.search.replace('?path=', ''), pageContext)
49
+ // .then((previewResponse) => {
50
+ // setPreviewContext(previewResponse);
51
+ // setIsLoading(false);
52
+ // })
53
+ // .catch(() => {
54
+ // alert('failed to load..');
55
+ // });
56
+ });
57
+ }
58
+ // eslint-disable-next-line react-hooks/exhaustive-deps
59
+ }, []);
60
+
61
+ if (isPreview) {
62
+ if (isLoading) {
63
+ return 'Loading...';
64
+ }
65
+ }
66
+
67
+ const TrackerContent = isTracker ? loadable(() => import(`~pages/tracker`)) : null;
68
+
69
+ return isTracker ? (
70
+ <>
12
71
  <Head page={pageContext.page} siteInfo={pageContext.siteInfo} />
13
- <Body pageContext={pageContext} />
72
+ <TrackerContent pageContext={pageContext} path={pageContext.page.path} />
73
+ </>
74
+ ) : (
75
+ <TranslationsProvider value={{ translations }}>
76
+ <Head
77
+ page={isPreview ? previewContext.page : pageContext.page}
78
+ siteInfo={isPreview ? previewContext.siteInfo : pageContext.siteInfo}
79
+ />
80
+ <Body pageContext={isPreview ? previewContext : pageContext} />
14
81
  </TranslationsProvider>
15
82
  );
16
83
  };
17
84
 
18
85
  App.propTypes = {
19
86
  pageContext: PropTypes.shape({
87
+ siteName: PropTypes.string,
88
+ isTracker: PropTypes.bool,
89
+ isPreview: PropTypes.bool,
20
90
  page: PropTypes.shape({
21
91
  id: PropTypes.number,
92
+ path: PropTypes.string,
22
93
  }),
23
94
  translations: PropTypes.object,
24
95
  siteInfo: PropTypes.shape({
@@ -1,6 +1,5 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { Helmet } from 'react-helmet';
4
3
  import Button from '~atoms/button';
5
4
  import LazyImage from '~hooks/lazy-image';
6
5
  import { prettyTracker } from '~helpers/getters';
@@ -52,9 +51,9 @@ const Tracker = ({
52
51
  }
53
52
 
54
53
  function redirect() {
55
- if (typeof window !== 'undefined' && !isStory) {
56
- window.location.replace(tracker);
57
- }
54
+ // if (typeof window !== 'undefined' && !isStory) {
55
+ // window.location.replace(tracker);
56
+ // }
58
57
  }
59
58
 
60
59
  function manualRedirect(e) {
@@ -91,9 +90,6 @@ const Tracker = ({
91
90
  <>
92
91
  {showSplashScreen && !isMobile && (
93
92
  <>
94
- <Helmet>
95
- <meta name="robots" content="noindex,nofollow" />
96
- </Helmet>
97
93
  <div className={styles.container}>
98
94
  {background}
99
95
  <div className={styles.content}>