gatsby-theme-q3 3.8.15 → 3.9.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -3,47 +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.8.15](https://github.com/3merge/q/compare/v3.8.14...v3.8.15) (2022-08-15)
7
-
8
- **Note:** Version bump only for package gatsby-theme-q3
9
-
10
-
11
-
12
-
13
-
14
- ## [3.8.12](https://github.com/3merge/q/compare/v3.8.11...v3.8.12) (2022-08-02)
15
-
16
- **Note:** Version bump only for package gatsby-theme-q3
17
-
18
-
19
-
20
-
21
-
22
- ## [3.8.9](https://github.com/3merge/q/compare/v3.8.8...v3.8.9) (2022-07-29)
23
-
24
- **Note:** Version bump only for package gatsby-theme-q3
25
-
26
-
27
-
28
-
29
-
30
- ## [3.8.6](https://github.com/3merge/q/compare/v3.8.5...v3.8.6) (2022-07-27)
31
-
32
- **Note:** Version bump only for package gatsby-theme-q3
33
-
34
-
35
-
36
-
37
-
38
- ## [3.8.3](https://github.com/3merge/q/compare/v3.8.2...v3.8.3) (2022-07-26)
39
-
40
- **Note:** Version bump only for package gatsby-theme-q3
41
-
42
-
43
-
44
-
45
-
46
- # [3.8.0](https://github.com/3merge/q/compare/v3.7.3...v3.8.0) (2022-07-26)
6
+ # [3.9.0](https://github.com/3merge/q/compare/v3.8.22...v3.9.0) (2022-09-01)
47
7
 
48
8
  **Note:** Version bump only for package gatsby-theme-q3
49
9
 
@@ -52,6 +12,71 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
52
12
 
53
13
 
54
14
 
15
+ ## [3.8.22](https://github.com/3merge/q/compare/v3.8.21...v3.8.22) (2022-08-30)
16
+
17
+ **Note:** Version bump only for package gatsby-theme-q3
18
+
19
+
20
+
21
+
22
+
23
+ ## [3.8.16](https://github.com/3merge/q/compare/v3.8.15...v3.8.16) (2022-08-15)
24
+
25
+ **Note:** Version bump only for package gatsby-theme-q3
26
+
27
+
28
+
29
+
30
+
31
+ ## [3.8.15](https://github.com/3merge/q/compare/v3.8.14...v3.8.15) (2022-08-15)
32
+
33
+ **Note:** Version bump only for package gatsby-theme-q3
34
+
35
+
36
+
37
+
38
+
39
+ ## [3.8.12](https://github.com/3merge/q/compare/v3.8.11...v3.8.12) (2022-08-02)
40
+
41
+ **Note:** Version bump only for package gatsby-theme-q3
42
+
43
+
44
+
45
+
46
+
47
+ ## [3.8.9](https://github.com/3merge/q/compare/v3.8.8...v3.8.9) (2022-07-29)
48
+
49
+ **Note:** Version bump only for package gatsby-theme-q3
50
+
51
+
52
+
53
+
54
+
55
+ ## [3.8.6](https://github.com/3merge/q/compare/v3.8.5...v3.8.6) (2022-07-27)
56
+
57
+ **Note:** Version bump only for package gatsby-theme-q3
58
+
59
+
60
+
61
+
62
+
63
+ ## [3.8.3](https://github.com/3merge/q/compare/v3.8.2...v3.8.3) (2022-07-26)
64
+
65
+ **Note:** Version bump only for package gatsby-theme-q3
66
+
67
+
68
+
69
+
70
+
71
+ # [3.8.0](https://github.com/3merge/q/compare/v3.7.3...v3.8.0) (2022-07-26)
72
+
73
+ **Note:** Version bump only for package gatsby-theme-q3
74
+
75
+
76
+
77
+
78
+
79
+
55
80
  ## [3.7.3](https://github.com/3merge/q/compare/v3.7.2...v3.7.3) (2022-07-22)
56
81
 
57
82
  **Note:** Version bump only for package gatsby-theme-q3
@@ -110,9 +110,12 @@ const PublicTemplate = ({
110
110
  invertLogo,
111
111
  terms,
112
112
  privacy,
113
- logo = '/logo.png',
114
- photo = '/background.jpg'
115
- } = (0, _useSiteMetaData.default)();
113
+ logo,
114
+ photo
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 = () => (0, _lodash.merge)((0, _lodash.get)((0, _gatsby.useStaticQuery)((0, _gatsby.graphql)`
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.15",
3
+ "version": "3.9.0",
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.12",
31
+ "gatsby-theme-q3-mui": "^3.9.0",
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.9",
37
- "q3-ui-locale": "^3.8.9",
36
+ "q3-ui-helpers": "^3.9.0",
37
+ "q3-ui-locale": "^3.9.0",
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": "cb170f5776705036227768fcf146a6df23f6475b"
45
+ "gitHead": "16fe4b65978089e1fc14e7a1f2b8760dfb2245d9"
46
46
  }
@@ -98,9 +98,12 @@ const PublicTemplate = ({ children, ...rest }) => {
98
98
  invertLogo,
99
99
  terms,
100
100
  privacy,
101
- logo = '/logo.png',
102
- photo = '/background.jpg',
103
- } = useSiteMetaData();
101
+ logo,
102
+ photo,
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
+ };