gatsby-theme-q3 3.1.5 → 3.2.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +75 -36
- package/gatsby-browser.js +29 -0
- package/gatsby-config.js +7 -47
- package/gatsby-node.js +0 -1
- package/lib/components/FormBoxContent.js +2 -1
- package/lib/components/PageWrapper.js +2 -11
- package/lib/components/PublicTemplate.js +130 -6
- package/lib/components/SearchEngine.js +67 -20
- package/lib/components/Wrapper.js +3 -25
- package/lib/components/__tests__/SearchEngine.test.js +41 -0
- package/lib/components/useSiteMetaData.js +13 -12
- package/lib/components/withPublicTemplate.js +17 -0
- package/lib/components/withSuccessOp.js +1 -1
- package/lib/pages/login.js +7 -4
- package/lib/pages/password-change.js +4 -3
- package/lib/pages/password-reset.js +4 -3
- package/lib/pages/reverify.js +5 -2
- package/lib/pages/verify.js +5 -3
- package/package.json +6 -6
- package/src/components/FormBoxContent.jsx +1 -1
- package/src/components/PageWrapper.jsx +1 -13
- package/src/components/PublicTemplate.jsx +134 -5
- package/src/components/SearchEngine.jsx +82 -23
- package/src/components/Wrapper.jsx +3 -27
- package/src/components/__tests__/SearchEngine.test.jsx +58 -0
- package/src/components/useSiteMetaData.js +17 -16
- package/src/components/withPublicTemplate.jsx +11 -0
- package/src/components/withSuccessOp.jsx +1 -1
- package/src/pages/login.jsx +55 -43
- package/src/pages/password-change.jsx +5 -3
- package/src/pages/password-reset.jsx +5 -3
- package/src/pages/reverify.jsx +4 -2
- package/src/pages/verify.jsx +9 -12
- package/__tests__/config.int.test.js +0 -73
- package/helpers/__tests__/loadContent.unit.test.js +0 -13
- package/helpers/__tests__/pagination.unit.test.js +0 -139
- package/helpers/__tests__/slug.unit.test.js +0 -21
- package/helpers/archive.js +0 -42
- package/helpers/index.js +0 -19
- package/helpers/loadContent.js +0 -45
- package/helpers/loadTheme.js +0 -10
- package/helpers/pagination.js +0 -109
- package/helpers/setup.js +0 -60
- package/helpers/slug.js +0 -31
- package/helpers/slugType.js +0 -24
- package/lib/components/LocaleBundles.js +0 -42
- package/lib/components/useLocale.js +0 -31
- package/src/components/LocaleBundles.jsx +0 -37
- 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.
|
6
|
+
## [3.2.3](https://github.com/3merge/q/compare/v3.2.2...v3.2.3) (2022-02-10)
|
7
7
|
|
8
8
|
**Note:** Version bump only for package gatsby-theme-q3
|
9
9
|
|
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
11
11
|
|
12
12
|
|
13
13
|
|
14
|
-
## [3.
|
14
|
+
## [3.2.2](https://github.com/3merge/q/compare/v3.2.1...v3.2.2) (2022-02-10)
|
15
15
|
|
16
16
|
**Note:** Version bump only for package gatsby-theme-q3
|
17
17
|
|
@@ -19,58 +19,97 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
19
19
|
|
20
20
|
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
**Note:** Version bump only for package gatsby-theme-q3
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
## [3.0.4](https://github.com/3merge/q/compare/v3.0.3...v3.0.4) (2022-01-29)
|
31
|
-
|
32
|
-
**Note:** Version bump only for package gatsby-theme-q3
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
## [3.0.3](https://github.com/3merge/q/compare/v3.0.2...v3.0.3) (2022-01-29)
|
22
|
+
## [3.2.1](https://github.com/3merge/q/compare/v3.2.0...v3.2.1) (2022-02-09)
|
39
23
|
|
40
24
|
|
41
25
|
### Bug Fixes
|
42
26
|
|
43
|
-
*
|
27
|
+
* misc domain issues ([17cb74b](https://github.com/3merge/q/commit/17cb74b927721f11b5fcd8f8a9a1a28a86867048))
|
44
28
|
|
45
29
|
|
46
30
|
|
47
31
|
|
48
32
|
|
49
|
-
|
50
|
-
|
51
|
-
**Note:** Version bump only for package gatsby-theme-q3
|
33
|
+
# [3.2.0](https://github.com/3merge/q/compare/v3.1.5...v3.2.0) (2022-02-09)
|
52
34
|
|
53
35
|
|
36
|
+
### Features
|
54
37
|
|
55
|
-
|
56
|
-
|
57
|
-
## [3.0.1](https://github.com/3merge/q/compare/v3.0.0...v3.0.1) (2022-01-28)
|
58
|
-
|
59
|
-
**Note:** Version bump only for package gatsby-theme-q3
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
# [3.0.0](https://github.com/3merge/q/compare/v2.3.13...v3.0.0) (2022-01-28)
|
66
|
-
|
67
|
-
**Note:** Version bump only for package gatsby-theme-q3
|
38
|
+
* text locale editor ([#377](https://github.com/3merge/q/issues/377)) ([e827875](https://github.com/3merge/q/commit/e8278757be7505554376c1d1d78d9b8900fdf35e))
|
68
39
|
|
69
40
|
|
70
41
|
|
71
42
|
|
72
43
|
|
73
44
|
|
45
|
+
## [3.1.5](https://github.com/3merge/q/compare/v3.1.4...v3.1.5) (2022-02-01)
|
46
|
+
|
47
|
+
**Note:** Version bump only for package gatsby-theme-q3
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
## [3.1.4](https://github.com/3merge/q/compare/v3.1.3...v3.1.4) (2022-02-01)
|
54
|
+
|
55
|
+
**Note:** Version bump only for package gatsby-theme-q3
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
# [3.1.0](https://github.com/3merge/q/compare/v3.0.4...v3.1.0) (2022-01-31)
|
62
|
+
|
63
|
+
**Note:** Version bump only for package gatsby-theme-q3
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
## [3.0.4](https://github.com/3merge/q/compare/v3.0.3...v3.0.4) (2022-01-29)
|
70
|
+
|
71
|
+
**Note:** Version bump only for package gatsby-theme-q3
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
## [3.0.3](https://github.com/3merge/q/compare/v3.0.2...v3.0.3) (2022-01-29)
|
78
|
+
|
79
|
+
|
80
|
+
### Bug Fixes
|
81
|
+
|
82
|
+
* major release bugs ([#372](https://github.com/3merge/q/issues/372)) ([d3e0681](https://github.com/3merge/q/commit/d3e0681a8d9ce61558b3aeaabe94ce8bc326dfa7))
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
## [3.0.2](https://github.com/3merge/q/compare/v3.0.1...v3.0.2) (2022-01-28)
|
89
|
+
|
90
|
+
**Note:** Version bump only for package gatsby-theme-q3
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
## [3.0.1](https://github.com/3merge/q/compare/v3.0.0...v3.0.1) (2022-01-28)
|
97
|
+
|
98
|
+
**Note:** Version bump only for package gatsby-theme-q3
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
# [3.0.0](https://github.com/3merge/q/compare/v2.3.13...v3.0.0) (2022-01-28)
|
105
|
+
|
106
|
+
**Note:** Version bump only for package gatsby-theme-q3
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
74
113
|
## [2.3.11](https://github.com/3merge/q/compare/v2.3.10...v2.3.11) (2022-01-18)
|
75
114
|
|
76
115
|
**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
@@ -23,7 +23,8 @@ const FormBoxContent = ({
|
|
23
23
|
t
|
24
24
|
} = (0, _q3UiLocale.useTranslation)();
|
25
25
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
26
|
-
|
26
|
+
component: "h1",
|
27
|
+
variant: "h2",
|
27
28
|
gutterBottom: true
|
28
29
|
}, t(`titles:${title}`)), /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
29
30
|
gutterBottom: true
|
@@ -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
|
-
|
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,13 @@ var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
11
11
|
|
12
|
-
var
|
12
|
+
var _core = require("@material-ui/core");
|
13
|
+
|
14
|
+
var _gatsby = require("gatsby");
|
15
|
+
|
16
|
+
var _q3UiLocale = require("q3-ui-locale");
|
17
|
+
|
18
|
+
var _lodash = require("lodash");
|
13
19
|
|
14
20
|
var _AdminPublicGateway = _interopRequireDefault(require("./AdminPublicGateway"));
|
15
21
|
|
@@ -17,18 +23,136 @@ var _useSiteMetaData = _interopRequireDefault(require("./useSiteMetaData"));
|
|
17
23
|
|
18
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
25
|
|
26
|
+
const useStyle = (0, _core.makeStyles)(theme => ({
|
27
|
+
logo: {
|
28
|
+
height: 95,
|
29
|
+
width: 180,
|
30
|
+
display: 'block',
|
31
|
+
'& img': {
|
32
|
+
objectFit: 'contain',
|
33
|
+
height: '100%',
|
34
|
+
width: '100%'
|
35
|
+
}
|
36
|
+
},
|
37
|
+
container: {
|
38
|
+
maxWidth: '85vw',
|
39
|
+
width: 850,
|
40
|
+
[theme.breakpoints.down('md')]: {
|
41
|
+
width: '100%'
|
42
|
+
},
|
43
|
+
[theme.breakpoints.down('sm')]: {
|
44
|
+
width: 'auto'
|
45
|
+
}
|
46
|
+
},
|
47
|
+
photo: ({
|
48
|
+
photo
|
49
|
+
}) => ({
|
50
|
+
backgroundColor: theme.palette.secondary.light,
|
51
|
+
backgroundImage: (0, _lodash.isString)(photo) ? `url("${String(photo).replace(/\s/gi, '%20')}")` : undefined,
|
52
|
+
backgroundSize: 'contain',
|
53
|
+
backgroundPosition: 'center',
|
54
|
+
backgroundRepeat: 'no-repeat',
|
55
|
+
width: '100%',
|
56
|
+
height: '100%',
|
57
|
+
backgroundBlendMode: 'multiply',
|
58
|
+
minHeight: '55vh'
|
59
|
+
})
|
60
|
+
}));
|
61
|
+
|
62
|
+
const Copyright = () => {
|
63
|
+
const {
|
64
|
+
brand
|
65
|
+
} = (0, _useSiteMetaData.default)();
|
66
|
+
return brand ? /*#__PURE__*/_react.default.createElement(_core.Box, {
|
67
|
+
display: "inline-block",
|
68
|
+
mx: 1
|
69
|
+
}, "\xA9", new Date().getFullYear(), " ", brand) : null;
|
70
|
+
}; // eslint-disable-next-line
|
71
|
+
|
72
|
+
|
73
|
+
const TextLink = ({
|
74
|
+
href,
|
75
|
+
text
|
76
|
+
}) => {
|
77
|
+
const {
|
78
|
+
t
|
79
|
+
} = (0, _q3UiLocale.useTranslation)('labels');
|
80
|
+
return href ? /*#__PURE__*/_react.default.createElement(_core.Box, {
|
81
|
+
display: "inline-block",
|
82
|
+
mx: 1
|
83
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Link, {
|
84
|
+
href: href,
|
85
|
+
target: "_blank"
|
86
|
+
}, t(text))) : null;
|
87
|
+
};
|
88
|
+
|
20
89
|
const PublicTemplate = ({
|
21
90
|
children,
|
22
91
|
...rest
|
23
92
|
}) => {
|
24
93
|
const {
|
25
94
|
brand,
|
26
|
-
|
95
|
+
cancellation,
|
96
|
+
logo,
|
97
|
+
terms,
|
98
|
+
privacy,
|
99
|
+
photo
|
27
100
|
} = (0, _useSiteMetaData.default)();
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
101
|
+
const cls = useStyle({
|
102
|
+
photo
|
103
|
+
});
|
104
|
+
return /*#__PURE__*/_react.default.createElement(_AdminPublicGateway.default, rest, /*#__PURE__*/_react.default.createElement(_core.Box, {
|
105
|
+
alignItems: "center",
|
106
|
+
component: "article",
|
107
|
+
display: "flex",
|
108
|
+
flexDirection: "column",
|
109
|
+
justifyContent: "center",
|
110
|
+
width: "100%"
|
111
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Box, {
|
112
|
+
component: "header",
|
113
|
+
mt: "2vh",
|
114
|
+
mb: 2,
|
115
|
+
textAlign: "center"
|
116
|
+
}, /*#__PURE__*/_react.default.createElement(_gatsby.Link, {
|
117
|
+
to: "/",
|
118
|
+
className: cls.logo
|
119
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
120
|
+
alt: brand,
|
121
|
+
src: logo
|
122
|
+
}))), /*#__PURE__*/_react.default.createElement(_core.Paper, {
|
123
|
+
className: cls.container
|
124
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Grid, {
|
125
|
+
alignItems: "center",
|
126
|
+
container: true,
|
127
|
+
spacing: 1
|
128
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Hidden, {
|
129
|
+
smDown: true
|
130
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Grid, {
|
131
|
+
item: true,
|
132
|
+
xs: 6
|
133
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Box, {
|
134
|
+
className: cls.photo
|
135
|
+
}))), /*#__PURE__*/_react.default.createElement(_core.Grid, {
|
136
|
+
item: true,
|
137
|
+
md: 6,
|
138
|
+
xs: 12
|
139
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Box, {
|
140
|
+
p: 2
|
141
|
+
}, children)))), /*#__PURE__*/_react.default.createElement(_core.Box, {
|
142
|
+
maxWidth: "75vw",
|
143
|
+
component: "footer",
|
144
|
+
mt: 3,
|
145
|
+
textAlign: "center"
|
146
|
+
}, /*#__PURE__*/_react.default.createElement("small", null, /*#__PURE__*/_react.default.createElement(Copyright, null), /*#__PURE__*/_react.default.createElement(TextLink, {
|
147
|
+
href: terms,
|
148
|
+
text: "termsAndConditions"
|
149
|
+
}), /*#__PURE__*/_react.default.createElement(TextLink, {
|
150
|
+
href: privacy,
|
151
|
+
text: "privacyPolicy"
|
152
|
+
}), /*#__PURE__*/_react.default.createElement(TextLink, {
|
153
|
+
href: cancellation,
|
154
|
+
text: "cancellationPolicy"
|
155
|
+
})))));
|
32
156
|
};
|
33
157
|
|
34
158
|
PublicTemplate.defaultProps = {
|
@@ -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:
|
31
|
-
titleTemplate:
|
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 = {
|
@@ -7,41 +7,19 @@ exports.default = void 0;
|
|
7
7
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
9
9
|
|
10
|
-
var _axios = _interopRequireDefault(require("axios"));
|
11
|
-
|
12
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
13
11
|
|
14
12
|
var _q3UiPermissions = _interopRequireDefault(require("q3-ui-permissions"));
|
15
13
|
|
16
|
-
var _LocaleBundles = _interopRequireDefault(require("./LocaleBundles"));
|
17
|
-
|
18
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
15
|
|
20
16
|
/* eslint-disable import/no-extraneous-dependencies */
|
21
|
-
const setBaseUrlForRest = (baseURL = process.env.GATSBY_APP_BASE_URL || 'http://localhost:9000') => {
|
22
|
-
_axios.default.defaults.baseURL = baseURL;
|
23
|
-
return _axios.default.defaults;
|
24
|
-
};
|
25
|
-
|
26
17
|
const Wrapper = ({
|
27
|
-
|
28
|
-
|
29
|
-
locale
|
30
|
-
}) => {
|
31
|
-
setBaseUrlForRest(baseURL);
|
32
|
-
return /*#__PURE__*/_react.default.createElement(_LocaleBundles.default, {
|
33
|
-
locale: locale
|
34
|
-
}, /*#__PURE__*/_react.default.createElement(_q3UiPermissions.default, null, children));
|
35
|
-
};
|
18
|
+
children
|
19
|
+
}) => /*#__PURE__*/_react.default.createElement(_q3UiPermissions.default, null, children);
|
36
20
|
|
37
|
-
Wrapper.defaultProps = {
|
38
|
-
baseURL: undefined
|
39
|
-
};
|
40
21
|
Wrapper.propTypes = {
|
41
|
-
|
42
|
-
children: _propTypes.default.node.isRequired,
|
43
|
-
// eslint-disable-next-line
|
44
|
-
locale: _propTypes.default.object.isRequired
|
22
|
+
children: _propTypes.default.node.isRequired
|
45
23
|
};
|
46
24
|
var _default = Wrapper;
|
47
25
|
exports.default = _default;
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _SearchEngine = require("../SearchEngine");
|
4
|
+
|
5
|
+
jest.mock('q3-ui-locale', () => ({
|
6
|
+
browser: {
|
7
|
+
isBrowserReady: jest.fn()
|
8
|
+
}
|
9
|
+
}));
|
10
|
+
const host = 'https://google.ca';
|
11
|
+
beforeEach(() => {
|
12
|
+
Object.defineProperty(window, 'location', {
|
13
|
+
value: {
|
14
|
+
host
|
15
|
+
}
|
16
|
+
});
|
17
|
+
});
|
18
|
+
describe('SearchEngine', () => {
|
19
|
+
it('should not render descriptions without content', () => {
|
20
|
+
expect((0, _SearchEngine.generateMetaDescriptionOptions)().length).toBe(0);
|
21
|
+
});
|
22
|
+
it('should render descriptions with content', () => {
|
23
|
+
expect((0, _SearchEngine.generateMetaDescriptionOptions)('foo').length).toBeGreaterThanOrEqual(1);
|
24
|
+
});
|
25
|
+
it('should return host', () => {
|
26
|
+
expect((0, _SearchEngine.getStartUrl)()).toMatch(host);
|
27
|
+
});
|
28
|
+
it('should render favicon', () => {
|
29
|
+
expect((0, _SearchEngine.generateIcons)({
|
30
|
+
favicon: host
|
31
|
+
})).toHaveLength(1);
|
32
|
+
});
|
33
|
+
it('should not render favicon', () => {
|
34
|
+
expect((0, _SearchEngine.generateIcons)({
|
35
|
+
favicon: undefined
|
36
|
+
})).toHaveLength(0);
|
37
|
+
});
|
38
|
+
it('should include template literals', () => {
|
39
|
+
expect((0, _SearchEngine.generateBrand)('3merge')).toMatch('%s | 3merge');
|
40
|
+
});
|
41
|
+
});
|