react-datocms 2.0.1 → 2.1.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.
Files changed (36) hide show
  1. package/README.md +90 -51
  2. package/dist/cjs/Seo/__tests__/index.test.js +277 -37
  3. package/dist/cjs/Seo/__tests__/index.test.js.map +1 -1
  4. package/dist/cjs/Seo/index.js +13 -60
  5. package/dist/cjs/Seo/index.js.map +1 -1
  6. package/dist/cjs/Seo/remixUtils.js +42 -0
  7. package/dist/cjs/Seo/remixUtils.js.map +1 -0
  8. package/dist/cjs/Seo/renderMetaTags.js +40 -0
  9. package/dist/cjs/Seo/renderMetaTags.js.map +1 -0
  10. package/dist/cjs/Seo/renderMetaTagsToString.js +22 -0
  11. package/dist/cjs/Seo/renderMetaTagsToString.js.map +1 -0
  12. package/dist/cjs/Seo/types.js +5 -0
  13. package/dist/cjs/Seo/types.js.map +1 -0
  14. package/dist/esm/Seo/__tests__/index.test.js +276 -36
  15. package/dist/esm/Seo/__tests__/index.test.js.map +1 -1
  16. package/dist/esm/Seo/index.d.ts +4 -12
  17. package/dist/esm/Seo/index.js +4 -55
  18. package/dist/esm/Seo/index.js.map +1 -1
  19. package/dist/esm/Seo/remixUtils.d.ts +24 -0
  20. package/dist/esm/Seo/remixUtils.js +37 -0
  21. package/dist/esm/Seo/remixUtils.js.map +1 -0
  22. package/dist/esm/Seo/renderMetaTags.d.ts +3 -0
  23. package/dist/esm/Seo/renderMetaTags.js +33 -0
  24. package/dist/esm/Seo/renderMetaTags.js.map +1 -0
  25. package/dist/esm/Seo/renderMetaTagsToString.d.ts +2 -0
  26. package/dist/esm/Seo/renderMetaTagsToString.js +18 -0
  27. package/dist/esm/Seo/renderMetaTagsToString.js.map +1 -0
  28. package/dist/esm/Seo/types.d.ts +37 -0
  29. package/dist/esm/Seo/types.js +4 -0
  30. package/dist/esm/Seo/types.js.map +1 -0
  31. package/dist/types/Seo/index.d.ts +4 -12
  32. package/dist/types/Seo/remixUtils.d.ts +24 -0
  33. package/dist/types/Seo/renderMetaTags.d.ts +3 -0
  34. package/dist/types/Seo/renderMetaTagsToString.d.ts +2 -0
  35. package/dist/types/Seo/types.d.ts +37 -0
  36. package/package.json +1 -1
@@ -0,0 +1,33 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import React from 'react';
13
+ export function renderMetaTags(data) {
14
+ return data.map(function (_a) {
15
+ var tag = _a.tag, attributes = _a.attributes, content = _a.content;
16
+ var key = [tag];
17
+ if (attributes && 'property' in attributes) {
18
+ key.push(attributes.property);
19
+ }
20
+ if (attributes && 'name' in attributes) {
21
+ key.push(attributes.name);
22
+ }
23
+ if (attributes && 'rel' in attributes) {
24
+ key.push(attributes.rel);
25
+ }
26
+ if (attributes && 'sizes' in attributes) {
27
+ key.push(attributes.sizes);
28
+ }
29
+ var Tag = tag;
30
+ return (React.createElement(Tag, __assign({ key: key.join('-') }, attributes), content));
31
+ });
32
+ }
33
+ //# sourceMappingURL=renderMetaTags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderMetaTags.js","sourceRoot":"","sources":["../../../src/Seo/renderMetaTags.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,UAAU,cAAc,CAAC,IAAuB;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,UAAC,EAA4B;YAA1B,GAAG,SAAA,EAAE,UAAU,gBAAA,EAAE,OAAO,aAAA;QACzC,IAAI,GAAG,GAAa,CAAC,GAAG,CAAC,CAAC;QAE1B,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,EAAE;YAC1C,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;SAC/B;QAED,IAAI,UAAU,IAAI,MAAM,IAAI,UAAU,EAAE;YACtC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SAC3B;QAED,IAAI,UAAU,IAAI,KAAK,IAAI,UAAU,EAAE;YACrC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SAC1B;QAED,IAAI,UAAU,IAAI,OAAO,IAAI,UAAU,EAAE;YACvC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SAC5B;QAED,IAAM,GAAG,GAAG,GAAG,CAAC;QAEhB,OAAO,CACL,oBAAC,GAAG,aAAC,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAM,UAAU,GACpC,OAAO,CACJ,CACP,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { SeoOrFaviconTag } from "./types";
2
+ export declare function renderMetaTagsToString(data: SeoOrFaviconTag[]): string;
@@ -0,0 +1,18 @@
1
+ export function renderMetaTagsToString(data) {
2
+ return data
3
+ .map(function (tag) {
4
+ if (tag.tag === 'title') {
5
+ return "<title>" + tag.content + "</title>";
6
+ }
7
+ var serializedAttrs = [];
8
+ for (var key in tag.attributes) {
9
+ if (Object.prototype.hasOwnProperty.call(tag.attributes, key)) {
10
+ serializedAttrs.push(key + "=\"" + tag.attributes[key] + "\"");
11
+ }
12
+ }
13
+ return "<" + tag.tag + " " + serializedAttrs.join(' ') + " />";
14
+ })
15
+ .join('\n');
16
+ }
17
+ ;
18
+ //# sourceMappingURL=renderMetaTagsToString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderMetaTagsToString.js","sourceRoot":"","sources":["../../../src/Seo/renderMetaTagsToString.tsx"],"names":[],"mappings":"AAEA,MAAM,UAAU,sBAAsB,CAAC,IAAuB;IAC5D,OAAO,IAAI;SACR,GAAG,CAAC,UAAC,GAAG;QACP,IAAI,GAAG,CAAC,GAAG,KAAK,OAAO,EAAE;YACvB,OAAO,YAAU,GAAG,CAAC,OAAO,aAAU,CAAC;SACxC;QAED,IAAM,eAAe,GAAG,EAAE,CAAC;QAE3B,KAAK,IAAM,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE;YAChC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE;gBAC7D,eAAe,CAAC,IAAI,CAAI,GAAG,WAAM,GAAG,CAAC,UAAkB,CAAC,GAAG,CAAC,OAAG,CAAC,CAAC;aAClE;SACF;QAED,OAAO,MAAI,GAAG,CAAC,GAAG,SAAI,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,QAAK,CAAC;IACvD,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAAA,CAAC"}
@@ -0,0 +1,37 @@
1
+ export interface SeoTitleTag {
2
+ tag: 'title';
3
+ content: string | null;
4
+ attributes?: null;
5
+ }
6
+ export interface RegularMetaAttributes {
7
+ name: string;
8
+ content: string;
9
+ }
10
+ export interface OgMetaAttributes {
11
+ property: string;
12
+ content: string;
13
+ }
14
+ export interface SeoMetaTag {
15
+ tag: 'meta';
16
+ content?: null;
17
+ attributes: RegularMetaAttributes | OgMetaAttributes;
18
+ }
19
+ export interface FaviconAttributes {
20
+ sizes: string;
21
+ type: string;
22
+ rel: string;
23
+ href: string;
24
+ }
25
+ export interface AppleTouchIconAttributes {
26
+ sizes: string;
27
+ rel: 'apple-touch-icon';
28
+ href: string;
29
+ }
30
+ export interface SeoLinkTag {
31
+ tag: 'link';
32
+ content?: null;
33
+ attributes: FaviconAttributes | AppleTouchIconAttributes;
34
+ }
35
+ export declare type SeoTag = SeoTitleTag | SeoMetaTag;
36
+ export declare type FaviconTag = SeoMetaTag | SeoLinkTag;
37
+ export declare type SeoOrFaviconTag = SeoTag | FaviconTag;
@@ -0,0 +1,4 @@
1
+ ;
2
+ ;
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/Seo/types.tsx"],"names":[],"mappings":"AASC,CAAC;AAKD,CAAC"}
@@ -1,12 +1,4 @@
1
- /// <reference types="react" />
2
- export declare type SeoMetaTagType = {
3
- /** the tag for the meta information */
4
- tag: string;
5
- /** the inner content of the meta tag */
6
- content: string | null;
7
- /** the HTML attributes to attach to the meta tag */
8
- attributes: Record<string, string> | null;
9
- };
10
- export declare type ToMetaTagsType = SeoMetaTagType[];
11
- export declare const renderMetaTags: (data: SeoMetaTagType[]) => JSX.Element[];
12
- export declare const renderMetaTagsToString: (data: SeoMetaTagType[]) => string;
1
+ export * from './types';
2
+ export * from './remixUtils';
3
+ export * from './renderMetaTags';
4
+ export * from './renderMetaTagsToString';
@@ -0,0 +1,24 @@
1
+ import { SeoOrFaviconTag } from './types';
2
+ interface RemixHtmlMetaDescriptor {
3
+ [name: string]: string | string[];
4
+ }
5
+ interface RemixHtmlLinkDescriptor {
6
+ href: string;
7
+ crossOrigin?: 'anonymous' | 'use-credentials';
8
+ rel: string;
9
+ media?: string;
10
+ integrity?: string;
11
+ hrefLang?: string;
12
+ type?: string;
13
+ referrerPolicy?: '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'same-origin' | 'origin' | 'strict-origin' | 'origin-when-cross-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
14
+ sizes?: string;
15
+ imagesrcset?: string;
16
+ imagesizes?: string;
17
+ as?: string;
18
+ color?: string;
19
+ disabled?: boolean;
20
+ title?: string;
21
+ }
22
+ export declare function toRemixMeta(metaTags: null | SeoOrFaviconTag[]): RemixHtmlMetaDescriptor;
23
+ export declare function toRemixLinks(metaTags: null | SeoOrFaviconTag[]): RemixHtmlLinkDescriptor[];
24
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { SeoOrFaviconTag } from './types';
3
+ export declare function renderMetaTags(data: SeoOrFaviconTag[]): JSX.Element[];
@@ -0,0 +1,2 @@
1
+ import { SeoOrFaviconTag } from "./types";
2
+ export declare function renderMetaTagsToString(data: SeoOrFaviconTag[]): string;
@@ -0,0 +1,37 @@
1
+ export interface SeoTitleTag {
2
+ tag: 'title';
3
+ content: string | null;
4
+ attributes?: null;
5
+ }
6
+ export interface RegularMetaAttributes {
7
+ name: string;
8
+ content: string;
9
+ }
10
+ export interface OgMetaAttributes {
11
+ property: string;
12
+ content: string;
13
+ }
14
+ export interface SeoMetaTag {
15
+ tag: 'meta';
16
+ content?: null;
17
+ attributes: RegularMetaAttributes | OgMetaAttributes;
18
+ }
19
+ export interface FaviconAttributes {
20
+ sizes: string;
21
+ type: string;
22
+ rel: string;
23
+ href: string;
24
+ }
25
+ export interface AppleTouchIconAttributes {
26
+ sizes: string;
27
+ rel: 'apple-touch-icon';
28
+ href: string;
29
+ }
30
+ export interface SeoLinkTag {
31
+ tag: 'link';
32
+ content?: null;
33
+ attributes: FaviconAttributes | AppleTouchIconAttributes;
34
+ }
35
+ export declare type SeoTag = SeoTitleTag | SeoMetaTag;
36
+ export declare type FaviconTag = SeoMetaTag | SeoLinkTag;
37
+ export declare type SeoOrFaviconTag = SeoTag | FaviconTag;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-datocms",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "types": "dist/types/index.d.ts",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",