@alpaca-headless/alpaca-headless-nextjs 1.0.2692 → 1.0.2694

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.
@@ -29,6 +29,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
29
29
  const Picture = (_a) => {
30
30
  var _b, _c, _d, _e;
31
31
  var { field, imageParams, sources, defaultVariant } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant"]);
32
+ if (!field)
33
+ return;
32
34
  const variants = (_b = field === null || field === void 0 ? void 0 : field.value) === null || _b === void 0 ? void 0 : _b.variants;
33
35
  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
36
  const attrs = Object.assign(Object.assign({}, img), otherProps);
@@ -16,6 +16,8 @@ exports.RichText = void 0;
16
16
  const react_1 = __importDefault(require("react"));
17
17
  function RichText({ field, tag, editable, }) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
+ if (!field)
20
+ return;
19
21
  const props = {
20
22
  dangerouslySetInnerHTML: {
21
23
  __html: field.value,
@@ -16,6 +16,8 @@ exports.Text = void 0;
16
16
  const react_1 = __importDefault(require("react"));
17
17
  function Text({ field, tag, editable, }) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
+ if (!field)
20
+ return;
19
21
  if (editable)
20
22
  return react_1.default.createElement(tag || "div", null, field.value);
21
23
  else
@@ -31,7 +31,10 @@ const fetchRouteData = (0, react_1.cache)((path, host, mode, itemId, language) =
31
31
  "Content-Type": "application/json",
32
32
  Cookie: (0, headers_1.cookies)().toString(),
33
33
  },
34
- next: { tags: ["pages"], revalidate: 10 },
34
+ next: {
35
+ tags: ["pages"],
36
+ revalidate: mode === "preview" || mode == "edit" ? 0 : 30,
37
+ },
35
38
  });
36
39
  if (response.status === 404) {
37
40
  return {
@@ -26,6 +26,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
26
26
  export const Picture = (_a) => {
27
27
  var _b, _c, _d, _e;
28
28
  var { field, imageParams, sources, defaultVariant } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant"]);
29
+ if (!field)
30
+ return;
29
31
  const variants = (_b = field === null || field === void 0 ? void 0 : field.value) === null || _b === void 0 ? void 0 : _b.variants;
30
32
  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
33
  const attrs = Object.assign(Object.assign({}, img), otherProps);
@@ -10,6 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import React from "react";
11
11
  export function RichText({ field, tag, editable, }) {
12
12
  return __awaiter(this, void 0, void 0, function* () {
13
+ if (!field)
14
+ return;
13
15
  const props = {
14
16
  dangerouslySetInnerHTML: {
15
17
  __html: field.value,
@@ -10,6 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import React from "react";
11
11
  export function Text({ field, tag, editable, }) {
12
12
  return __awaiter(this, void 0, void 0, function* () {
13
+ if (!field)
14
+ return;
13
15
  if (editable)
14
16
  return React.createElement(tag || "div", null, field.value);
15
17
  else
@@ -28,7 +28,10 @@ const fetchRouteData = cache((path, host, mode, itemId, language) => __awaiter(v
28
28
  "Content-Type": "application/json",
29
29
  Cookie: cookies().toString(),
30
30
  },
31
- next: { tags: ["pages"], revalidate: 10 },
31
+ next: {
32
+ tags: ["pages"],
33
+ revalidate: mode === "preview" || mode == "edit" ? 0 : 30,
34
+ },
32
35
  });
33
36
  if (response.status === 404) {
34
37
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpaca-headless/alpaca-headless-nextjs",
3
- "version": "1.0.2692",
3
+ "version": "1.0.2694",
4
4
  "description": "Alpaca Headless NextJs Integration",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -9,4 +9,4 @@ export declare function RichText({ field, tag, editable, }: {
9
9
  __html: string;
10
10
  };
11
11
  editable: boolean | undefined;
12
- }, Element>>;
12
+ }, Element> | undefined>;
@@ -4,4 +4,4 @@ export declare function Text({ field, tag, editable, }: {
4
4
  field: TextField;
5
5
  tag?: string;
6
6
  editable?: boolean;
7
- }): Promise<React.DOMElement<React.DOMAttributes<Element>, Element>>;
7
+ }): Promise<React.DOMElement<React.DOMAttributes<Element>, Element> | undefined>;