gatsby-theme-q3 3.8.12 → 3.8.22
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +24 -0
- package/lib/components/PublicTemplate.js +5 -2
- package/lib/components/__tests__/useSiteMetaData.test.js +44 -0
- package/lib/components/useSiteMetaData.js +9 -1
- package/package.json +5 -5
- package/src/components/PublicTemplate.jsx +5 -2
- package/src/components/__tests__/useSiteMetaData.test.js +44 -0
- package/src/components/useSiteMetaData.js +15 -3
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,30 @@
|
|
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.8.22](https://github.com/3merge/q/compare/v3.8.21...v3.8.22) (2022-08-30)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package gatsby-theme-q3
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [3.8.16](https://github.com/3merge/q/compare/v3.8.15...v3.8.16) (2022-08-15)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package gatsby-theme-q3
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
## [3.8.15](https://github.com/3merge/q/compare/v3.8.14...v3.8.15) (2022-08-15)
|
23
|
+
|
24
|
+
**Note:** Version bump only for package gatsby-theme-q3
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
6
30
|
## [3.8.12](https://github.com/3merge/q/compare/v3.8.11...v3.8.12) (2022-08-02)
|
7
31
|
|
8
32
|
**Note:** Version bump only for package gatsby-theme-q3
|
@@ -107,12 +107,15 @@ const PublicTemplate = ({
|
|
107
107
|
const {
|
108
108
|
brand,
|
109
109
|
cancellation,
|
110
|
-
logo,
|
111
110
|
invertLogo,
|
112
111
|
terms,
|
113
112
|
privacy,
|
113
|
+
logo,
|
114
114
|
photo
|
115
|
-
} = (0, _useSiteMetaData.default)(
|
115
|
+
} = (0, _useSiteMetaData.default)({
|
116
|
+
logo: '/logo.png',
|
117
|
+
photo: '/background.jpg'
|
118
|
+
});
|
116
119
|
const cls = useStyle({
|
117
120
|
photo,
|
118
121
|
invertLogo
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import useSiteMetaData from '../useSiteMetaData';
|
2
|
+
|
3
|
+
jest.mock('gatsby', () => ({
|
4
|
+
graphql: jest.fn(),
|
5
|
+
useStaticQuery: jest.fn(),
|
6
|
+
}));
|
7
|
+
|
8
|
+
jest.mock(
|
9
|
+
'gatsby-theme-q3-mui/src/components/useRunTime',
|
10
|
+
() =>
|
11
|
+
jest.fn().mockReturnValue({
|
12
|
+
foo: 1,
|
13
|
+
bar: null,
|
14
|
+
quuz: 'string',
|
15
|
+
thunk: undefined,
|
16
|
+
}),
|
17
|
+
);
|
18
|
+
|
19
|
+
describe('useSiteMetaData', () => {
|
20
|
+
it('should overwrite only the nullish and undefined', () => {
|
21
|
+
expect(
|
22
|
+
useSiteMetaData({
|
23
|
+
foo: 2,
|
24
|
+
bar: 2,
|
25
|
+
quuz: 2,
|
26
|
+
thunk: 2,
|
27
|
+
}),
|
28
|
+
).toEqual({
|
29
|
+
foo: 1,
|
30
|
+
bar: 2,
|
31
|
+
quuz: 'string',
|
32
|
+
thunk: 2,
|
33
|
+
});
|
34
|
+
});
|
35
|
+
|
36
|
+
it('should return without defaults', () => {
|
37
|
+
expect(useSiteMetaData()).toEqual({
|
38
|
+
foo: 1,
|
39
|
+
bar: null,
|
40
|
+
quuz: 'string',
|
41
|
+
thunk: undefined,
|
42
|
+
});
|
43
|
+
});
|
44
|
+
});
|
@@ -13,7 +13,8 @@ var _useRunTime = _interopRequireDefault(require("gatsby-theme-q3-mui/src/compon
|
|
13
13
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
15
|
|
16
|
-
var _default = (
|
16
|
+
var _default = (defaultValues = {}) => {
|
17
|
+
const output = (0, _lodash.merge)((0, _lodash.get)((0, _gatsby.useStaticQuery)((0, _gatsby.graphql)`
|
17
18
|
query {
|
18
19
|
site {
|
19
20
|
siteMetadata {
|
@@ -24,5 +25,12 @@ var _default = () => (0, _lodash.merge)((0, _lodash.get)((0, _gatsby.useStaticQu
|
|
24
25
|
}
|
25
26
|
}
|
26
27
|
`), 'site.siteMetadata', {}), (0, _useRunTime.default)());
|
28
|
+
if ((0, _lodash.isObject)(output) && (0, _lodash.isObject)(defaultValues)) Object.entries(defaultValues).forEach(([key, value]) => {
|
29
|
+
if ((0, _lodash.isNil)(output[key])) {
|
30
|
+
output[key] = value;
|
31
|
+
}
|
32
|
+
});
|
33
|
+
return output;
|
34
|
+
};
|
27
35
|
|
28
36
|
exports.default = _default;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "gatsby-theme-q3",
|
3
|
-
"version": "3.8.
|
3
|
+
"version": "3.8.22",
|
4
4
|
"main": "index.js",
|
5
5
|
"license": "MIT",
|
6
6
|
"peerDependencies": {
|
@@ -28,13 +28,13 @@
|
|
28
28
|
"gatsby-plugin-robots-txt": "^1.6.14",
|
29
29
|
"gatsby-plugin-sharp": "^4.2.0",
|
30
30
|
"gatsby-plugin-sitemap": "^5.2.0",
|
31
|
-
"gatsby-theme-q3-mui": "^3.8.
|
31
|
+
"gatsby-theme-q3-mui": "^3.8.22",
|
32
32
|
"gatsby-transformer-sharp": "^4.2.0",
|
33
33
|
"lodash": "^4.17.20",
|
34
34
|
"process": "^0.11.10",
|
35
35
|
"prop-types": "^15.7.2",
|
36
|
-
"q3-ui-helpers": "^3.8.
|
37
|
-
"q3-ui-locale": "^3.8.
|
36
|
+
"q3-ui-helpers": "^3.8.22",
|
37
|
+
"q3-ui-locale": "^3.8.22",
|
38
38
|
"query-string": "^7.0.1",
|
39
39
|
"react-helmet": "^6.1.0",
|
40
40
|
"react-share": "^4.3.1",
|
@@ -42,5 +42,5 @@
|
|
42
42
|
"transform-loader": "^0.2.4",
|
43
43
|
"yarn": "^1.22.17"
|
44
44
|
},
|
45
|
-
"gitHead": "
|
45
|
+
"gitHead": "994f6c87c09df4d66fc7bc57d6973e20fa8f178e"
|
46
46
|
}
|
@@ -95,12 +95,15 @@ const PublicTemplate = ({ children, ...rest }) => {
|
|
95
95
|
const {
|
96
96
|
brand,
|
97
97
|
cancellation,
|
98
|
-
logo,
|
99
98
|
invertLogo,
|
100
99
|
terms,
|
101
100
|
privacy,
|
101
|
+
logo,
|
102
102
|
photo,
|
103
|
-
} = useSiteMetaData(
|
103
|
+
} = useSiteMetaData({
|
104
|
+
logo: '/logo.png',
|
105
|
+
photo: '/background.jpg',
|
106
|
+
});
|
104
107
|
|
105
108
|
const cls = useStyle({
|
106
109
|
photo,
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import useSiteMetaData from '../useSiteMetaData';
|
2
|
+
|
3
|
+
jest.mock('gatsby', () => ({
|
4
|
+
graphql: jest.fn(),
|
5
|
+
useStaticQuery: jest.fn(),
|
6
|
+
}));
|
7
|
+
|
8
|
+
jest.mock(
|
9
|
+
'gatsby-theme-q3-mui/src/components/useRunTime',
|
10
|
+
() =>
|
11
|
+
jest.fn().mockReturnValue({
|
12
|
+
foo: 1,
|
13
|
+
bar: null,
|
14
|
+
quuz: 'string',
|
15
|
+
thunk: undefined,
|
16
|
+
}),
|
17
|
+
);
|
18
|
+
|
19
|
+
describe('useSiteMetaData', () => {
|
20
|
+
it('should overwrite only the nullish and undefined', () => {
|
21
|
+
expect(
|
22
|
+
useSiteMetaData({
|
23
|
+
foo: 2,
|
24
|
+
bar: 2,
|
25
|
+
quuz: 2,
|
26
|
+
thunk: 2,
|
27
|
+
}),
|
28
|
+
).toEqual({
|
29
|
+
foo: 1,
|
30
|
+
bar: 2,
|
31
|
+
quuz: 'string',
|
32
|
+
thunk: 2,
|
33
|
+
});
|
34
|
+
});
|
35
|
+
|
36
|
+
it('should return without defaults', () => {
|
37
|
+
expect(useSiteMetaData()).toEqual({
|
38
|
+
foo: 1,
|
39
|
+
bar: null,
|
40
|
+
quuz: 'string',
|
41
|
+
thunk: undefined,
|
42
|
+
});
|
43
|
+
});
|
44
|
+
});
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { get, merge } from 'lodash';
|
1
|
+
import { get, merge, isObject, isNil } from 'lodash';
|
2
2
|
import { useStaticQuery, graphql } from 'gatsby';
|
3
3
|
import useRunTime from 'gatsby-theme-q3-mui/src/components/useRunTime';
|
4
4
|
|
5
|
-
export default () =>
|
6
|
-
merge(
|
5
|
+
export default (defaultValues = {}) => {
|
6
|
+
const output = merge(
|
7
7
|
get(
|
8
8
|
useStaticQuery(graphql`
|
9
9
|
query {
|
@@ -21,3 +21,15 @@ export default () =>
|
|
21
21
|
),
|
22
22
|
useRunTime(),
|
23
23
|
);
|
24
|
+
|
25
|
+
if (isObject(output) && isObject(defaultValues))
|
26
|
+
Object.entries(defaultValues).forEach(
|
27
|
+
([key, value]) => {
|
28
|
+
if (isNil(output[key])) {
|
29
|
+
output[key] = value;
|
30
|
+
}
|
31
|
+
},
|
32
|
+
);
|
33
|
+
|
34
|
+
return output;
|
35
|
+
};
|