gatsby-theme-q3 3.8.15 → 3.8.16

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
@@ -3,6 +3,14 @@
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.16](https://github.com/3merge/q/compare/v3.8.15...v3.8.16) (2022-08-15)
7
+
8
+ **Note:** Version bump only for package gatsby-theme-q3
9
+
10
+
11
+
12
+
13
+
6
14
  ## [3.8.15](https://github.com/3merge/q/compare/v3.8.14...v3.8.15) (2022-08-15)
7
15
 
8
16
  **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.8.16",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "peerDependencies": {
@@ -42,5 +42,5 @@
42
42
  "transform-loader": "^0.2.4",
43
43
  "yarn": "^1.22.17"
44
44
  },
45
- "gitHead": "cb170f5776705036227768fcf146a6df23f6475b"
45
+ "gitHead": "65b026205272a7151532cb926edad14f75c0875a"
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
+ };