@treely/strapi-slices 5.6.0 → 5.8.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.
@@ -1,3 +1,3 @@
1
1
  import { PortfolioProject } from '../..';
2
- declare const getPortfolioProjects: (locale?: string) => Promise<PortfolioProject[]>;
2
+ declare const getPortfolioProjects: (locale?: string, preview?: boolean) => Promise<PortfolioProject[]>;
3
3
  export default getPortfolioProjects;
@@ -3,6 +3,7 @@ interface Options {
3
3
  locale?: string;
4
4
  slug?: string;
5
5
  preview?: boolean;
6
+ filters?: Record<string, any>;
6
7
  }
7
- declare const getStaticPropsFromStrapi: (path: string, { locale, slug, preview }: Options) => Promise<AxiosResponse>;
8
+ declare const getStaticPropsFromStrapi: (path: string, { locale, slug, preview, filters }: Options) => Promise<AxiosResponse>;
8
9
  export default getStaticPropsFromStrapi;
@@ -426,20 +426,30 @@ var strapiClient = /*#__PURE__*/axiosCacheInterceptor.setupCache( /*#__PURE__*/a
426
426
  }));
427
427
 
428
428
  var getPortfolioProjects = /*#__PURE__*/function () {
429
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(locale) {
430
- var _yield$Promise$all, fpmProjects, strapiProjects;
429
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(locale, preview) {
430
+ var params, _yield$Promise$all, fpmProjects, strapiProjects;
431
431
  return _regeneratorRuntime().wrap(function _callee$(_context) {
432
432
  while (1) switch (_context.prev = _context.next) {
433
433
  case 0:
434
- _context.next = 2;
434
+ if (locale === void 0) {
435
+ locale = 'en';
436
+ }
437
+ if (preview === void 0) {
438
+ preview = false;
439
+ }
440
+ params = {
441
+ populate: 'deep,6',
442
+ locale: locale,
443
+ 'pagination[pageSize]': STRAPI_DEFAULT_PAGE_SIZE
444
+ };
445
+ if (preview) {
446
+ params.publicationState = 'preview';
447
+ }
448
+ _context.next = 6;
435
449
  return Promise.all([fpmClient.get('/public/projects'), strapiClient.get('/projects', {
436
- params: {
437
- populate: 'deep,6',
438
- locale: locale,
439
- 'pagination[pageSize]': STRAPI_DEFAULT_PAGE_SIZE
440
- }
450
+ params: params
441
451
  })]);
442
- case 2:
452
+ case 6:
443
453
  _yield$Promise$all = _context.sent;
444
454
  fpmProjects = _yield$Promise$all[0].data;
445
455
  strapiProjects = _yield$Promise$all[1].data;
@@ -466,13 +476,13 @@ var getPortfolioProjects = /*#__PURE__*/function () {
466
476
  }
467
477
  return toReturn;
468
478
  }));
469
- case 6:
479
+ case 10:
470
480
  case "end":
471
481
  return _context.stop();
472
482
  }
473
483
  }, _callee);
474
484
  }));
475
- return function getPortfolioProjects(_x) {
485
+ return function getPortfolioProjects(_x, _x2) {
476
486
  return _ref.apply(this, arguments);
477
487
  };
478
488
  }();
@@ -507,20 +517,20 @@ var getStaticPathsFromStrapi = /*#__PURE__*/function () {
507
517
 
508
518
  var getStaticPropsFromStrapi = /*#__PURE__*/function () {
509
519
  var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(path, _ref) {
510
- var _ref$locale, locale, slug, _ref$preview, preview, filters, params;
520
+ var _ref$locale, locale, slug, _ref$preview, preview, _ref$filters, filters, enrichedFilters, params;
511
521
  return _regeneratorRuntime().wrap(function _callee$(_context) {
512
522
  while (1) switch (_context.prev = _context.next) {
513
523
  case 0:
514
- _ref$locale = _ref.locale, locale = _ref$locale === void 0 ? 'en' : _ref$locale, slug = _ref.slug, _ref$preview = _ref.preview, preview = _ref$preview === void 0 ? false : _ref$preview;
515
- filters = {};
524
+ _ref$locale = _ref.locale, locale = _ref$locale === void 0 ? 'en' : _ref$locale, slug = _ref.slug, _ref$preview = _ref.preview, preview = _ref$preview === void 0 ? false : _ref$preview, _ref$filters = _ref.filters, filters = _ref$filters === void 0 ? {} : _ref$filters;
525
+ enrichedFilters = filters;
516
526
  if (slug) {
517
- filters.slug = slug;
527
+ enrichedFilters.slug = slug;
518
528
  }
519
529
  params = {
520
530
  populate: 'deep,6',
521
531
  locale: locale,
522
532
  'pagination[pageSize]': STRAPI_DEFAULT_PAGE_SIZE,
523
- filters: filters
533
+ filters: enrichedFilters
524
534
  };
525
535
  if (preview) {
526
536
  params.publicationState = 'preview';