@treely/strapi-slices 7.5.0 → 7.5.1
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/strapi-slices.cjs.development.js +36 -68
- package/dist/strapi-slices.cjs.development.js.map +1 -1
- package/dist/strapi-slices.cjs.production.min.js +1 -1
- package/dist/strapi-slices.cjs.production.min.js.map +1 -1
- package/dist/strapi-slices.esm.js +36 -68
- package/dist/strapi-slices.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/integrations/strapi/getAllSlugsFromStrapi.test.ts +1 -13
- package/src/integrations/strapi/getAvailableLocalesFromStrapi.test.ts +1 -1
- package/src/integrations/strapi/getStrapiCollectionType.test.ts +20 -15
- package/src/integrations/strapi/getStrapiCollectionType.ts +26 -20
|
@@ -40,11 +40,6 @@ var useEmblaCarousel__default = /*#__PURE__*/_interopDefault(useEmblaCarousel);
|
|
|
40
40
|
var AutoScroll__default = /*#__PURE__*/_interopDefault(AutoScroll);
|
|
41
41
|
var useSWRInfinite__default = /*#__PURE__*/_interopDefault(useSWRInfinite);
|
|
42
42
|
|
|
43
|
-
function _arrayLikeToArray(r, a) {
|
|
44
|
-
(null == a || a > r.length) && (a = r.length);
|
|
45
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
46
|
-
return n;
|
|
47
|
-
}
|
|
48
43
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
49
44
|
try {
|
|
50
45
|
var i = n[a](c),
|
|
@@ -70,23 +65,6 @@ function _asyncToGenerator(n) {
|
|
|
70
65
|
});
|
|
71
66
|
};
|
|
72
67
|
}
|
|
73
|
-
function _createForOfIteratorHelperLoose(r, e) {
|
|
74
|
-
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
75
|
-
if (t) return (t = t.call(r)).next.bind(t);
|
|
76
|
-
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
|
77
|
-
t && (r = t);
|
|
78
|
-
var o = 0;
|
|
79
|
-
return function () {
|
|
80
|
-
return o >= r.length ? {
|
|
81
|
-
done: !0
|
|
82
|
-
} : {
|
|
83
|
-
done: !1,
|
|
84
|
-
value: r[o++]
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
89
|
-
}
|
|
90
68
|
function _extends() {
|
|
91
69
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
92
70
|
for (var e = 1; e < arguments.length; e++) {
|
|
@@ -409,13 +387,6 @@ function _regeneratorRuntime() {
|
|
|
409
387
|
function _taggedTemplateLiteralLoose(e, t) {
|
|
410
388
|
return t || (t = e.slice(0)), e.raw = t, e;
|
|
411
389
|
}
|
|
412
|
-
function _unsupportedIterableToArray(r, a) {
|
|
413
|
-
if (r) {
|
|
414
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
415
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
416
|
-
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
390
|
|
|
420
391
|
var STRAPI_URI = process.env.NEXT_PUBLIC_STRAPI_URI || 'http://127.0.0.1:1337';
|
|
421
392
|
var STRAPI_DEFAULT_PAGE_SIZE = '100';
|
|
@@ -611,7 +582,7 @@ var getPortfolioProjects = /*#__PURE__*/function () {
|
|
|
611
582
|
|
|
612
583
|
var getStrapiCollectionType = /*#__PURE__*/function () {
|
|
613
584
|
var _ref2 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(path, key, _ref) {
|
|
614
|
-
var _ref$locale, locale, _ref$preview, preview, _ref$filters, filters, cache, allLocales,
|
|
585
|
+
var _ref$locale, locale, _ref$preview, preview, _ref$filters, filters, cache, allLocales, promises, responses, results, localizedResponses, fallbackResponses, result;
|
|
615
586
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
616
587
|
while (1) switch (_context.prev = _context.next) {
|
|
617
588
|
case 0:
|
|
@@ -624,45 +595,42 @@ var getStrapiCollectionType = /*#__PURE__*/function () {
|
|
|
624
595
|
if (!allLocales.includes(STRAPI_FALLBACK_LOCALE)) {
|
|
625
596
|
allLocales.push(STRAPI_FALLBACK_LOCALE);
|
|
626
597
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
pLevel: '6',
|
|
637
|
-
loc: loc,
|
|
638
|
-
'pagination[pageSize]': STRAPI_DEFAULT_PAGE_SIZE,
|
|
639
|
-
filters: filters
|
|
640
|
-
};
|
|
641
|
-
if (preview) {
|
|
642
|
-
params.publicationState = 'preview';
|
|
643
|
-
}
|
|
644
|
-
_context.next = 14;
|
|
645
|
-
return strapiClient.get(path, {
|
|
646
|
-
params: params,
|
|
647
|
-
cache: cache
|
|
648
|
-
});
|
|
649
|
-
case 14:
|
|
650
|
-
_yield$strapiClient$g = _context.sent;
|
|
651
|
-
data = _yield$strapiClient$g.data;
|
|
652
|
-
responses.push.apply(responses, data.data);
|
|
653
|
-
case 17:
|
|
654
|
-
_context.next = 8;
|
|
655
|
-
break;
|
|
656
|
-
case 19:
|
|
657
|
-
groupedResponses = responses.reduce(function (acc, response) {
|
|
658
|
-
var keyValue = response.attributes[key];
|
|
659
|
-
if (!acc[keyValue] || response.attributes.locale === locale) {
|
|
660
|
-
acc[keyValue] = response;
|
|
598
|
+
promises = allLocales.map(function (loc) {
|
|
599
|
+
var params = {
|
|
600
|
+
pLevel: '6',
|
|
601
|
+
locale: loc,
|
|
602
|
+
'pagination[pageSize]': STRAPI_DEFAULT_PAGE_SIZE,
|
|
603
|
+
filters: filters
|
|
604
|
+
};
|
|
605
|
+
if (preview) {
|
|
606
|
+
params.publicationState = 'preview';
|
|
661
607
|
}
|
|
662
|
-
return
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
608
|
+
return strapiClient.get(path, {
|
|
609
|
+
params: params,
|
|
610
|
+
cache: cache
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
_context.next = 9;
|
|
614
|
+
return Promise.all(promises);
|
|
615
|
+
case 9:
|
|
616
|
+
responses = _context.sent;
|
|
617
|
+
results = responses.flatMap(function (response) {
|
|
618
|
+
return response.data.data;
|
|
619
|
+
});
|
|
620
|
+
localizedResponses = results.filter(function (d) {
|
|
621
|
+
return d.attributes.locale === locale;
|
|
622
|
+
});
|
|
623
|
+
fallbackResponses = results.filter(function (d) {
|
|
624
|
+
return d.attributes.locale === STRAPI_FALLBACK_LOCALE;
|
|
625
|
+
});
|
|
626
|
+
result = fallbackResponses.map(function (fallbackResponse) {
|
|
627
|
+
var localizedResponse = localizedResponses.find(function (localized) {
|
|
628
|
+
return localized.attributes[key] === fallbackResponse.attributes[key];
|
|
629
|
+
});
|
|
630
|
+
return localizedResponse || fallbackResponse;
|
|
631
|
+
});
|
|
632
|
+
return _context.abrupt("return", result);
|
|
633
|
+
case 15:
|
|
666
634
|
case "end":
|
|
667
635
|
return _context.stop();
|
|
668
636
|
}
|