@plasmicpkgs/plasmic-contentful 0.0.123 → 0.0.125
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/index.js +45 -33
- package/dist/index.mjs +45 -33
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -227,7 +227,7 @@ function ContentfulFetcher({
|
|
|
227
227
|
noLayout,
|
|
228
228
|
setControlContextData
|
|
229
229
|
}) {
|
|
230
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
230
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
231
231
|
const creds = ensure(
|
|
232
232
|
(0, import_react.useContext)(CredentialsContext),
|
|
233
233
|
"Could not find context with current credentials"
|
|
@@ -315,11 +315,13 @@ function ContentfulFetcher({
|
|
|
315
315
|
types: (_b = contentTypes == null ? void 0 : contentTypes.items) != null ? _b : [],
|
|
316
316
|
fields: uniq(filterFields != null ? filterFields : [])
|
|
317
317
|
});
|
|
318
|
-
if (filterField
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
318
|
+
if (filterField) {
|
|
319
|
+
if (!searchParameter) {
|
|
320
|
+
return /* @__PURE__ */ import_react.default.createElement("div", null, "Please specify a Search Parameter");
|
|
321
|
+
}
|
|
322
|
+
if (!filterValue) {
|
|
323
|
+
return /* @__PURE__ */ import_react.default.createElement("div", null, "Please specify a Filter value");
|
|
324
|
+
}
|
|
323
325
|
}
|
|
324
326
|
function denormalizeData(data) {
|
|
325
327
|
if (!(data == null ? void 0 : data.items) || !(data == null ? void 0 : data.includes)) {
|
|
@@ -338,32 +340,41 @@ function ContentfulFetcher({
|
|
|
338
340
|
return denormalizeField(arrayItem);
|
|
339
341
|
});
|
|
340
342
|
return updatedArray;
|
|
341
|
-
} else if (
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
343
|
+
} else if (fieldValue && typeof fieldValue === "object") {
|
|
344
|
+
if (data.includes.Asset && "sys" in fieldValue && fieldValue.sys.linkType === "Asset") {
|
|
345
|
+
const fieldId = fieldValue.sys.id;
|
|
346
|
+
const asset = data.includes.Asset.find(
|
|
347
|
+
(a) => a.sys.id === fieldId
|
|
348
|
+
);
|
|
349
|
+
if (asset) {
|
|
350
|
+
fieldValue = {
|
|
351
|
+
...fieldValue,
|
|
352
|
+
url: "https:" + ((_b2 = (_a2 = asset.fields) == null ? void 0 : _a2.file) == null ? void 0 : _b2.url)
|
|
353
|
+
};
|
|
354
|
+
} else {
|
|
355
|
+
console.log(`Asset URL not found for ID: ${fieldId}`);
|
|
356
|
+
}
|
|
357
|
+
} else if (data.includes.Entry && "sys" in fieldValue && fieldValue.sys.linkType === "Entry") {
|
|
358
|
+
const fieldId = fieldValue.sys.id;
|
|
359
|
+
if (entryMap[fieldId]) {
|
|
360
|
+
fieldValue = {
|
|
361
|
+
...fieldValue,
|
|
362
|
+
fields: denormalizeItem(entryMap[fieldId]).fields
|
|
363
|
+
};
|
|
364
|
+
} else {
|
|
365
|
+
console.log(`Entry not found for ID: ${fieldId}`);
|
|
366
|
+
}
|
|
363
367
|
}
|
|
364
|
-
|
|
365
|
-
|
|
368
|
+
fieldValue = Object.entries(fieldValue).reduce((obj, [key, value]) => {
|
|
369
|
+
if (key === "sys" || key === "fields") {
|
|
370
|
+
obj[key] = value;
|
|
371
|
+
} else {
|
|
372
|
+
obj[key] = denormalizeField(value);
|
|
373
|
+
}
|
|
374
|
+
return obj;
|
|
375
|
+
}, {});
|
|
366
376
|
}
|
|
377
|
+
return fieldValue;
|
|
367
378
|
};
|
|
368
379
|
const denormalizeItem = (item) => {
|
|
369
380
|
const updatedFields = {};
|
|
@@ -384,6 +395,7 @@ function ContentfulFetcher({
|
|
|
384
395
|
};
|
|
385
396
|
}
|
|
386
397
|
let renderedData;
|
|
398
|
+
const fixedData = entriesData ? denormalizeData(entriesData) : void 0;
|
|
387
399
|
if (filteredData) {
|
|
388
400
|
if (((_c = filteredData == null ? void 0 : filteredData.items) == null ? void 0 : _c.length) === 0) {
|
|
389
401
|
return /* @__PURE__ */ import_react.default.createElement("div", { className }, "No published entry found");
|
|
@@ -411,10 +423,10 @@ function ContentfulFetcher({
|
|
|
411
423
|
}
|
|
412
424
|
);
|
|
413
425
|
} else {
|
|
414
|
-
if (((_f =
|
|
426
|
+
if (((_f = fixedData == null ? void 0 : fixedData.items) == null ? void 0 : _f.length) === 0) {
|
|
415
427
|
return /* @__PURE__ */ import_react.default.createElement("div", { className }, contentType, " is empty");
|
|
416
428
|
}
|
|
417
|
-
renderedData = noAutoRepeat ? children : (
|
|
429
|
+
renderedData = noAutoRepeat ? children : (_g = fixedData == null ? void 0 : fixedData.items) == null ? void 0 : _g.map((item, index) => {
|
|
418
430
|
var _a2;
|
|
419
431
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
420
432
|
import_host.DataProvider,
|
|
@@ -428,7 +440,7 @@ function ContentfulFetcher({
|
|
|
428
440
|
);
|
|
429
441
|
});
|
|
430
442
|
}
|
|
431
|
-
return /* @__PURE__ */ import_react.default.createElement(import_host.DataProvider, { name: "contentfulItems", data:
|
|
443
|
+
return /* @__PURE__ */ import_react.default.createElement(import_host.DataProvider, { name: "contentfulItems", data: fixedData == null ? void 0 : fixedData.items }, noLayout ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, " ", renderedData, " ") : /* @__PURE__ */ import_react.default.createElement("div", { className }, " ", renderedData, " "));
|
|
432
444
|
}
|
|
433
445
|
var ContentfulFieldMeta = {
|
|
434
446
|
name: "ContentfulField",
|
package/dist/index.mjs
CHANGED
|
@@ -190,7 +190,7 @@ function ContentfulFetcher({
|
|
|
190
190
|
noLayout,
|
|
191
191
|
setControlContextData
|
|
192
192
|
}) {
|
|
193
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
193
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
194
194
|
const creds = ensure(
|
|
195
195
|
useContext(CredentialsContext),
|
|
196
196
|
"Could not find context with current credentials"
|
|
@@ -278,11 +278,13 @@ function ContentfulFetcher({
|
|
|
278
278
|
types: (_b = contentTypes == null ? void 0 : contentTypes.items) != null ? _b : [],
|
|
279
279
|
fields: uniq(filterFields != null ? filterFields : [])
|
|
280
280
|
});
|
|
281
|
-
if (filterField
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
281
|
+
if (filterField) {
|
|
282
|
+
if (!searchParameter) {
|
|
283
|
+
return /* @__PURE__ */ React.createElement("div", null, "Please specify a Search Parameter");
|
|
284
|
+
}
|
|
285
|
+
if (!filterValue) {
|
|
286
|
+
return /* @__PURE__ */ React.createElement("div", null, "Please specify a Filter value");
|
|
287
|
+
}
|
|
286
288
|
}
|
|
287
289
|
function denormalizeData(data) {
|
|
288
290
|
if (!(data == null ? void 0 : data.items) || !(data == null ? void 0 : data.includes)) {
|
|
@@ -301,32 +303,41 @@ function ContentfulFetcher({
|
|
|
301
303
|
return denormalizeField(arrayItem);
|
|
302
304
|
});
|
|
303
305
|
return updatedArray;
|
|
304
|
-
} else if (
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
306
|
+
} else if (fieldValue && typeof fieldValue === "object") {
|
|
307
|
+
if (data.includes.Asset && "sys" in fieldValue && fieldValue.sys.linkType === "Asset") {
|
|
308
|
+
const fieldId = fieldValue.sys.id;
|
|
309
|
+
const asset = data.includes.Asset.find(
|
|
310
|
+
(a) => a.sys.id === fieldId
|
|
311
|
+
);
|
|
312
|
+
if (asset) {
|
|
313
|
+
fieldValue = {
|
|
314
|
+
...fieldValue,
|
|
315
|
+
url: "https:" + ((_b2 = (_a2 = asset.fields) == null ? void 0 : _a2.file) == null ? void 0 : _b2.url)
|
|
316
|
+
};
|
|
317
|
+
} else {
|
|
318
|
+
console.log(`Asset URL not found for ID: ${fieldId}`);
|
|
319
|
+
}
|
|
320
|
+
} else if (data.includes.Entry && "sys" in fieldValue && fieldValue.sys.linkType === "Entry") {
|
|
321
|
+
const fieldId = fieldValue.sys.id;
|
|
322
|
+
if (entryMap[fieldId]) {
|
|
323
|
+
fieldValue = {
|
|
324
|
+
...fieldValue,
|
|
325
|
+
fields: denormalizeItem(entryMap[fieldId]).fields
|
|
326
|
+
};
|
|
327
|
+
} else {
|
|
328
|
+
console.log(`Entry not found for ID: ${fieldId}`);
|
|
329
|
+
}
|
|
326
330
|
}
|
|
327
|
-
|
|
328
|
-
|
|
331
|
+
fieldValue = Object.entries(fieldValue).reduce((obj, [key, value]) => {
|
|
332
|
+
if (key === "sys" || key === "fields") {
|
|
333
|
+
obj[key] = value;
|
|
334
|
+
} else {
|
|
335
|
+
obj[key] = denormalizeField(value);
|
|
336
|
+
}
|
|
337
|
+
return obj;
|
|
338
|
+
}, {});
|
|
329
339
|
}
|
|
340
|
+
return fieldValue;
|
|
330
341
|
};
|
|
331
342
|
const denormalizeItem = (item) => {
|
|
332
343
|
const updatedFields = {};
|
|
@@ -347,6 +358,7 @@ function ContentfulFetcher({
|
|
|
347
358
|
};
|
|
348
359
|
}
|
|
349
360
|
let renderedData;
|
|
361
|
+
const fixedData = entriesData ? denormalizeData(entriesData) : void 0;
|
|
350
362
|
if (filteredData) {
|
|
351
363
|
if (((_c = filteredData == null ? void 0 : filteredData.items) == null ? void 0 : _c.length) === 0) {
|
|
352
364
|
return /* @__PURE__ */ React.createElement("div", { className }, "No published entry found");
|
|
@@ -374,10 +386,10 @@ function ContentfulFetcher({
|
|
|
374
386
|
}
|
|
375
387
|
);
|
|
376
388
|
} else {
|
|
377
|
-
if (((_f =
|
|
389
|
+
if (((_f = fixedData == null ? void 0 : fixedData.items) == null ? void 0 : _f.length) === 0) {
|
|
378
390
|
return /* @__PURE__ */ React.createElement("div", { className }, contentType, " is empty");
|
|
379
391
|
}
|
|
380
|
-
renderedData = noAutoRepeat ? children : (
|
|
392
|
+
renderedData = noAutoRepeat ? children : (_g = fixedData == null ? void 0 : fixedData.items) == null ? void 0 : _g.map((item, index) => {
|
|
381
393
|
var _a2;
|
|
382
394
|
return /* @__PURE__ */ React.createElement(
|
|
383
395
|
DataProvider,
|
|
@@ -391,7 +403,7 @@ function ContentfulFetcher({
|
|
|
391
403
|
);
|
|
392
404
|
});
|
|
393
405
|
}
|
|
394
|
-
return /* @__PURE__ */ React.createElement(DataProvider, { name: "contentfulItems", data:
|
|
406
|
+
return /* @__PURE__ */ React.createElement(DataProvider, { name: "contentfulItems", data: fixedData == null ? void 0 : fixedData.items }, noLayout ? /* @__PURE__ */ React.createElement(React.Fragment, null, " ", renderedData, " ") : /* @__PURE__ */ React.createElement("div", { className }, " ", renderedData, " "));
|
|
395
407
|
}
|
|
396
408
|
var ContentfulFieldMeta = {
|
|
397
409
|
name: "ContentfulField",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicpkgs/plasmic-contentful",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.125",
|
|
4
4
|
"description": "Plasmic Contentful components.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
}
|
|
33
33
|
],
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@plasmicapp/host": "1.0.
|
|
35
|
+
"@plasmicapp/host": "1.0.185",
|
|
36
36
|
"@plasmicapp/query": "0.1.77",
|
|
37
37
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
38
38
|
"@types/dlv": "^1.1.2",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"change-case": "^4.1.2",
|
|
53
53
|
"dlv": "^1.1.3"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "be71b41ad94d0db53100816e00d1519793409999"
|
|
56
56
|
}
|