gatsby-theme-q3 3.1.4 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/CHANGELOG.md +74 -35
  2. package/gatsby-browser.js +29 -0
  3. package/gatsby-config.js +7 -47
  4. package/gatsby-node.js +0 -1
  5. package/lib/components/PageWrapper.js +2 -11
  6. package/lib/components/PublicTemplate.js +125 -6
  7. package/lib/components/PublicTemplateBackground.js +120 -0
  8. package/lib/components/SearchEngine.js +67 -20
  9. package/lib/components/Wrapper.js +3 -25
  10. package/lib/components/__tests__/SearchEngine.test.js +41 -0
  11. package/lib/components/useSiteMetaData.js +13 -12
  12. package/lib/components/withPublicTemplate.js +17 -0
  13. package/lib/components/withSuccessOp.js +1 -1
  14. package/lib/pages/login.js +5 -3
  15. package/lib/pages/password-change.js +4 -3
  16. package/lib/pages/password-reset.js +4 -3
  17. package/lib/pages/reverify.js +5 -2
  18. package/lib/pages/verify.js +5 -3
  19. package/package.json +6 -6
  20. package/src/components/PageWrapper.jsx +1 -13
  21. package/src/components/PublicTemplate.jsx +129 -5
  22. package/src/components/PublicTemplateBackground.jsx +140 -0
  23. package/src/components/SearchEngine.jsx +82 -23
  24. package/src/components/Wrapper.jsx +3 -27
  25. package/src/components/__tests__/SearchEngine.test.jsx +58 -0
  26. package/src/components/useSiteMetaData.js +17 -16
  27. package/src/components/withPublicTemplate.jsx +11 -0
  28. package/src/components/withSuccessOp.jsx +1 -1
  29. package/src/pages/login.jsx +51 -43
  30. package/src/pages/password-change.jsx +5 -3
  31. package/src/pages/password-reset.jsx +5 -3
  32. package/src/pages/reverify.jsx +4 -2
  33. package/src/pages/verify.jsx +9 -12
  34. package/__tests__/config.int.test.js +0 -73
  35. package/helpers/__tests__/loadContent.unit.test.js +0 -13
  36. package/helpers/__tests__/pagination.unit.test.js +0 -139
  37. package/helpers/__tests__/slug.unit.test.js +0 -21
  38. package/helpers/archive.js +0 -42
  39. package/helpers/index.js +0 -19
  40. package/helpers/loadContent.js +0 -45
  41. package/helpers/loadTheme.js +0 -10
  42. package/helpers/pagination.js +0 -109
  43. package/helpers/setup.js +0 -60
  44. package/helpers/slug.js +0 -31
  45. package/helpers/slugType.js +0 -24
  46. package/lib/components/LocaleBundles.js +0 -42
  47. package/lib/components/useLocale.js +0 -31
  48. package/src/components/LocaleBundles.jsx +0 -37
  49. package/src/components/useLocale.js +0 -20
package/CHANGELOG.md CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [3.1.4](https://github.com/3merge/q/compare/v3.1.3...v3.1.4) (2022-02-01)
6
+ ## [3.2.2](https://github.com/3merge/q/compare/v3.2.1...v3.2.2) (2022-02-10)
7
7
 
8
8
  **Note:** Version bump only for package gatsby-theme-q3
9
9
 
@@ -11,58 +11,97 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
11
11
 
12
12
 
13
13
 
14
- # [3.1.0](https://github.com/3merge/q/compare/v3.0.4...v3.1.0) (2022-01-31)
15
-
16
- **Note:** Version bump only for package gatsby-theme-q3
17
-
18
-
19
-
20
-
21
-
22
- ## [3.0.4](https://github.com/3merge/q/compare/v3.0.3...v3.0.4) (2022-01-29)
23
-
24
- **Note:** Version bump only for package gatsby-theme-q3
25
-
26
-
27
-
28
-
29
-
30
- ## [3.0.3](https://github.com/3merge/q/compare/v3.0.2...v3.0.3) (2022-01-29)
14
+ ## [3.2.1](https://github.com/3merge/q/compare/v3.2.0...v3.2.1) (2022-02-09)
31
15
 
32
16
 
33
17
  ### Bug Fixes
34
18
 
35
- * major release bugs ([#372](https://github.com/3merge/q/issues/372)) ([d3e0681](https://github.com/3merge/q/commit/d3e0681a8d9ce61558b3aeaabe94ce8bc326dfa7))
19
+ * misc domain issues ([17cb74b](https://github.com/3merge/q/commit/17cb74b927721f11b5fcd8f8a9a1a28a86867048))
36
20
 
37
21
 
38
22
 
39
23
 
40
24
 
41
- ## [3.0.2](https://github.com/3merge/q/compare/v3.0.1...v3.0.2) (2022-01-28)
42
-
43
- **Note:** Version bump only for package gatsby-theme-q3
25
+ # [3.2.0](https://github.com/3merge/q/compare/v3.1.5...v3.2.0) (2022-02-09)
44
26
 
45
27
 
28
+ ### Features
46
29
 
47
-
48
-
49
- ## [3.0.1](https://github.com/3merge/q/compare/v3.0.0...v3.0.1) (2022-01-28)
50
-
51
- **Note:** Version bump only for package gatsby-theme-q3
52
-
53
-
54
-
55
-
56
-
57
- # [3.0.0](https://github.com/3merge/q/compare/v2.3.13...v3.0.0) (2022-01-28)
58
-
59
- **Note:** Version bump only for package gatsby-theme-q3
30
+ * text locale editor ([#377](https://github.com/3merge/q/issues/377)) ([e827875](https://github.com/3merge/q/commit/e8278757be7505554376c1d1d78d9b8900fdf35e))
60
31
 
61
32
 
62
33
 
63
34
 
64
35
 
65
36
 
37
+ ## [3.1.5](https://github.com/3merge/q/compare/v3.1.4...v3.1.5) (2022-02-01)
38
+
39
+ **Note:** Version bump only for package gatsby-theme-q3
40
+
41
+
42
+
43
+
44
+
45
+ ## [3.1.4](https://github.com/3merge/q/compare/v3.1.3...v3.1.4) (2022-02-01)
46
+
47
+ **Note:** Version bump only for package gatsby-theme-q3
48
+
49
+
50
+
51
+
52
+
53
+ # [3.1.0](https://github.com/3merge/q/compare/v3.0.4...v3.1.0) (2022-01-31)
54
+
55
+ **Note:** Version bump only for package gatsby-theme-q3
56
+
57
+
58
+
59
+
60
+
61
+ ## [3.0.4](https://github.com/3merge/q/compare/v3.0.3...v3.0.4) (2022-01-29)
62
+
63
+ **Note:** Version bump only for package gatsby-theme-q3
64
+
65
+
66
+
67
+
68
+
69
+ ## [3.0.3](https://github.com/3merge/q/compare/v3.0.2...v3.0.3) (2022-01-29)
70
+
71
+
72
+ ### Bug Fixes
73
+
74
+ * major release bugs ([#372](https://github.com/3merge/q/issues/372)) ([d3e0681](https://github.com/3merge/q/commit/d3e0681a8d9ce61558b3aeaabe94ce8bc326dfa7))
75
+
76
+
77
+
78
+
79
+
80
+ ## [3.0.2](https://github.com/3merge/q/compare/v3.0.1...v3.0.2) (2022-01-28)
81
+
82
+ **Note:** Version bump only for package gatsby-theme-q3
83
+
84
+
85
+
86
+
87
+
88
+ ## [3.0.1](https://github.com/3merge/q/compare/v3.0.0...v3.0.1) (2022-01-28)
89
+
90
+ **Note:** Version bump only for package gatsby-theme-q3
91
+
92
+
93
+
94
+
95
+
96
+ # [3.0.0](https://github.com/3merge/q/compare/v2.3.13...v3.0.0) (2022-01-28)
97
+
98
+ **Note:** Version bump only for package gatsby-theme-q3
99
+
100
+
101
+
102
+
103
+
104
+
66
105
  ## [2.3.11](https://github.com/3merge/q/compare/v2.3.10...v2.3.11) (2022-01-18)
67
106
 
68
107
  **Note:** Version bump only for package gatsby-theme-q3
package/gatsby-browser.js CHANGED
@@ -1,4 +1,33 @@
1
+ import axios from 'axios';
2
+ import { last, size } from 'lodash';
3
+ import { getDomain } from 'q3-admin';
4
+ import { browser } from 'q3-ui-helpers';
5
+
1
6
  export {
2
7
  wrapPageElement,
3
8
  wrapRootElement,
4
9
  } from './gatsby-ssr';
10
+
11
+ export const onClientEntry = async () => {
12
+ if (!browser.isBrowserReady()) return;
13
+
14
+ // set api default root
15
+ axios.defaults.baseURL =
16
+ process.env.GATSBY_APP_BASE_URL ||
17
+ 'http://localhost:9000';
18
+
19
+ // set language default
20
+ axios.defaults.headers['Content-Language'] =
21
+ window.localStorage.getItem('q3-locale') || 'en';
22
+
23
+ // set tenant default
24
+ const { host } = window.location;
25
+ const parts = String(host).split('.').reverse();
26
+
27
+ if (size(parts) > 1)
28
+ axios.defaults.headers['X-Session-Tenant'] =
29
+ last(parts);
30
+
31
+ // calls Q3 API
32
+ await getDomain();
33
+ };
package/gatsby-config.js CHANGED
@@ -4,16 +4,7 @@ require('dotenv').config();
4
4
  const genKey = (url) =>
5
5
  String(url).includes('netlify') ? 'disallow' : 'allow';
6
6
 
7
- module.exports = ({
8
- contentfulSpaceID,
9
- contentfulAccessToken,
10
- siteUrl,
11
- title,
12
- brandingColor,
13
- icon,
14
- netlify,
15
- ...options
16
- }) => {
7
+ module.exports = (options) => {
17
8
  const plugins = [
18
9
  {
19
10
  resolve: 'gatsby-theme-q3-mui',
@@ -50,51 +41,20 @@ module.exports = ({
50
41
  },
51
42
  },
52
43
  },
53
- ];
54
-
55
- if (contentfulSpaceID) {
56
- if (!contentfulAccessToken)
57
- throw new Error('Contentful access token missing');
58
-
59
- plugins.push({
60
- resolve: 'gatsby-source-contentful',
61
- options: {
62
- spaceId: contentfulSpaceID,
63
- accessToken: contentfulAccessToken,
64
- },
65
- });
66
- }
67
-
68
- if (netlify)
69
- plugins.push({
44
+ {
70
45
  resolve: 'gatsby-plugin-netlify',
71
46
  options: {
72
47
  generateMatchPathRewrites: true,
73
48
  },
74
- });
75
-
76
- if (title && brandingColor)
77
- plugins.push({
78
- resolve: 'gatsby-plugin-manifest',
79
- options: {
80
- short_name: title,
81
- start_url: '/',
82
- background_color: '#FFF',
83
- theme_color: brandingColor,
84
- display: 'standalone',
85
- name: title,
86
- icon,
87
- },
88
- });
89
-
90
- if (siteUrl)
91
- plugins.push({
49
+ },
50
+ {
92
51
  resolve: 'gatsby-plugin-canonical-urls',
93
52
  options: {
94
53
  stripQueryString: true,
95
- siteUrl,
54
+ siteUrl: process.env.URL,
96
55
  },
97
- });
56
+ },
57
+ ];
98
58
 
99
59
  return {
100
60
  plugins,
package/gatsby-node.js CHANGED
@@ -70,7 +70,6 @@ exports.onCreatePage = async ({ page, actions }) => {
70
70
  createPage({
71
71
  ...page,
72
72
  context: {
73
- contentful_id: 'APP',
74
73
  to: '/app',
75
74
  },
76
75
  });
@@ -13,21 +13,12 @@ var _components = require("q3-admin/lib/components");
13
13
 
14
14
  var _SearchEngine = _interopRequireDefault(require("./SearchEngine"));
15
15
 
16
- var _useLocale = _interopRequireDefault(require("./useLocale"));
17
-
18
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
17
 
20
- // cannot conditionally call hooks otherwise
21
- const Locale = () => {
22
- (0, _useLocale.default)();
23
- return null;
24
- };
25
-
26
18
  const PageWrapper = ({
27
19
  children,
28
- includeLoader,
29
- includeLocale
30
- }) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_SearchEngine.default, null), includeLoader && /*#__PURE__*/_react.default.createElement(_components.Loader, null), includeLocale && /*#__PURE__*/_react.default.createElement(Locale, null), children);
20
+ includeLoader
21
+ }) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_SearchEngine.default, null), includeLoader && /*#__PURE__*/_react.default.createElement(_components.Loader, null), children);
31
22
 
32
23
  PageWrapper.defaultProps = {
33
24
  children: null,
@@ -9,7 +9,11 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _components = require("q3-admin/lib/components");
12
+ var _core = require("@material-ui/core");
13
+
14
+ var _gatsby = require("gatsby");
15
+
16
+ var _q3UiLocale = require("q3-ui-locale");
13
17
 
14
18
  var _AdminPublicGateway = _interopRequireDefault(require("./AdminPublicGateway"));
15
19
 
@@ -17,18 +21,133 @@ var _useSiteMetaData = _interopRequireDefault(require("./useSiteMetaData"));
17
21
 
18
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
23
 
24
+ const useStyle = (0, _core.makeStyles)(theme => ({
25
+ logo: {
26
+ height: 95,
27
+ width: 180,
28
+ display: 'block',
29
+ '& img': {
30
+ objectFit: 'contain',
31
+ height: '100%',
32
+ width: '100%'
33
+ }
34
+ },
35
+ container: {
36
+ maxWidth: '85vw',
37
+ width: 850,
38
+ [theme.breakpoints.down('md')]: {
39
+ width: '100%'
40
+ },
41
+ [theme.breakpoints.down('sm')]: {
42
+ width: 'auto'
43
+ }
44
+ },
45
+ photo: ({
46
+ photo
47
+ }) => ({
48
+ backgroundColor: theme.palette.secondary.light,
49
+ backgroundImage: `url(${photo})`,
50
+ backgroundSize: 'contain',
51
+ backgroundPosition: 'center',
52
+ backgroundRepeat: 'no-repeat',
53
+ width: '100%',
54
+ height: '100%'
55
+ })
56
+ }));
57
+
58
+ const Copyright = () => {
59
+ const {
60
+ brand
61
+ } = (0, _useSiteMetaData.default)();
62
+ return brand ? /*#__PURE__*/_react.default.createElement(_core.Box, {
63
+ display: "inline-block",
64
+ mx: 1
65
+ }, "\xA9", new Date().getFullYear(), " ", brand) : null;
66
+ }; // eslint-disable-next-line
67
+
68
+
69
+ const TextLink = ({
70
+ href,
71
+ text
72
+ }) => {
73
+ const {
74
+ t
75
+ } = (0, _q3UiLocale.useTranslation)('labels');
76
+ return href ? /*#__PURE__*/_react.default.createElement(_core.Box, {
77
+ display: "inline-block",
78
+ mx: 1
79
+ }, /*#__PURE__*/_react.default.createElement(_core.Link, {
80
+ href: href,
81
+ target: "_blank"
82
+ }, t(text)), ' ') : null;
83
+ };
84
+
20
85
  const PublicTemplate = ({
21
86
  children,
22
87
  ...rest
23
88
  }) => {
24
89
  const {
25
90
  brand,
26
- logo
91
+ cancellation,
92
+ logo,
93
+ terms,
94
+ privacy,
95
+ photo
27
96
  } = (0, _useSiteMetaData.default)();
28
- return /*#__PURE__*/_react.default.createElement(_AdminPublicGateway.default, rest, /*#__PURE__*/_react.default.createElement(_components.Public, {
29
- companyName: brand,
30
- logo: logo
31
- }, children));
97
+ const cls = useStyle({
98
+ photo
99
+ });
100
+ return /*#__PURE__*/_react.default.createElement(_AdminPublicGateway.default, rest, /*#__PURE__*/_react.default.createElement(_core.Box, {
101
+ alignItems: "center",
102
+ component: "article",
103
+ display: "flex",
104
+ flexDirection: "column",
105
+ justifyContent: "center",
106
+ width: "100%"
107
+ }, /*#__PURE__*/_react.default.createElement(_core.Box, {
108
+ component: "header",
109
+ mt: "2vh",
110
+ mb: 2,
111
+ textAlign: "center"
112
+ }, /*#__PURE__*/_react.default.createElement(_gatsby.Link, {
113
+ to: "/",
114
+ className: cls.logo
115
+ }, /*#__PURE__*/_react.default.createElement("img", {
116
+ alt: brand,
117
+ src: logo
118
+ }))), /*#__PURE__*/_react.default.createElement(_core.Paper, {
119
+ className: cls.container
120
+ }, /*#__PURE__*/_react.default.createElement(_core.Grid, {
121
+ container: true,
122
+ spacing: 1
123
+ }, /*#__PURE__*/_react.default.createElement(_core.Hidden, {
124
+ smDown: true
125
+ }, /*#__PURE__*/_react.default.createElement(_core.Grid, {
126
+ item: true,
127
+ xs: 6
128
+ }, /*#__PURE__*/_react.default.createElement(_core.Box, {
129
+ className: cls.photo
130
+ }))), /*#__PURE__*/_react.default.createElement(_core.Grid, {
131
+ item: true,
132
+ md: 6,
133
+ xs: 12
134
+ }, /*#__PURE__*/_react.default.createElement(_core.Box, {
135
+ p: 2
136
+ }, children)))), /*#__PURE__*/_react.default.createElement(_core.Box, {
137
+ maxWidth: "75vw",
138
+ component: "footer",
139
+ mt: 3,
140
+ textAlign: "center"
141
+ }, /*#__PURE__*/_react.default.createElement("small", null, /*#__PURE__*/_react.default.createElement(Copyright, null), /*#__PURE__*/_react.default.createElement(TextLink, {
142
+ href: terms,
143
+ text: "termsAndConditions"
144
+ }), /*#__PURE__*/_react.default.createElement(TextLink, {
145
+ href: privacy,
146
+ text: "privacyPolicy"
147
+ }), /*#__PURE__*/_react.default.createElement(TextLink, {
148
+ href: cancellation,
149
+ text: "cancellationPolicy"
150
+ })))));
32
151
  };
33
152
 
34
153
  PublicTemplate.defaultProps = {
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _core = require("@material-ui/core");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const PublicTemplateBackground = () => {
15
+ const theme = (0, _core.useTheme)();
16
+ return /*#__PURE__*/_react.default.createElement(_core.Box, {
17
+ position: "fixed",
18
+ top: 0,
19
+ right: 0,
20
+ left: 0,
21
+ bottom: 0,
22
+ overflow: "hidden"
23
+ }, /*#__PURE__*/_react.default.createElement(_core.Box, {
24
+ position: "fixed",
25
+ top: 0,
26
+ right: 0,
27
+ left: 0,
28
+ bottom: 0,
29
+ style: {
30
+ backgroundImage: 'url(https://images.unsplash.com/photo-1523293836414-f04e712e1f3b?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=703&q=80)',
31
+ opacity: 0.1
32
+ }
33
+ }), /*#__PURE__*/_react.default.createElement(_core.Box, {
34
+ position: "fixed",
35
+ top: 0,
36
+ right: 0,
37
+ left: 0,
38
+ bottom: 0,
39
+ style: {
40
+ background: `linear-gradient(90deg, ${theme.palette.secondary.dark} 0%, ${theme.palette.secondary.light} 35%, ${theme.palette.secondary.main} 100%)`,
41
+ opacity: 0.1
42
+ }
43
+ }), /*#__PURE__*/_react.default.createElement("svg", {
44
+ xmlns: "http://www.w3.org/2000/svg",
45
+ style: {
46
+ opacity: 0.15,
47
+ minHeight: '100vh',
48
+ minWidth: '100vw'
49
+ }
50
+ }, /*#__PURE__*/_react.default.createElement("defs", null, /*#__PURE__*/_react.default.createElement("linearGradient", {
51
+ id: "a",
52
+ x1: "0",
53
+ x2: "0",
54
+ y1: "1",
55
+ y2: "0"
56
+ }, /*#__PURE__*/_react.default.createElement("stop", {
57
+ offset: "0",
58
+ stopColor: theme.palette.background.muted
59
+ }), /*#__PURE__*/_react.default.createElement("stop", {
60
+ offset: "1",
61
+ stopColor: theme.palette.secondary.dark
62
+ })), /*#__PURE__*/_react.default.createElement("linearGradient", {
63
+ id: "b",
64
+ x1: "0",
65
+ x2: "0",
66
+ y1: "0",
67
+ y2: "1"
68
+ }, /*#__PURE__*/_react.default.createElement("stop", {
69
+ offset: "0",
70
+ stopColor: theme.palette.secondary.light
71
+ }), /*#__PURE__*/_react.default.createElement("stop", {
72
+ offset: "1",
73
+ stopColor: theme.palette.secondary.main
74
+ }))), /*#__PURE__*/_react.default.createElement("g", {
75
+ fill: theme.palette.background.muted,
76
+ fillOpacity: "0",
77
+ strokeMiterlimit: "10"
78
+ }, /*#__PURE__*/_react.default.createElement("g", {
79
+ stroke: "url(#a)",
80
+ strokeWidth: "2"
81
+ }, /*#__PURE__*/_react.default.createElement("path", {
82
+ transform: "translate(0 0)",
83
+ d: "M1409 581 1450.35 511 1490 581z"
84
+ }), /*#__PURE__*/_react.default.createElement("circle", {
85
+ strokeWidth: "4",
86
+ transform: "rotate(0 800 450)",
87
+ cx: "500",
88
+ cy: "100",
89
+ r: "40"
90
+ }), /*#__PURE__*/_react.default.createElement("path", {
91
+ transform: "translate(0 0)",
92
+ d: "M400.86 735.5h-83.73c0-23.12 18.74-41.87 41.87-41.87S400.86 712.38 400.86 735.5z"
93
+ })), /*#__PURE__*/_react.default.createElement("g", {
94
+ stroke: "url(#b)",
95
+ strokeWidth: "4"
96
+ }, /*#__PURE__*/_react.default.createElement("path", {
97
+ transform: "translate(0 0)",
98
+ d: "M149.8 345.2 118.4 389.8 149.8 434.4 181.2 389.8z"
99
+ }), /*#__PURE__*/_react.default.createElement("rect", {
100
+ strokeWidth: "8",
101
+ transform: "rotate(0 1089 759)",
102
+ x: "1039",
103
+ y: "709",
104
+ width: "100",
105
+ height: "100"
106
+ }), /*#__PURE__*/_react.default.createElement("path", {
107
+ transform: "rotate(0 1400 132)",
108
+ d: "M1426.8 132.4 1405.7 168.8 1363.7 168.8 1342.7 132.4 1363.7 96 1405.7 96z"
109
+ })))), /*#__PURE__*/_react.default.createElement(_core.Box, {
110
+ position: "fixed",
111
+ bottom: "1rem",
112
+ right: "1rem",
113
+ zIndex: 10
114
+ }, /*#__PURE__*/_react.default.createElement("small", null, "Texture made with", ' ', /*#__PURE__*/_react.default.createElement(_core.Link, {
115
+ href: "https://www.design.svgbackgrounds.com/"
116
+ }, "SVGBackgrounds.com"))));
117
+ };
118
+
119
+ var _default = PublicTemplateBackground;
120
+ exports.default = _default;
@@ -3,18 +3,72 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.getStartUrl = exports.generateMetaTitleOptions = exports.generateMetaDescriptionOptions = exports.generateManifest = exports.generateIcons = exports.generateBrand = exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
+ var _lodash = require("lodash");
11
+
10
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
13
 
12
14
  var _reactHelmet = require("react-helmet");
13
15
 
16
+ var _q3UiHelpers = require("q3-ui-helpers");
17
+
14
18
  var _useSiteMetaData = _interopRequireDefault(require("./useSiteMetaData"));
15
19
 
16
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
21
 
22
+ const withContent = output => content => content && (0, _lodash.isFunction)(output) ? output(content) : [];
23
+
24
+ const getStartUrl = () => _q3UiHelpers.browser.isBrowserReady() ? (0, _lodash.get)(window, 'location.host') : '';
25
+
26
+ exports.getStartUrl = getStartUrl;
27
+ const generateMetaDescriptionOptions = withContent(content => [{
28
+ name: 'description',
29
+ content
30
+ }, {
31
+ property: 'og:description',
32
+ content
33
+ }, {
34
+ name: 'twitter:description',
35
+ content
36
+ }]);
37
+ exports.generateMetaDescriptionOptions = generateMetaDescriptionOptions;
38
+ const generateMetaTitleOptions = withContent(content => [{
39
+ property: 'og:title',
40
+ content
41
+ }, {
42
+ name: 'twitter:title',
43
+ content
44
+ }]);
45
+ exports.generateMetaTitleOptions = generateMetaTitleOptions;
46
+
47
+ const generateBrand = xs => xs ? `%s | ${xs}` : undefined;
48
+
49
+ exports.generateBrand = generateBrand;
50
+
51
+ const generateIcons = (site = {}) => site !== null && site !== void 0 && site.favicon ? [{
52
+ src: site.favicon,
53
+ sizes: '512x512',
54
+ type: 'image/png'
55
+ }] : [];
56
+
57
+ exports.generateIcons = generateIcons;
58
+
59
+ const generateManifest = (site = {}) => ({
60
+ background_color: site.color,
61
+ description: site.description,
62
+ display: 'fullscreen',
63
+ icons: generateIcons(site),
64
+ name: site.title,
65
+ start_url: getStartUrl(),
66
+ short_name: site.brand,
67
+ theme_color: site.color
68
+ });
69
+
70
+ exports.generateManifest = generateManifest;
71
+
18
72
  const SEO = ({
19
73
  description,
20
74
  lang,
@@ -23,35 +77,28 @@ const SEO = ({
23
77
  }) => {
24
78
  const site = (0, _useSiteMetaData.default)();
25
79
  const metaDescription = description || site.description;
80
+ const metaTitle = title || site.title;
81
+ const manifestData = generateManifest(site);
26
82
  return /*#__PURE__*/_react.default.createElement(_reactHelmet.Helmet, {
27
83
  htmlAttributes: {
28
84
  lang
29
85
  },
30
- title: title || site.title,
31
- titleTemplate: `%s | ${site.brand}`,
32
- meta: [{
33
- name: 'description',
34
- content: metaDescription
35
- }, {
36
- property: 'og:title',
37
- content: title
38
- }, {
39
- property: 'og:description',
40
- content: metaDescription
41
- }, {
86
+ title: metaTitle,
87
+ titleTemplate: generateBrand(site.brand),
88
+ meta: [...generateMetaTitleOptions(metaTitle), ...generateMetaDescriptionOptions(metaDescription), {
42
89
  property: 'og:type',
43
90
  content: 'website'
44
91
  }, {
45
92
  name: 'twitter:card',
46
93
  content: 'summary'
47
- }, {
48
- name: 'twitter:title',
49
- content: title
50
- }, {
51
- name: 'twitter:description',
52
- content: metaDescription
53
94
  }].concat(meta)
54
- });
95
+ }, (0, _lodash.isObject)(manifestData) ? /*#__PURE__*/_react.default.createElement("link", {
96
+ rel: "manifest",
97
+ href: `data:application/manifest+json,${encodeURIComponent(JSON.stringify(manifestData))}`
98
+ }) : null, /*#__PURE__*/_react.default.createElement("link", {
99
+ rel: "icon",
100
+ href: site.favicon
101
+ }));
55
102
  };
56
103
 
57
104
  SEO.defaultProps = {