react-datocms 4.0.4 → 4.0.6
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/dist/cjs/Image/index.js +9 -16
- package/dist/cjs/Image/index.js.map +1 -1
- package/dist/cjs/Seo/__tests__/index.test.js +187 -187
- package/dist/cjs/Seo/__tests__/index.test.js.map +1 -1
- package/dist/cjs/StructuredText/__tests__/index.test.js.map +1 -1
- package/dist/cjs/StructuredText/index.js +3 -3
- package/dist/cjs/StructuredText/index.js.map +1 -1
- package/dist/cjs/setupTests.js.map +1 -1
- package/dist/cjs/useQuerySubscription/index.js.map +1 -1
- package/dist/esm/Image/index.d.ts +4 -0
- package/dist/esm/Image/index.js +9 -16
- package/dist/esm/Image/index.js.map +1 -1
- package/dist/esm/Seo/__tests__/index.test.js +190 -190
- package/dist/esm/Seo/__tests__/index.test.js.map +1 -1
- package/dist/esm/StructuredText/__tests__/index.test.js.map +1 -1
- package/dist/esm/StructuredText/index.js +3 -3
- package/dist/esm/StructuredText/index.js.map +1 -1
- package/dist/esm/setupTests.js.map +1 -1
- package/dist/esm/useQuerySubscription/index.js +1 -1
- package/dist/esm/useQuerySubscription/index.js.map +1 -1
- package/dist/types/Image/index.d.ts +4 -0
- package/package.json +3 -1
- package/src/Image/__tests__/__snapshots__/index.test.tsx.snap +64 -0
- package/src/Image/index.tsx +16 -2
- package/src/Seo/__tests__/index.test.tsx +202 -197
- package/src/Seo/index.ts +1 -1
- package/src/StructuredText/__tests__/index.test.tsx +2 -1
- package/src/StructuredText/index.tsx +3 -3
- package/src/setupTests.ts +2 -2
- package/src/useQuerySubscription/index.ts +3 -1
|
@@ -1,309 +1,314 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { shallow } from
|
|
3
|
-
import { renderMetaTags, renderMetaTagsToString, toRemixMeta } from
|
|
4
|
-
import { TitleMetaLinkTag } from
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
content: 'Remix CMS - The easiest way to manage content with Remix',
|
|
9
|
+
attributes: null,
|
|
10
|
+
tag: 'title',
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
content: null,
|
|
14
|
+
attributes: {
|
|
15
|
+
property: 'og:title',
|
|
16
|
+
content: 'Remix CMS - The easiest way to manage content with Remix',
|
|
17
17
|
},
|
|
18
|
-
|
|
18
|
+
tag: 'meta',
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
content: null,
|
|
22
|
+
attributes: {
|
|
23
|
+
name: 'twitter:title',
|
|
24
|
+
content: 'Remix CMS - The easiest way to manage content with Remix',
|
|
25
25
|
},
|
|
26
|
-
|
|
26
|
+
tag: 'meta',
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
35
|
+
tag: 'meta',
|
|
35
36
|
},
|
|
36
37
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
44
|
+
tag: 'meta',
|
|
43
45
|
},
|
|
44
46
|
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
53
|
+
tag: 'meta',
|
|
51
54
|
},
|
|
52
55
|
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
62
|
+
tag: 'meta',
|
|
59
63
|
},
|
|
60
64
|
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
content: null,
|
|
66
|
+
attributes: {
|
|
67
|
+
property: 'og:image:width',
|
|
68
|
+
content: '746',
|
|
65
69
|
},
|
|
66
|
-
|
|
70
|
+
tag: 'meta',
|
|
67
71
|
},
|
|
68
72
|
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
content: null,
|
|
74
|
+
attributes: {
|
|
75
|
+
property: 'og:image:height',
|
|
76
|
+
content: '186',
|
|
73
77
|
},
|
|
74
|
-
|
|
78
|
+
tag: 'meta',
|
|
75
79
|
},
|
|
76
80
|
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
87
|
+
tag: 'meta',
|
|
83
88
|
},
|
|
84
89
|
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
content: null,
|
|
91
|
+
attributes: {
|
|
92
|
+
property: 'og:locale',
|
|
93
|
+
content: 'en',
|
|
89
94
|
},
|
|
90
|
-
|
|
95
|
+
tag: 'meta',
|
|
91
96
|
},
|
|
92
97
|
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
content: null,
|
|
99
|
+
attributes: {
|
|
100
|
+
property: 'og:type',
|
|
101
|
+
content: 'article',
|
|
97
102
|
},
|
|
98
|
-
|
|
103
|
+
tag: 'meta',
|
|
99
104
|
},
|
|
100
105
|
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
content: null,
|
|
107
|
+
attributes: {
|
|
108
|
+
property: 'og:site_name',
|
|
109
|
+
content: 'DatoCMS',
|
|
105
110
|
},
|
|
106
|
-
|
|
111
|
+
tag: 'meta',
|
|
107
112
|
},
|
|
108
113
|
{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
content: null,
|
|
115
|
+
attributes: {
|
|
116
|
+
property: 'article:modified_time',
|
|
117
|
+
content: '2022-01-18T14:02:47Z',
|
|
113
118
|
},
|
|
114
|
-
|
|
119
|
+
tag: 'meta',
|
|
115
120
|
},
|
|
116
121
|
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
content: null,
|
|
123
|
+
attributes: {
|
|
124
|
+
name: 'twitter:card',
|
|
125
|
+
content: 'summary_large_image',
|
|
121
126
|
},
|
|
122
|
-
|
|
127
|
+
tag: 'meta',
|
|
123
128
|
},
|
|
124
129
|
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
content: null,
|
|
131
|
+
attributes: {
|
|
132
|
+
name: 'twitter:site',
|
|
133
|
+
content: '@datocms',
|
|
129
134
|
},
|
|
130
|
-
|
|
135
|
+
tag: 'meta',
|
|
131
136
|
},
|
|
132
137
|
{
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
140
|
-
|
|
144
|
+
content: null,
|
|
145
|
+
tag: 'link',
|
|
141
146
|
},
|
|
142
147
|
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
150
|
-
|
|
154
|
+
content: null,
|
|
155
|
+
tag: 'link',
|
|
151
156
|
},
|
|
152
157
|
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
160
|
-
|
|
164
|
+
content: null,
|
|
165
|
+
tag: 'link',
|
|
161
166
|
},
|
|
162
167
|
{
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
170
|
-
|
|
174
|
+
content: null,
|
|
175
|
+
tag: 'link',
|
|
171
176
|
},
|
|
172
177
|
{
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
179
|
-
|
|
183
|
+
content: null,
|
|
184
|
+
tag: 'link',
|
|
180
185
|
},
|
|
181
186
|
{
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
188
|
-
|
|
192
|
+
content: null,
|
|
193
|
+
tag: 'link',
|
|
189
194
|
},
|
|
190
195
|
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
197
|
-
|
|
201
|
+
content: null,
|
|
202
|
+
tag: 'link',
|
|
198
203
|
},
|
|
199
204
|
{
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
206
|
-
|
|
210
|
+
content: null,
|
|
211
|
+
tag: 'link',
|
|
207
212
|
},
|
|
208
213
|
{
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
-
|
|
215
|
-
|
|
219
|
+
content: null,
|
|
220
|
+
tag: 'link',
|
|
216
221
|
},
|
|
217
222
|
{
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
-
|
|
224
|
-
|
|
228
|
+
content: null,
|
|
229
|
+
tag: 'link',
|
|
225
230
|
},
|
|
226
231
|
{
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
|
|
233
|
-
|
|
237
|
+
content: null,
|
|
238
|
+
tag: 'link',
|
|
234
239
|
},
|
|
235
240
|
{
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
242
|
-
|
|
246
|
+
content: null,
|
|
247
|
+
tag: 'link',
|
|
243
248
|
},
|
|
244
249
|
{
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
251
|
-
|
|
255
|
+
content: null,
|
|
256
|
+
tag: 'link',
|
|
252
257
|
},
|
|
253
258
|
{
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
259
|
-
|
|
264
|
+
content: null,
|
|
265
|
+
tag: 'meta',
|
|
260
266
|
},
|
|
261
267
|
{
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
|
|
267
|
-
|
|
273
|
+
content: null,
|
|
274
|
+
tag: 'meta',
|
|
268
275
|
},
|
|
269
276
|
{
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
-
|
|
275
|
-
|
|
282
|
+
content: null,
|
|
283
|
+
tag: 'meta',
|
|
276
284
|
},
|
|
277
285
|
{
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
291
|
+
content: null,
|
|
292
|
+
tag: 'meta',
|
|
293
|
+
},
|
|
285
294
|
];
|
|
286
295
|
|
|
287
|
-
describe(
|
|
288
|
-
it(
|
|
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(
|
|
300
|
-
it(
|
|
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(
|
|
306
|
-
it(
|
|
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
|
@@ -147,7 +147,7 @@ export function StructuredText<
|
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
if (!isStructuredText(data)
|
|
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)
|
|
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)
|
|
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
|
@@ -6,7 +6,9 @@ import {
|
|
|
6
6
|
ConnectionStatus,
|
|
7
7
|
Options,
|
|
8
8
|
} from 'datocms-listen';
|
|
9
|
-
import {
|
|
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>,
|