@treely/strapi-slices 5.5.1 → 5.6.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.
- package/dist/__mocks__/adblock-detect-react.d.ts +3 -0
- package/dist/__mocks__/axios-cache-interceptor.d.ts +2 -0
- package/dist/__mocks__/axios.d.ts +2 -0
- package/dist/__mocks__/mapbox-gl.d.ts +14 -0
- package/dist/__mocks__/next/router.d.ts +3 -0
- package/dist/constants/strapi.d.ts +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/integrations/fpmClient.d.ts +2 -0
- package/dist/integrations/strapi/getPortfolioProjects.d.ts +3 -0
- package/dist/integrations/strapi/getStaticPathsFromStrapi.d.ts +6 -0
- package/dist/integrations/strapi/getStaticPropsFromStrapi.d.ts +8 -0
- package/dist/integrations/strapi/strapiClient.d.ts +2 -0
- package/dist/models/PageProps.d.ts +1 -0
- package/dist/strapi-slices.cjs.development.js +157 -12
- 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 +153 -13
- package/dist/strapi-slices.esm.js.map +1 -1
- package/package.json +5 -2
- package/src/components/portfolio/SmallCheckout/SmallCheckout.tsx +3 -5
- package/src/constants/strapi.ts +2 -0
- package/src/index.tsx +9 -0
- package/src/integrations/fpmClient.ts +14 -0
- package/src/integrations/strapi/getPortfolioProjects.test.ts +32 -0
- package/src/integrations/strapi/getPortfolioProjects.ts +58 -0
- package/src/integrations/strapi/getStaticPathsFromStrapi.test.ts +22 -0
- package/src/integrations/strapi/getStaticPathsFromStrapi.ts +22 -0
- package/src/integrations/strapi/getStaticPropsFromStrapi.test.ts +56 -0
- package/src/integrations/strapi/getStaticPropsFromStrapi.ts +35 -0
- package/src/integrations/strapi/strapiClient.ts +14 -0
- package/src/models/PageProps.ts +1 -0
- package/src/utils/mergeGlobalAndStrapiBlogPostData.ts +1 -0
- package/src/utils/mergeGlobalAndStrapiCustomerStoryData.ts +1 -0
- package/src/utils/mergeGlobalAndStrapiPageData.ts +1 -0
- package/src/utils/mergeGlobalAndStrapiProjectData.ts +1 -0
- package/dist/slices/FullWidthImageSlider/utils.test.d.ts +0 -1
- package/dist/utils/convertAreaM2ToHa.test.d.ts +0 -1
- package/dist/utils/convertToKebabCase.test.d.ts +0 -1
- package/dist/utils/getTimeSpanInYears.test.d.ts +0 -1
- package/dist/utils/mergeBoundingBoxes.test.d.ts +0 -1
- package/dist/utils/mergeGlobalAndStrapiBlogPostData.test.d.ts +0 -1
- package/dist/utils/mergeGlobalAndStrapiCustomerStoryData.test.d.ts +0 -1
- package/dist/utils/mergeGlobalAndStrapiPageData.test.d.ts +0 -1
- package/dist/utils/mergeGlobalAndStrapiProjectData.test.d.ts +0 -1
- package/dist/utils/strapiLinkUrl.test.d.ts +0 -1
- package/dist/utils/strapiMediaUrl.test.d.ts +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
declare const mapboxgl: {};
|
|
3
|
+
export default mapboxgl;
|
|
4
|
+
export declare const mapOnSpy: jest.Mock<any, any, any>;
|
|
5
|
+
export declare const mapAddSourceSpy: jest.Mock<any, any, any>;
|
|
6
|
+
export declare const mapAddLayerSpy: jest.Mock<any, any, any>;
|
|
7
|
+
export declare const mapSetFeatureStateSpy: jest.Mock<any, any, any>;
|
|
8
|
+
export declare const mapAddControlSpy: jest.Mock<any, any, any>;
|
|
9
|
+
export declare const mapRemoveSpy: jest.Mock<any, any, any>;
|
|
10
|
+
export declare const markerAddToSpy: jest.Mock<any, any, any>;
|
|
11
|
+
export declare const markerSetLngLatSpy: jest.Mock<any, any, any>;
|
|
12
|
+
export declare const mapConstructorMock: jest.Mock<any, any, any>;
|
|
13
|
+
export declare const Map: jest.Mock<any, any, any>;
|
|
14
|
+
export declare const Marker: jest.Mock<any, any, any>;
|
package/dist/index.d.ts
CHANGED
|
@@ -43,6 +43,9 @@ import Locale from './models/Locale';
|
|
|
43
43
|
import PageMetadata from './models/PageMetadata';
|
|
44
44
|
import PageProps from './models/PageProps';
|
|
45
45
|
import PortfolioProject from './models/PortfolioProject';
|
|
46
|
+
import getPortfolioProjects from './integrations/strapi/getPortfolioProjects';
|
|
47
|
+
import getStaticPathsFromStrapi from './integrations/strapi/getStaticPathsFromStrapi';
|
|
48
|
+
import getStaticPropsFromStrapi from './integrations/strapi/getStaticPropsFromStrapi';
|
|
46
49
|
import mergeGlobalAndStrapiBlogPostData from './utils/mergeGlobalAndStrapiBlogPostData';
|
|
47
50
|
import mergeGlobalAndStrapiCustomerStoryData from './utils/mergeGlobalAndStrapiCustomerStoryData';
|
|
48
51
|
import mergeGlobalAndStrapiPageData from './utils/mergeGlobalAndStrapiPageData';
|
|
@@ -51,5 +54,5 @@ import strapiLinkUrl from './utils/strapiLinkUrl';
|
|
|
51
54
|
import strapiMediaUrl from './utils/strapiMediaUrl';
|
|
52
55
|
export * from './components/SEOTags';
|
|
53
56
|
export * from './components/SliceRenderer';
|
|
54
|
-
export { mergeGlobalAndStrapiBlogPostData, mergeGlobalAndStrapiCustomerStoryData, mergeGlobalAndStrapiPageData, mergeGlobalAndStrapiProjectData, strapiLinkUrl, strapiMediaUrl, };
|
|
57
|
+
export { mergeGlobalAndStrapiBlogPostData, mergeGlobalAndStrapiCustomerStoryData, mergeGlobalAndStrapiPageData, mergeGlobalAndStrapiProjectData, strapiLinkUrl, strapiMediaUrl, getPortfolioProjects, getStaticPathsFromStrapi, getStaticPropsFromStrapi, };
|
|
55
58
|
export type { IStrapi, IStrapiData, IStrapiResponse, StrapiAuthor, StrapiAvatarWithName, StrapiBanner, StrapiBlogPost, StrapiBlogPostProps, StrapiButtonWithVariant, StrapiCategory, StrapiContactArea, StrapiCustomerStory, StrapiCustomerStoryProps, StrapiDefaultHeader, StrapiGlobal, StrapiGlossaryItem, StrapiHeroCard, StrapiImage, StrapiImageFormat, StrapiImageWithLink, StrapiLink, StrapiLinkList, StrapiLinkPage, StrapiLinkWithIcon, StrapiLocalization, StrapiMedia, StrapiMetadata, StrapiNavMenu, StrapiPage, StrapiPageProps, StrapiPortfolio, StrapiPortfolioCard, StrapiProject, StrapiProjectProps, StrapiProjectCard, StrapiQuoteCard, StrapiShapesCard, StrapiTextCardWithIcons, StrapiTopBanner, HeaderType, Image, Locale, PageMetadata, PageProps, PortfolioProject, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
interface Options {
|
|
3
|
+
locale?: string;
|
|
4
|
+
slug?: string;
|
|
5
|
+
preview?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const getStaticPropsFromStrapi: (path: string, { locale, slug, preview }: Options) => Promise<AxiosResponse>;
|
|
8
|
+
export default getStaticPropsFromStrapi;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var axios = require('axios');
|
|
6
|
+
var qs = require('qs');
|
|
7
|
+
var axiosCacheInterceptor = require('axios-cache-interceptor');
|
|
5
8
|
var React = require('react');
|
|
6
9
|
var Head = require('next/head');
|
|
7
10
|
var boemly = require('boemly');
|
|
@@ -21,6 +24,8 @@ var formik = require('formik');
|
|
|
21
24
|
|
|
22
25
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
26
|
|
|
27
|
+
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
28
|
+
var qs__default = /*#__PURE__*/_interopDefault(qs);
|
|
24
29
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
25
30
|
var Head__default = /*#__PURE__*/_interopDefault(Head);
|
|
26
31
|
var Image__default = /*#__PURE__*/_interopDefault(Image);
|
|
@@ -394,6 +399,145 @@ function _taggedTemplateLiteralLoose(strings, raw) {
|
|
|
394
399
|
}
|
|
395
400
|
|
|
396
401
|
var STRAPI_URI = process.env.NEXT_PUBLIC_STRAPI_URI || 'http://127.0.0.1:1337';
|
|
402
|
+
var STRAPI_DEFAULT_PAGE_SIZE = '100';
|
|
403
|
+
|
|
404
|
+
process.env.NEXT_PUBLIC_API_URI || 'http://localhost:4001';
|
|
405
|
+
var FPM_API_URI = process.env.NEXT_PUBLIC_FPM_API_URI || 'https://api.fpm.t-staging.com';
|
|
406
|
+
var CDN_URI = 'https://cdn.tree.ly';
|
|
407
|
+
|
|
408
|
+
var fpmClient = /*#__PURE__*/axiosCacheInterceptor.setupCache( /*#__PURE__*/axios__default.default.create({
|
|
409
|
+
baseURL: FPM_API_URI + "/v1",
|
|
410
|
+
paramsSerializer: function paramsSerializer(p) {
|
|
411
|
+
return qs__default.default.stringify(p, {
|
|
412
|
+
encodeValuesOnly: true
|
|
413
|
+
});
|
|
414
|
+
},
|
|
415
|
+
timeout: 5000
|
|
416
|
+
}));
|
|
417
|
+
|
|
418
|
+
var strapiClient = /*#__PURE__*/axiosCacheInterceptor.setupCache( /*#__PURE__*/axios__default.default.create({
|
|
419
|
+
baseURL: STRAPI_URI + "/api",
|
|
420
|
+
paramsSerializer: function paramsSerializer(p) {
|
|
421
|
+
return qs__default.default.stringify(p, {
|
|
422
|
+
encodeValuesOnly: true
|
|
423
|
+
});
|
|
424
|
+
},
|
|
425
|
+
timeout: 60000
|
|
426
|
+
}));
|
|
427
|
+
|
|
428
|
+
var getPortfolioProjects = /*#__PURE__*/function () {
|
|
429
|
+
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(locale) {
|
|
430
|
+
var _yield$Promise$all, fpmProjects, strapiProjects;
|
|
431
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
432
|
+
while (1) switch (_context.prev = _context.next) {
|
|
433
|
+
case 0:
|
|
434
|
+
_context.next = 2;
|
|
435
|
+
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
|
+
}
|
|
441
|
+
})]);
|
|
442
|
+
case 2:
|
|
443
|
+
_yield$Promise$all = _context.sent;
|
|
444
|
+
fpmProjects = _yield$Promise$all[0].data;
|
|
445
|
+
strapiProjects = _yield$Promise$all[1].data;
|
|
446
|
+
return _context.abrupt("return", fpmProjects.map(function (fpmProject) {
|
|
447
|
+
var _strapiProject$attrib;
|
|
448
|
+
var strapiProject = strapiProjects.data.find(function (sp) {
|
|
449
|
+
return sp.attributes.fpmProjectId === fpmProject.id;
|
|
450
|
+
});
|
|
451
|
+
var toReturn = fpmProject;
|
|
452
|
+
if (strapiProject != null && strapiProject.attributes.slug) {
|
|
453
|
+
toReturn.slug = strapiProject.attributes.slug;
|
|
454
|
+
}
|
|
455
|
+
if (strapiProject != null && strapiProject.attributes.creditsAvailable) {
|
|
456
|
+
toReturn.creditsAvailable = strapiProject == null ? void 0 : strapiProject.attributes.creditsAvailable;
|
|
457
|
+
}
|
|
458
|
+
if (strapiProject != null && strapiProject.attributes.thumbnail) {
|
|
459
|
+
toReturn.thumbnail = strapiProject == null ? void 0 : strapiProject.attributes.thumbnail;
|
|
460
|
+
}
|
|
461
|
+
if (strapiProject != null && strapiProject.attributes.footerSubTitle) {
|
|
462
|
+
toReturn.footerSubTitle = strapiProject == null ? void 0 : strapiProject.attributes.footerSubTitle;
|
|
463
|
+
}
|
|
464
|
+
if (strapiProject != null && (_strapiProject$attrib = strapiProject.attributes.portfolio.data) != null && _strapiProject$attrib.attributes.host) {
|
|
465
|
+
toReturn.portfolioHost = strapiProject.attributes.portfolio.data.attributes.host;
|
|
466
|
+
}
|
|
467
|
+
return toReturn;
|
|
468
|
+
}));
|
|
469
|
+
case 6:
|
|
470
|
+
case "end":
|
|
471
|
+
return _context.stop();
|
|
472
|
+
}
|
|
473
|
+
}, _callee);
|
|
474
|
+
}));
|
|
475
|
+
return function getPortfolioProjects(_x) {
|
|
476
|
+
return _ref.apply(this, arguments);
|
|
477
|
+
};
|
|
478
|
+
}();
|
|
479
|
+
|
|
480
|
+
var getStaticPathsFromStrapi = /*#__PURE__*/function () {
|
|
481
|
+
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(path, _temp) {
|
|
482
|
+
var _ref2, _ref2$filters, filters, params;
|
|
483
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
484
|
+
while (1) switch (_context.prev = _context.next) {
|
|
485
|
+
case 0:
|
|
486
|
+
_ref2 = _temp === void 0 ? {
|
|
487
|
+
filters: {}
|
|
488
|
+
} : _temp, _ref2$filters = _ref2.filters, filters = _ref2$filters === void 0 ? {} : _ref2$filters;
|
|
489
|
+
params = {
|
|
490
|
+
locale: 'all',
|
|
491
|
+
'pagination[pageSize]': STRAPI_DEFAULT_PAGE_SIZE,
|
|
492
|
+
filters: filters
|
|
493
|
+
};
|
|
494
|
+
return _context.abrupt("return", strapiClient.get(path, {
|
|
495
|
+
params: params
|
|
496
|
+
}));
|
|
497
|
+
case 3:
|
|
498
|
+
case "end":
|
|
499
|
+
return _context.stop();
|
|
500
|
+
}
|
|
501
|
+
}, _callee);
|
|
502
|
+
}));
|
|
503
|
+
return function getStaticPathsFromStrapi(_x, _x2) {
|
|
504
|
+
return _ref.apply(this, arguments);
|
|
505
|
+
};
|
|
506
|
+
}();
|
|
507
|
+
|
|
508
|
+
var getStaticPropsFromStrapi = /*#__PURE__*/function () {
|
|
509
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(path, _ref) {
|
|
510
|
+
var _ref$locale, locale, slug, _ref$preview, preview, filters, params;
|
|
511
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
512
|
+
while (1) switch (_context.prev = _context.next) {
|
|
513
|
+
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 = {};
|
|
516
|
+
if (slug) {
|
|
517
|
+
filters.slug = slug;
|
|
518
|
+
}
|
|
519
|
+
params = {
|
|
520
|
+
populate: 'deep,6',
|
|
521
|
+
locale: locale,
|
|
522
|
+
'pagination[pageSize]': STRAPI_DEFAULT_PAGE_SIZE,
|
|
523
|
+
filters: filters
|
|
524
|
+
};
|
|
525
|
+
if (preview) {
|
|
526
|
+
params.publicationState = 'preview';
|
|
527
|
+
}
|
|
528
|
+
return _context.abrupt("return", strapiClient.get(path, {
|
|
529
|
+
params: params
|
|
530
|
+
}));
|
|
531
|
+
case 6:
|
|
532
|
+
case "end":
|
|
533
|
+
return _context.stop();
|
|
534
|
+
}
|
|
535
|
+
}, _callee);
|
|
536
|
+
}));
|
|
537
|
+
return function getStaticPropsFromStrapi(_x, _x2) {
|
|
538
|
+
return _ref2.apply(this, arguments);
|
|
539
|
+
};
|
|
540
|
+
}();
|
|
397
541
|
|
|
398
542
|
var strapiMediaUrl = function strapiMediaUrl(media, preferredSize) {
|
|
399
543
|
if (preferredSize === void 0) {
|
|
@@ -458,7 +602,8 @@ var mergeGlobalAndStrapiBlogPostData = function mergeGlobalAndStrapiBlogPostData
|
|
|
458
602
|
blogPosts: returnBlog ? blog : [],
|
|
459
603
|
banner: global.attributes.banner,
|
|
460
604
|
topBanner: (post == null ? void 0 : post.attributes.topBanner) || global.attributes.topBanner,
|
|
461
|
-
customerStories: []
|
|
605
|
+
customerStories: [],
|
|
606
|
+
preview: !!context.preview
|
|
462
607
|
});
|
|
463
608
|
};
|
|
464
609
|
|
|
@@ -496,7 +641,8 @@ var mergeGlobalAndStrapiCustomerStoryData = function mergeGlobalAndStrapiCustome
|
|
|
496
641
|
customerStories: returnCustomerStories ? customerStories : [],
|
|
497
642
|
banner: global.attributes.banner,
|
|
498
643
|
topBanner: (customerStory == null ? void 0 : customerStory.attributes.topBanner) || global.attributes.topBanner,
|
|
499
|
-
blogPosts: []
|
|
644
|
+
blogPosts: [],
|
|
645
|
+
preview: !!context.preview
|
|
500
646
|
});
|
|
501
647
|
};
|
|
502
648
|
|
|
@@ -541,7 +687,8 @@ var mergeGlobalAndStrapiPageData = function mergeGlobalAndStrapiPageData(context
|
|
|
541
687
|
blogPosts: returnBlogPosts ? blogPosts : [],
|
|
542
688
|
banner: global.attributes.banner,
|
|
543
689
|
topBanner: (page == null ? void 0 : page.attributes.topBanner) || global.attributes.topBanner,
|
|
544
|
-
customerStories: returnCustomerStories ? customerStories : []
|
|
690
|
+
customerStories: returnCustomerStories ? customerStories : [],
|
|
691
|
+
preview: !!context.preview
|
|
545
692
|
});
|
|
546
693
|
};
|
|
547
694
|
|
|
@@ -583,7 +730,8 @@ var mergeGlobalAndStrapiProject = function mergeGlobalAndStrapiProject(context,
|
|
|
583
730
|
blogPosts: returnBlogPosts ? blogPosts : [],
|
|
584
731
|
banner: global.attributes.banner,
|
|
585
732
|
topBanner: (project == null ? void 0 : project.attributes.topBanner) || global.attributes.topBanner,
|
|
586
|
-
customerStories: []
|
|
733
|
+
customerStories: [],
|
|
734
|
+
preview: !!context.preview
|
|
587
735
|
});
|
|
588
736
|
};
|
|
589
737
|
|
|
@@ -1200,10 +1348,6 @@ var ImageGrid = function ImageGrid(_ref) {
|
|
|
1200
1348
|
}))));
|
|
1201
1349
|
};
|
|
1202
1350
|
|
|
1203
|
-
process.env.NEXT_PUBLIC_API_URI || 'http://localhost:4001';
|
|
1204
|
-
var FPM_API_URI = process.env.NEXT_PUBLIC_FPM_API_URI || 'https://api.fpm.t-staging.com';
|
|
1205
|
-
var CDN_URI = 'https://cdn.tree.ly';
|
|
1206
|
-
|
|
1207
1351
|
var ImageTextSequence = function ImageTextSequence(_ref) {
|
|
1208
1352
|
var slice = _ref.slice;
|
|
1209
1353
|
var _useMediaQuery = boemly.useMediaQuery(BREAKPOINT_LG_QUERY),
|
|
@@ -4281,11 +4425,9 @@ var SmallCheckout = function SmallCheckout(_ref) {
|
|
|
4281
4425
|
type: 'number',
|
|
4282
4426
|
value: field.value,
|
|
4283
4427
|
onChange: function onChange(e) {
|
|
4284
|
-
// valueAsNumber might be NaN
|
|
4285
|
-
var value = e.target.valueAsNumber || 0;
|
|
4286
4428
|
setValues({
|
|
4287
|
-
contributionValueCurrency:
|
|
4288
|
-
contributionValueKgs:
|
|
4429
|
+
contributionValueCurrency: e.target.valueAsNumber,
|
|
4430
|
+
contributionValueKgs: e.target.valueAsNumber / pricePerKg / 1000
|
|
4289
4431
|
});
|
|
4290
4432
|
}
|
|
4291
4433
|
},
|
|
@@ -5429,6 +5571,9 @@ var SliceRenderer = function SliceRenderer(_ref) {
|
|
|
5429
5571
|
|
|
5430
5572
|
exports.SEOTags = SEOTags;
|
|
5431
5573
|
exports.SliceRenderer = SliceRenderer;
|
|
5574
|
+
exports.getPortfolioProjects = getPortfolioProjects;
|
|
5575
|
+
exports.getStaticPathsFromStrapi = getStaticPathsFromStrapi;
|
|
5576
|
+
exports.getStaticPropsFromStrapi = getStaticPropsFromStrapi;
|
|
5432
5577
|
exports.mergeGlobalAndStrapiBlogPostData = mergeGlobalAndStrapiBlogPostData;
|
|
5433
5578
|
exports.mergeGlobalAndStrapiCustomerStoryData = mergeGlobalAndStrapiCustomerStoryData;
|
|
5434
5579
|
exports.mergeGlobalAndStrapiPageData = mergeGlobalAndStrapiPageData;
|