react-datocms 4.0.3 → 4.0.5

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.
@@ -1,309 +1,314 @@
1
- import * as React from "react";
2
- import { shallow } from "enzyme";
3
- import { renderMetaTags, renderMetaTagsToString, toRemixMeta } from "..";
4
- import { TitleMetaLinkTag } from "../types";
1
+ import * as React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import { renderMetaTags, renderMetaTagsToString, toRemixMeta } from '..';
4
+ import { TitleMetaLinkTag } from '../types';
5
5
 
6
6
  const metaTags: TitleMetaLinkTag[] = [
7
7
  {
8
- "content": "Remix CMS - The easiest way to manage content with Remix",
9
- "attributes": null,
10
- "tag": "title"
8
+ content: 'Remix CMS - The easiest way to manage content with Remix',
9
+ attributes: null,
10
+ tag: 'title',
11
11
  },
12
12
  {
13
- "content": null,
14
- "attributes": {
15
- "property": "og:title",
16
- "content": "Remix CMS - The easiest way to manage content with Remix"
13
+ content: null,
14
+ attributes: {
15
+ property: 'og:title',
16
+ content: 'Remix CMS - The easiest way to manage content with Remix',
17
17
  },
18
- "tag": "meta"
18
+ tag: 'meta',
19
19
  },
20
20
  {
21
- "content": null,
22
- "attributes": {
23
- "name": "twitter:title",
24
- "content": "Remix CMS - The easiest way to manage content with Remix"
21
+ content: null,
22
+ attributes: {
23
+ name: 'twitter:title',
24
+ content: 'Remix CMS - The easiest way to manage content with Remix',
25
25
  },
26
- "tag": "meta"
26
+ tag: 'meta',
27
27
  },
28
28
  {
29
- "content": null,
30
- "attributes": {
31
- "name": "description",
32
- "content": "Remix makes building scalable and fast React apps simple, pair it with a CMS that shares the same intuitiveness. Start a new Remix + Dato project now."
29
+ content: null,
30
+ attributes: {
31
+ name: 'description',
32
+ content:
33
+ 'Remix makes building scalable and fast React apps simple, pair it with a CMS that shares the same intuitiveness. Start a new Remix + Dato project now.',
33
34
  },
34
- "tag": "meta"
35
+ tag: 'meta',
35
36
  },
36
37
  {
37
- "content": null,
38
- "attributes": {
39
- "property": "og:description",
40
- "content": "Remix makes building scalable and fast React apps simple, pair it with a CMS that shares the same intuitiveness. Start a new Remix + Dato project now."
38
+ content: null,
39
+ attributes: {
40
+ property: 'og:description',
41
+ content:
42
+ 'Remix makes building scalable and fast React apps simple, pair it with a CMS that shares the same intuitiveness. Start a new Remix + Dato project now.',
41
43
  },
42
- "tag": "meta"
44
+ tag: 'meta',
43
45
  },
44
46
  {
45
- "content": null,
46
- "attributes": {
47
- "name": "twitter:description",
48
- "content": "Remix makes building scalable and fast React apps simple, pair it with a CMS that shares the same intuitiveness. Start a new Remix + Dato project now."
47
+ content: null,
48
+ attributes: {
49
+ name: 'twitter:description',
50
+ content:
51
+ 'Remix makes building scalable and fast React apps simple, pair it with a CMS that shares the same intuitiveness. Start a new Remix + Dato project now.',
49
52
  },
50
- "tag": "meta"
53
+ tag: 'meta',
51
54
  },
52
55
  {
53
- "content": null,
54
- "attributes": {
55
- "property": "og:image",
56
- "content": "https://www.datocms-assets.com/205/1642515293-full-logo.svg?fit=max&fm=jpg&w=1000"
56
+ content: null,
57
+ attributes: {
58
+ property: 'og:image',
59
+ content:
60
+ 'https://www.datocms-assets.com/205/1642515293-full-logo.svg?fit=max&fm=jpg&w=1000',
57
61
  },
58
- "tag": "meta"
62
+ tag: 'meta',
59
63
  },
60
64
  {
61
- "content": null,
62
- "attributes": {
63
- "property": "og:image:width",
64
- "content": "746"
65
+ content: null,
66
+ attributes: {
67
+ property: 'og:image:width',
68
+ content: '746',
65
69
  },
66
- "tag": "meta"
70
+ tag: 'meta',
67
71
  },
68
72
  {
69
- "content": null,
70
- "attributes": {
71
- "property": "og:image:height",
72
- "content": "186"
73
+ content: null,
74
+ attributes: {
75
+ property: 'og:image:height',
76
+ content: '186',
73
77
  },
74
- "tag": "meta"
78
+ tag: 'meta',
75
79
  },
76
80
  {
77
- "content": null,
78
- "attributes": {
79
- "name": "twitter:image",
80
- "content": "https://www.datocms-assets.com/205/1642515293-full-logo.svg?fit=max&fm=jpg&w=1000"
81
+ content: null,
82
+ attributes: {
83
+ name: 'twitter:image',
84
+ content:
85
+ 'https://www.datocms-assets.com/205/1642515293-full-logo.svg?fit=max&fm=jpg&w=1000',
81
86
  },
82
- "tag": "meta"
87
+ tag: 'meta',
83
88
  },
84
89
  {
85
- "content": null,
86
- "attributes": {
87
- "property": "og:locale",
88
- "content": "en"
90
+ content: null,
91
+ attributes: {
92
+ property: 'og:locale',
93
+ content: 'en',
89
94
  },
90
- "tag": "meta"
95
+ tag: 'meta',
91
96
  },
92
97
  {
93
- "content": null,
94
- "attributes": {
95
- "property": "og:type",
96
- "content": "article"
98
+ content: null,
99
+ attributes: {
100
+ property: 'og:type',
101
+ content: 'article',
97
102
  },
98
- "tag": "meta"
103
+ tag: 'meta',
99
104
  },
100
105
  {
101
- "content": null,
102
- "attributes": {
103
- "property": "og:site_name",
104
- "content": "DatoCMS"
106
+ content: null,
107
+ attributes: {
108
+ property: 'og:site_name',
109
+ content: 'DatoCMS',
105
110
  },
106
- "tag": "meta"
111
+ tag: 'meta',
107
112
  },
108
113
  {
109
- "content": null,
110
- "attributes": {
111
- "property": "article:modified_time",
112
- "content": "2022-01-18T14:02:47Z"
114
+ content: null,
115
+ attributes: {
116
+ property: 'article:modified_time',
117
+ content: '2022-01-18T14:02:47Z',
113
118
  },
114
- "tag": "meta"
119
+ tag: 'meta',
115
120
  },
116
121
  {
117
- "content": null,
118
- "attributes": {
119
- "name": "twitter:card",
120
- "content": "summary_large_image"
122
+ content: null,
123
+ attributes: {
124
+ name: 'twitter:card',
125
+ content: 'summary_large_image',
121
126
  },
122
- "tag": "meta"
127
+ tag: 'meta',
123
128
  },
124
129
  {
125
- "content": null,
126
- "attributes": {
127
- "name": "twitter:site",
128
- "content": "@datocms"
130
+ content: null,
131
+ attributes: {
132
+ name: 'twitter:site',
133
+ content: '@datocms',
129
134
  },
130
- "tag": "meta"
135
+ tag: 'meta',
131
136
  },
132
137
  {
133
- "attributes": {
134
- "sizes": "16x16",
135
- "type": "image/png",
136
- "rel": "icon",
137
- "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=16&w=16"
138
+ attributes: {
139
+ sizes: '16x16',
140
+ type: 'image/png',
141
+ rel: 'icon',
142
+ href: 'https://www.datocms-assets.com/205/1525789775-dato.png?h=16&w=16',
138
143
  },
139
- "content": null,
140
- "tag": "link"
144
+ content: null,
145
+ tag: 'link',
141
146
  },
142
147
  {
143
- "attributes": {
144
- "sizes": "32x32",
145
- "type": "image/png",
146
- "rel": "icon",
147
- "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=32&w=32"
148
+ attributes: {
149
+ sizes: '32x32',
150
+ type: 'image/png',
151
+ rel: 'icon',
152
+ href: 'https://www.datocms-assets.com/205/1525789775-dato.png?h=32&w=32',
148
153
  },
149
- "content": null,
150
- "tag": "link"
154
+ content: null,
155
+ tag: 'link',
151
156
  },
152
157
  {
153
- "attributes": {
154
- "sizes": "96x96",
155
- "type": "image/png",
156
- "rel": "icon",
157
- "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=96&w=96"
158
+ attributes: {
159
+ sizes: '96x96',
160
+ type: 'image/png',
161
+ rel: 'icon',
162
+ href: 'https://www.datocms-assets.com/205/1525789775-dato.png?h=96&w=96',
158
163
  },
159
- "content": null,
160
- "tag": "link"
164
+ content: null,
165
+ tag: 'link',
161
166
  },
162
167
  {
163
- "attributes": {
164
- "sizes": "192x192",
165
- "type": "image/png",
166
- "rel": "icon",
167
- "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=192&w=192"
168
+ attributes: {
169
+ sizes: '192x192',
170
+ type: 'image/png',
171
+ rel: 'icon',
172
+ href: 'https://www.datocms-assets.com/205/1525789775-dato.png?h=192&w=192',
168
173
  },
169
- "content": null,
170
- "tag": "link"
174
+ content: null,
175
+ tag: 'link',
171
176
  },
172
177
  {
173
- "attributes": {
174
- "sizes": "57x57",
175
- "rel": "apple-touch-icon",
176
- "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=57&w=57"
178
+ attributes: {
179
+ sizes: '57x57',
180
+ rel: 'apple-touch-icon',
181
+ href: 'https://www.datocms-assets.com/205/1525789775-dato.png?h=57&w=57',
177
182
  },
178
- "content": null,
179
- "tag": "link"
183
+ content: null,
184
+ tag: 'link',
180
185
  },
181
186
  {
182
- "attributes": {
183
- "sizes": "60x60",
184
- "rel": "apple-touch-icon",
185
- "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=60&w=60"
187
+ attributes: {
188
+ sizes: '60x60',
189
+ rel: 'apple-touch-icon',
190
+ href: 'https://www.datocms-assets.com/205/1525789775-dato.png?h=60&w=60',
186
191
  },
187
- "content": null,
188
- "tag": "link"
192
+ content: null,
193
+ tag: 'link',
189
194
  },
190
195
  {
191
- "attributes": {
192
- "sizes": "72x72",
193
- "rel": "apple-touch-icon",
194
- "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=72&w=72"
196
+ attributes: {
197
+ sizes: '72x72',
198
+ rel: 'apple-touch-icon',
199
+ href: 'https://www.datocms-assets.com/205/1525789775-dato.png?h=72&w=72',
195
200
  },
196
- "content": null,
197
- "tag": "link"
201
+ content: null,
202
+ tag: 'link',
198
203
  },
199
204
  {
200
- "attributes": {
201
- "sizes": "76x76",
202
- "rel": "apple-touch-icon",
203
- "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=76&w=76"
205
+ attributes: {
206
+ sizes: '76x76',
207
+ rel: 'apple-touch-icon',
208
+ href: 'https://www.datocms-assets.com/205/1525789775-dato.png?h=76&w=76',
204
209
  },
205
- "content": null,
206
- "tag": "link"
210
+ content: null,
211
+ tag: 'link',
207
212
  },
208
213
  {
209
- "attributes": {
210
- "sizes": "114x114",
211
- "rel": "apple-touch-icon",
212
- "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=114&w=114"
214
+ attributes: {
215
+ sizes: '114x114',
216
+ rel: 'apple-touch-icon',
217
+ href: 'https://www.datocms-assets.com/205/1525789775-dato.png?h=114&w=114',
213
218
  },
214
- "content": null,
215
- "tag": "link"
219
+ content: null,
220
+ tag: 'link',
216
221
  },
217
222
  {
218
- "attributes": {
219
- "sizes": "120x120",
220
- "rel": "apple-touch-icon",
221
- "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=120&w=120"
223
+ attributes: {
224
+ sizes: '120x120',
225
+ rel: 'apple-touch-icon',
226
+ href: 'https://www.datocms-assets.com/205/1525789775-dato.png?h=120&w=120',
222
227
  },
223
- "content": null,
224
- "tag": "link"
228
+ content: null,
229
+ tag: 'link',
225
230
  },
226
231
  {
227
- "attributes": {
228
- "sizes": "144x144",
229
- "rel": "apple-touch-icon",
230
- "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=144&w=144"
232
+ attributes: {
233
+ sizes: '144x144',
234
+ rel: 'apple-touch-icon',
235
+ href: 'https://www.datocms-assets.com/205/1525789775-dato.png?h=144&w=144',
231
236
  },
232
- "content": null,
233
- "tag": "link"
237
+ content: null,
238
+ tag: 'link',
234
239
  },
235
240
  {
236
- "attributes": {
237
- "sizes": "152x152",
238
- "rel": "apple-touch-icon",
239
- "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=152&w=152"
241
+ attributes: {
242
+ sizes: '152x152',
243
+ rel: 'apple-touch-icon',
244
+ href: 'https://www.datocms-assets.com/205/1525789775-dato.png?h=152&w=152',
240
245
  },
241
- "content": null,
242
- "tag": "link"
246
+ content: null,
247
+ tag: 'link',
243
248
  },
244
249
  {
245
- "attributes": {
246
- "sizes": "180x180",
247
- "rel": "apple-touch-icon",
248
- "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=180&w=180"
250
+ attributes: {
251
+ sizes: '180x180',
252
+ rel: 'apple-touch-icon',
253
+ href: 'https://www.datocms-assets.com/205/1525789775-dato.png?h=180&w=180',
249
254
  },
250
- "content": null,
251
- "tag": "link"
255
+ content: null,
256
+ tag: 'link',
252
257
  },
253
258
  {
254
- "attributes": {
255
- "name": "msapplication-square70x70logo",
256
- "content": "https://www.datocms-assets.com/205/1525789775-dato.png?h=70&w=70"
259
+ attributes: {
260
+ name: 'msapplication-square70x70logo',
261
+ content:
262
+ 'https://www.datocms-assets.com/205/1525789775-dato.png?h=70&w=70',
257
263
  },
258
- "content": null,
259
- "tag": "meta"
264
+ content: null,
265
+ tag: 'meta',
260
266
  },
261
267
  {
262
- "attributes": {
263
- "name": "msapplication-square150x150logo",
264
- "content": "https://www.datocms-assets.com/205/1525789775-dato.png?h=150&w=150"
268
+ attributes: {
269
+ name: 'msapplication-square150x150logo',
270
+ content:
271
+ 'https://www.datocms-assets.com/205/1525789775-dato.png?h=150&w=150',
265
272
  },
266
- "content": null,
267
- "tag": "meta"
273
+ content: null,
274
+ tag: 'meta',
268
275
  },
269
276
  {
270
- "attributes": {
271
- "name": "msapplication-square310x310logo",
272
- "content": "https://www.datocms-assets.com/205/1525789775-dato.png?h=310&w=310"
277
+ attributes: {
278
+ name: 'msapplication-square310x310logo',
279
+ content:
280
+ 'https://www.datocms-assets.com/205/1525789775-dato.png?h=310&w=310',
273
281
  },
274
- "content": null,
275
- "tag": "meta"
282
+ content: null,
283
+ tag: 'meta',
276
284
  },
277
285
  {
278
- "attributes": {
279
- "name": "msapplication-square310x150logo",
280
- "content": "https://www.datocms-assets.com/205/1525789775-dato.png?h=150&w=310"
286
+ attributes: {
287
+ name: 'msapplication-square310x150logo',
288
+ content:
289
+ 'https://www.datocms-assets.com/205/1525789775-dato.png?h=150&w=310',
281
290
  },
282
- "content": null,
283
- "tag": "meta"
284
- }
291
+ content: null,
292
+ tag: 'meta',
293
+ },
285
294
  ];
286
295
 
287
- describe("renderMetaTags", () => {
288
- it("generates an array of meta tags", () => {
289
- const wrapper = shallow(
290
- <head>
291
- {renderMetaTags(metaTags)}
292
- </head>
293
- );
296
+ describe('renderMetaTags', () => {
297
+ it('generates an array of meta tags', () => {
298
+ const wrapper = shallow(<head>{renderMetaTags(metaTags)}</head>);
294
299
 
295
300
  expect(wrapper).toMatchSnapshot();
296
301
  });
297
302
  });
298
303
 
299
- describe("renderMetaTagsToString", () => {
300
- it("generates an array of meta tags", () => {
304
+ describe('renderMetaTagsToString', () => {
305
+ it('generates an array of meta tags', () => {
301
306
  expect(renderMetaTagsToString(metaTags)).toMatchSnapshot();
302
307
  });
303
308
  });
304
309
 
305
- describe("toRemixMeta", () => {
306
- it("generates a meta descriptor", () => {
310
+ describe('toRemixMeta', () => {
311
+ it('generates a meta descriptor', () => {
307
312
  expect(toRemixMeta(metaTags)).toMatchSnapshot();
308
313
  });
309
- });
314
+ });
package/src/Seo/index.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './types';
2
2
  export * from './remixUtils';
3
3
  export * from './renderMetaTags';
4
- export * from './renderMetaTagsToString';
4
+ export * from './renderMetaTagsToString';
@@ -144,7 +144,8 @@ describe('StructuredText', () => {
144
144
  };
145
145
 
146
146
  const structuredText: StructuredTextGraphQlResponse<
147
- QuoteRecord, DocPageRecord
147
+ QuoteRecord,
148
+ DocPageRecord
148
149
  > = {
149
150
  value: {
150
151
  schema: 'dast',
@@ -147,7 +147,7 @@ export function StructuredText<
147
147
  );
148
148
  }
149
149
 
150
- if (!isStructuredText(data) || !data.links) {
150
+ if (!(isStructuredText(data) && data.links)) {
151
151
  throw new RenderError(
152
152
  `The document contains an 'itemLink' node, but the passed data prop is not a Structured Text GraphQL response, or data.links is not present!`,
153
153
  node,
@@ -176,7 +176,7 @@ export function StructuredText<
176
176
  );
177
177
  }
178
178
 
179
- if (!isStructuredText(data) || !data.links) {
179
+ if (!(isStructuredText(data) && data.links)) {
180
180
  throw new RenderError(
181
181
  `The document contains an 'itemLink' node, but the passed data prop is not a Structured Text GraphQL response, or data.links is not present!`,
182
182
  node,
@@ -214,7 +214,7 @@ export function StructuredText<
214
214
  );
215
215
  }
216
216
 
217
- if (!isStructuredText(data) || !data.blocks) {
217
+ if (!(isStructuredText(data) && data.blocks)) {
218
218
  throw new RenderError(
219
219
  `The document contains an 'block' node, but the passed data prop is not a Structured Text GraphQL response, or data.blocks is not present!`,
220
220
  node,
package/src/setupTests.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { configure } from 'enzyme'
1
+ import { configure } from 'enzyme';
2
2
  import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
3
3
 
4
4
  configure({
5
5
  adapter: new Adapter(),
6
- })
6
+ });
@@ -6,7 +6,9 @@ import {
6
6
  ConnectionStatus,
7
7
  Options,
8
8
  } from 'datocms-listen';
9
- import { useDeepCompareEffectNoCheck as useDeepCompareEffect } from 'use-deep-compare-effect';
9
+ import {
10
+ useDeepCompareEffectNoCheck as useDeepCompareEffect,
11
+ } from 'use-deep-compare-effect';
10
12
 
11
13
  export type SubscribeToQueryOptions<QueryResult, QueryVariables> = Omit<
12
14
  Options<QueryResult, QueryVariables>,