@alpaca-headless/alpaca-headless-nextjs 1.0.2789 → 1.0.2790

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.
@@ -28,17 +28,17 @@ const mediaProtection_1 = require("../mediaProtection");
28
28
  // }
29
29
  // };
30
30
  const Picture = (_a) => {
31
- var _b, _c, _d, _e;
32
- var { field, imageParams, sources, defaultVariant } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant"]);
31
+ var _b, _c, _d, _e, _f, _g, _h, _j;
32
+ var { field, imageParams, sources, defaultVariant, renderJsonLinkedData } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant", "renderJsonLinkedData"]);
33
33
  if (!field)
34
- return;
35
- const variants = (_b = field === null || field === void 0 ? void 0 : field.value) === null || _b === void 0 ? void 0 : _b.variants;
36
- const img = (_d = (_c = field === null || field === void 0 ? void 0 : field.value) === null || _c === void 0 ? void 0 : _c.variants.find((x) => x.name.toUpperCase() == (defaultVariant === null || defaultVariant === void 0 ? void 0 : defaultVariant.toUpperCase()))) !== null && _d !== void 0 ? _d : (_e = field === null || field === void 0 ? void 0 : field.value) === null || _e === void 0 ? void 0 : _e.variants[0];
34
+ return null;
35
+ const variants = (_b = field.value) === null || _b === void 0 ? void 0 : _b.variants;
36
+ const img = (_d = (_c = field.value) === null || _c === void 0 ? void 0 : _c.variants.find((x) => x.name.toUpperCase() == (defaultVariant === null || defaultVariant === void 0 ? void 0 : defaultVariant.toUpperCase()))) !== null && _d !== void 0 ? _d : (_e = field.value) === null || _e === void 0 ? void 0 : _e.variants[0];
37
37
  const attrs = Object.assign({ src: img === null || img === void 0 ? void 0 : img.src }, otherProps);
38
38
  const video = img === null || img === void 0 ? void 0 : img.videoUrl;
39
39
  const videoAttr = Object.assign({ src: video }, otherProps);
40
40
  if (!(sources === null || sources === void 0 ? void 0 : sources.length)) {
41
- return (0, jsx_runtime_1.jsx)("img", Object.assign({}, attrs, { alt: "" }));
41
+ return (0, jsx_runtime_1.jsx)("img", Object.assign({}, attrs, { alt: (_f = field.value) === null || _f === void 0 ? void 0 : _f.alt }));
42
42
  }
43
43
  else {
44
44
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("picture", { children: [sources === null || sources === void 0 ? void 0 : sources.map((source) => {
@@ -88,7 +88,15 @@ const Picture = (_a) => {
88
88
  }
89
89
  }
90
90
  return ((0, jsx_runtime_1.jsx)("source", { srcSet: srcSet, media: source.media }, source.variant + source.media));
91
- }), (0, jsx_runtime_1.jsx)("img", Object.assign({}, attrs, { alt: "" }))] }), video && (0, jsx_runtime_1.jsx)("video", Object.assign({}, videoAttr))] }));
91
+ }), (0, jsx_runtime_1.jsx)("img", Object.assign({}, attrs, { alt: (_g = field.value) === null || _g === void 0 ? void 0 : _g.alt }))] }), video && (0, jsx_runtime_1.jsx)("video", Object.assign({}, videoAttr)), renderJsonLinkedData ? (0, jsx_runtime_1.jsx)("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
92
+ __html: JSON.stringify({
93
+ "@context": "http://schema.org",
94
+ "@type": "ImageObject",
95
+ "image": img === null || img === void 0 ? void 0 : img.src,
96
+ "description": (_h = field.value) === null || _h === void 0 ? void 0 : _h.alt,
97
+ "name": (_j = field.value) === null || _j === void 0 ? void 0 : _j.name
98
+ })
99
+ } }) : null] }));
92
100
  }
93
101
  };
94
102
  exports.Picture = Picture;
@@ -25,17 +25,17 @@ import { hashImageUrl } from "../mediaProtection";
25
25
  // }
26
26
  // };
27
27
  export const Picture = (_a) => {
28
- var _b, _c, _d, _e;
29
- var { field, imageParams, sources, defaultVariant } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant"]);
28
+ var _b, _c, _d, _e, _f, _g, _h, _j;
29
+ var { field, imageParams, sources, defaultVariant, renderJsonLinkedData } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant", "renderJsonLinkedData"]);
30
30
  if (!field)
31
- return;
32
- const variants = (_b = field === null || field === void 0 ? void 0 : field.value) === null || _b === void 0 ? void 0 : _b.variants;
33
- const img = (_d = (_c = field === null || field === void 0 ? void 0 : field.value) === null || _c === void 0 ? void 0 : _c.variants.find((x) => x.name.toUpperCase() == (defaultVariant === null || defaultVariant === void 0 ? void 0 : defaultVariant.toUpperCase()))) !== null && _d !== void 0 ? _d : (_e = field === null || field === void 0 ? void 0 : field.value) === null || _e === void 0 ? void 0 : _e.variants[0];
31
+ return null;
32
+ const variants = (_b = field.value) === null || _b === void 0 ? void 0 : _b.variants;
33
+ const img = (_d = (_c = field.value) === null || _c === void 0 ? void 0 : _c.variants.find((x) => x.name.toUpperCase() == (defaultVariant === null || defaultVariant === void 0 ? void 0 : defaultVariant.toUpperCase()))) !== null && _d !== void 0 ? _d : (_e = field.value) === null || _e === void 0 ? void 0 : _e.variants[0];
34
34
  const attrs = Object.assign({ src: img === null || img === void 0 ? void 0 : img.src }, otherProps);
35
35
  const video = img === null || img === void 0 ? void 0 : img.videoUrl;
36
36
  const videoAttr = Object.assign({ src: video }, otherProps);
37
37
  if (!(sources === null || sources === void 0 ? void 0 : sources.length)) {
38
- return _jsx("img", Object.assign({}, attrs, { alt: "" }));
38
+ return _jsx("img", Object.assign({}, attrs, { alt: (_f = field.value) === null || _f === void 0 ? void 0 : _f.alt }));
39
39
  }
40
40
  else {
41
41
  return (_jsxs(_Fragment, { children: [_jsxs("picture", { children: [sources === null || sources === void 0 ? void 0 : sources.map((source) => {
@@ -85,6 +85,14 @@ export const Picture = (_a) => {
85
85
  }
86
86
  }
87
87
  return (_jsx("source", { srcSet: srcSet, media: source.media }, source.variant + source.media));
88
- }), _jsx("img", Object.assign({}, attrs, { alt: "" }))] }), video && _jsx("video", Object.assign({}, videoAttr))] }));
88
+ }), _jsx("img", Object.assign({}, attrs, { alt: (_g = field.value) === null || _g === void 0 ? void 0 : _g.alt }))] }), video && _jsx("video", Object.assign({}, videoAttr)), renderJsonLinkedData ? _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
89
+ __html: JSON.stringify({
90
+ "@context": "http://schema.org",
91
+ "@type": "ImageObject",
92
+ "image": img === null || img === void 0 ? void 0 : img.src,
93
+ "description": (_h = field.value) === null || _h === void 0 ? void 0 : _h.alt,
94
+ "name": (_j = field.value) === null || _j === void 0 ? void 0 : _j.name
95
+ })
96
+ } }) : null] }));
89
97
  }
90
98
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpaca-headless/alpaca-headless-nextjs",
3
- "version": "1.0.2789",
3
+ "version": "1.0.2790",
4
4
  "description": "Alpaca Headless NextJs Integration",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -15,5 +15,6 @@ export interface PictureProps {
15
15
  };
16
16
  defaultVariant?: string;
17
17
  sources?: PictureSource[];
18
+ renderJsonLinkedData?: boolean;
18
19
  }
19
20
  export declare const Picture: React.FC<PictureProps>;
@@ -8,7 +8,7 @@ export interface LinkField {
8
8
  value: LinkValue;
9
9
  }
10
10
  export interface PictureValue {
11
- altText: string;
11
+ name: string;
12
12
  alt: string;
13
13
  variants: PictureVariant[];
14
14
  loopVideos: boolean;