react-datocms 4.2.2 → 5.0.0

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,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toRemixMeta = void 0;
4
- function toRemixMeta(metaTags) {
3
+ exports.toRemixMeta = exports.toRemixV1Meta = void 0;
4
+ function toRemixV1Meta(metaTags) {
5
5
  if (!metaTags) {
6
6
  return {};
7
7
  }
@@ -20,5 +20,18 @@ function toRemixMeta(metaTags) {
20
20
  : tag.attributes.name]: tag.attributes.content });
21
21
  }, {});
22
22
  }
23
+ exports.toRemixV1Meta = toRemixV1Meta;
24
+ function toRemixMeta(tags) {
25
+ if (!tags) {
26
+ return [];
27
+ }
28
+ return tags
29
+ .map((x) => {
30
+ if (x.tag === 'title' && x.content)
31
+ return { title: x.content };
32
+ return x.attributes;
33
+ })
34
+ .filter((x) => Boolean(x));
35
+ }
23
36
  exports.toRemixMeta = toRemixMeta;
24
37
  //# sourceMappingURL=remixUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"remixUtils.js","sourceRoot":"","sources":["../../../src/Seo/remixUtils.ts"],"names":[],"mappings":";;;AAMA,SAAgB,WAAW,CACzB,QAAuD;IAEvD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAQ,QAA+B,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1D,IAAI,GAAG,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;YACxB,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC,iCAAM,GAAG,KAAE,KAAK,EAAE,GAAG,CAAC,OAAO,IAAG,CAAC,CAAC,GAAG,CAAC;QAC5D,CAAC;QAED,IAAI,GAAG,CAAC,GAAG,KAAK,MAAM,EAAE,CAAC;YACvB,OAAO,GAAG,CAAC;QACb,CAAC;QA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A3BD,sCA2BC;AAED,SAAgB,WAAW,CACzB,IAAmD;IAEnD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,CAAC,OAAO;YAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QAChE,OAAO,CAAC,CAAC,UAAU,CAAC;IACtB,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAA8B,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAbD,kCAaC"}
@@ -1,4 +1,4 @@
1
- export function toRemixMeta(metaTags) {
1
+ export function toRemixV1Meta(metaTags) {
2
2
  if (!metaTags) {
3
3
  return {};
4
4
  }
@@ -17,4 +17,16 @@ export function toRemixMeta(metaTags) {
17
17
  : tag.attributes.name]: tag.attributes.content });
18
18
  }, {});
19
19
  }
20
+ export function toRemixMeta(tags) {
21
+ if (!tags) {
22
+ return [];
23
+ }
24
+ return tags
25
+ .map((x) => {
26
+ if (x.tag === 'title' && x.content)
27
+ return { title: x.content };
28
+ return x.attributes;
29
+ })
30
+ .filter((x) => Boolean(x));
31
+ }
20
32
  //# sourceMappingURL=remixUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"remixUtils.js","sourceRoot":"","sources":["../../../src/Seo/remixUtils.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,WAAW,CACzB,QAAuD;IAEvD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAQ,QAA+B,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1D,IAAI,GAAG,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;YACxB,OAAO,GAAG,CAAC,OAAO,C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,GAAG,CAAC,UAAU,CAAC,QAAQ;gBACzB,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,OAAO,IAChD;IACJ,CAAC,EAAE,EAA+B,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,IAAmD;IAEnD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,CAAC,OAAO;YAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QAChE,OAAO,CAAC,CAAC,UAAU,CAAC;IACtB,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAA8B,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { SeoOrFaviconTag, TitleMetaLinkTag } from './types.js';
2
- interface RemixHtmlMetaDescriptor {
2
+ interface RemixV1HtmlMetaDescriptor {
3
3
  [name: string]: string | string[];
4
4
  }
5
- export declare function toRemixMeta(metaTags: null | TitleMetaLinkTag[] | SeoOrFaviconTag[]): RemixHtmlMetaDescriptor;
5
+ export declare function toRemixV1Meta(metaTags: null | TitleMetaLinkTag[] | SeoOrFaviconTag[]): RemixV1HtmlMetaDescriptor;
6
+ export declare function toRemixMeta(tags: null | TitleMetaLinkTag[] | SeoOrFaviconTag[]): NonNullable<Record<string, string> | import("./types.js").RegularMetaAttributes | import("./types.js").OgMetaAttributes | import("./types.js").FaviconAttributes | import("./types.js").AppleTouchIconAttributes | null | undefined>[];
6
7
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-datocms",
3
- "version": "4.2.2",
3
+ "version": "5.0.0",
4
4
  "engines": {
5
5
  "node": ">=8.0.0"
6
6
  },
@@ -316,6 +316,159 @@ exports[`toNextMetadata generates a Next Metadata object 1`] = `
316
316
  `;
317
317
 
318
318
  exports[`toRemixMeta generates a meta descriptor 1`] = `
319
+ [
320
+ {
321
+ "title": "Remix CMS - The easiest way to manage content with Remix",
322
+ },
323
+ {
324
+ "content": "Remix CMS - The easiest way to manage content with Remix",
325
+ "property": "og:title",
326
+ },
327
+ {
328
+ "content": "Remix CMS - The easiest way to manage content with Remix",
329
+ "name": "twitter:title",
330
+ },
331
+ {
332
+ "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.",
333
+ "name": "description",
334
+ },
335
+ {
336
+ "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.",
337
+ "property": "og:description",
338
+ },
339
+ {
340
+ "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.",
341
+ "name": "twitter:description",
342
+ },
343
+ {
344
+ "content": "https://www.datocms-assets.com/205/1642515293-full-logo.svg?fit=max&fm=jpg&w=1000",
345
+ "property": "og:image",
346
+ },
347
+ {
348
+ "content": "746",
349
+ "property": "og:image:width",
350
+ },
351
+ {
352
+ "content": "186",
353
+ "property": "og:image:height",
354
+ },
355
+ {
356
+ "content": "https://www.datocms-assets.com/205/1642515293-full-logo.svg?fit=max&fm=jpg&w=1000",
357
+ "name": "twitter:image",
358
+ },
359
+ {
360
+ "content": "en",
361
+ "property": "og:locale",
362
+ },
363
+ {
364
+ "content": "article",
365
+ "property": "og:type",
366
+ },
367
+ {
368
+ "content": "DatoCMS",
369
+ "property": "og:site_name",
370
+ },
371
+ {
372
+ "content": "2022-01-18T14:02:47Z",
373
+ "property": "article:modified_time",
374
+ },
375
+ {
376
+ "content": "summary_large_image",
377
+ "name": "twitter:card",
378
+ },
379
+ {
380
+ "content": "@datocms",
381
+ "name": "twitter:site",
382
+ },
383
+ {
384
+ "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=16&w=16",
385
+ "rel": "icon",
386
+ "sizes": "16x16",
387
+ "type": "image/png",
388
+ },
389
+ {
390
+ "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=32&w=32",
391
+ "rel": "icon",
392
+ "sizes": "32x32",
393
+ "type": "image/png",
394
+ },
395
+ {
396
+ "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=96&w=96",
397
+ "rel": "icon",
398
+ "sizes": "96x96",
399
+ "type": "image/png",
400
+ },
401
+ {
402
+ "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=192&w=192",
403
+ "rel": "icon",
404
+ "sizes": "192x192",
405
+ "type": "image/png",
406
+ },
407
+ {
408
+ "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=57&w=57",
409
+ "rel": "apple-touch-icon",
410
+ "sizes": "57x57",
411
+ },
412
+ {
413
+ "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=60&w=60",
414
+ "rel": "apple-touch-icon",
415
+ "sizes": "60x60",
416
+ },
417
+ {
418
+ "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=72&w=72",
419
+ "rel": "apple-touch-icon",
420
+ "sizes": "72x72",
421
+ },
422
+ {
423
+ "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=76&w=76",
424
+ "rel": "apple-touch-icon",
425
+ "sizes": "76x76",
426
+ },
427
+ {
428
+ "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=114&w=114",
429
+ "rel": "apple-touch-icon",
430
+ "sizes": "114x114",
431
+ },
432
+ {
433
+ "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=120&w=120",
434
+ "rel": "apple-touch-icon",
435
+ "sizes": "120x120",
436
+ },
437
+ {
438
+ "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=144&w=144",
439
+ "rel": "apple-touch-icon",
440
+ "sizes": "144x144",
441
+ },
442
+ {
443
+ "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=152&w=152",
444
+ "rel": "apple-touch-icon",
445
+ "sizes": "152x152",
446
+ },
447
+ {
448
+ "href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=180&w=180",
449
+ "rel": "apple-touch-icon",
450
+ "sizes": "180x180",
451
+ },
452
+ {
453
+ "content": "https://www.datocms-assets.com/205/1525789775-dato.png?h=70&w=70",
454
+ "name": "msapplication-square70x70logo",
455
+ },
456
+ {
457
+ "content": "https://www.datocms-assets.com/205/1525789775-dato.png?h=150&w=150",
458
+ "name": "msapplication-square150x150logo",
459
+ },
460
+ {
461
+ "content": "https://www.datocms-assets.com/205/1525789775-dato.png?h=310&w=310",
462
+ "name": "msapplication-square310x310logo",
463
+ },
464
+ {
465
+ "content": "https://www.datocms-assets.com/205/1525789775-dato.png?h=150&w=310",
466
+ "name": "msapplication-square310x150logo",
467
+ },
468
+ ]
469
+ `;
470
+
471
+ exports[`toRemixV1Meta generates a meta descriptor 1`] = `
319
472
  {
320
473
  "article:modified_time": "2022-01-18T14:02:47Z",
321
474
  "description": "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.",
@@ -5,6 +5,7 @@ import {
5
5
  renderMetaTagsToString,
6
6
  toNextMetadata,
7
7
  toRemixMeta,
8
+ toRemixV1Meta,
8
9
  } from '../index.js';
9
10
  import { TitleMetaLinkTag } from '../types.js';
10
11
 
@@ -312,6 +313,12 @@ describe('renderMetaTagsToString', () => {
312
313
  });
313
314
  });
314
315
 
316
+ describe('toRemixV1Meta', () => {
317
+ it('generates a meta descriptor', () => {
318
+ expect(toRemixV1Meta(metaTags)).toMatchSnapshot();
319
+ });
320
+ });
321
+
315
322
  describe('toRemixMeta', () => {
316
323
  it('generates a meta descriptor', () => {
317
324
  expect(toRemixMeta(metaTags)).toMatchSnapshot();
@@ -1,12 +1,12 @@
1
1
  import { SeoOrFaviconTag, TitleMetaLinkTag } from './types.js';
2
2
 
3
- interface RemixHtmlMetaDescriptor {
3
+ interface RemixV1HtmlMetaDescriptor {
4
4
  [name: string]: string | string[];
5
5
  }
6
6
 
7
- export function toRemixMeta(
7
+ export function toRemixV1Meta(
8
8
  metaTags: null | TitleMetaLinkTag[] | SeoOrFaviconTag[],
9
- ): RemixHtmlMetaDescriptor {
9
+ ): RemixV1HtmlMetaDescriptor {
10
10
  if (!metaTags) {
11
11
  return {};
12
12
  }
@@ -30,5 +30,20 @@ export function toRemixMeta(
30
30
  ? tag.attributes.property
31
31
  : tag.attributes.name]: tag.attributes.content,
32
32
  };
33
- }, {} as RemixHtmlMetaDescriptor);
33
+ }, {} as RemixV1HtmlMetaDescriptor);
34
+ }
35
+
36
+ export function toRemixMeta(
37
+ tags: null | TitleMetaLinkTag[] | SeoOrFaviconTag[],
38
+ ) {
39
+ if (!tags) {
40
+ return [];
41
+ }
42
+
43
+ return tags
44
+ .map((x) => {
45
+ if (x.tag === 'title' && x.content) return { title: x.content };
46
+ return x.attributes;
47
+ })
48
+ .filter((x): x is NonNullable<typeof x> => Boolean(x));
34
49
  }