@treely/strapi-slices 3.2.1 → 4.0.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/README.md +11 -2
- package/dist/constants/slicesConfig.d.ts +5 -0
- package/dist/index.d.ts +1 -2
- package/dist/strapi-slices.cjs.development.js +38 -17
- 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 +39 -15
- package/dist/strapi-slices.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/constants/{sectionsConfig.ts → slicesConfig.ts} +3 -6
- package/src/index.tsx +0 -11
- package/src/utils/mergeGlobalAndStrapiBlogPostData.test.ts +47 -0
- package/src/utils/mergeGlobalAndStrapiBlogPostData.ts +13 -2
- package/src/utils/mergeGlobalAndStrapiCustomerStoryData.test.ts +21 -0
- package/src/utils/mergeGlobalAndStrapiCustomerStoryData.ts +6 -1
- package/src/utils/mergeGlobalAndStrapiPageData.test.ts +66 -0
- package/src/utils/mergeGlobalAndStrapiPageData.ts +17 -4
- package/src/utils/mergeGlobalAndStrapiProjectData.test.ts +40 -0
- package/src/utils/mergeGlobalAndStrapiProjectData.ts +12 -3
- package/dist/constants/sectionsConfig.d.ts +0 -5
package/README.md
CHANGED
|
@@ -32,6 +32,16 @@ Run the tests:
|
|
|
32
32
|
npm run test
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
For local testing, you can link the package to your project:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm run build
|
|
39
|
+
npm pack
|
|
40
|
+
|
|
41
|
+
cd ../path/to/your/project
|
|
42
|
+
npm install ../path/to/strapi-slices-package.tgz
|
|
43
|
+
```
|
|
44
|
+
|
|
35
45
|
Commit message guideline
|
|
36
46
|
|
|
37
47
|
The project uses the Angular commit message guideline. Find the documentation
|
|
@@ -62,7 +72,7 @@ import {
|
|
|
62
72
|
IStrapiData,
|
|
63
73
|
SliceRenderer,
|
|
64
74
|
StrapiBlogPost,
|
|
65
|
-
StrapiCustomerStory
|
|
75
|
+
StrapiCustomerStory,
|
|
66
76
|
} from '@tree-ly/strapi-slices';
|
|
67
77
|
|
|
68
78
|
// Get the slices, blog posts, and customer stories from Strapi
|
|
@@ -72,7 +82,6 @@ const blogPosts: IStrapiData<StrapiBlogPost> = [];
|
|
|
72
82
|
const projects: PortfolioProject[] = [];
|
|
73
83
|
const customerStories: IStrapiData<StrapiCustomerStory> = [];
|
|
74
84
|
|
|
75
|
-
|
|
76
85
|
const App = (): JSX.Element => (
|
|
77
86
|
<SliceRenderer
|
|
78
87
|
slices={slices}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const EXTENDABLE_HEADER_SECTIONS: string[];
|
|
2
|
+
export declare const DARK_THEME_HEADER_SECTIONS: string[];
|
|
3
|
+
export declare const SLICES_WITH_BLOG_POSTS: string[];
|
|
4
|
+
export declare const SLICES_WITH_CUSTOMER_STORIES: string[];
|
|
5
|
+
export declare const SLICES_WITH_PROJECTS: string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -49,8 +49,7 @@ import mergeGlobalAndStrapiPageData from './utils/mergeGlobalAndStrapiPageData';
|
|
|
49
49
|
import mergeGlobalAndStrapiProjectData from './utils/mergeGlobalAndStrapiProjectData';
|
|
50
50
|
import strapiLinkUrl from './utils/strapiLinkUrl';
|
|
51
51
|
import strapiMediaUrl from './utils/strapiMediaUrl';
|
|
52
|
-
import { SECTIONS_WITH_BLOG_POSTS, SECTIONS_WITH_CUSTOMER_STORIES, SECTIONS_WITH_PROJECTS } from './constants/sectionsConfig';
|
|
53
52
|
export * from './components/SEOTags';
|
|
54
53
|
export * from './components/SliceRenderer';
|
|
55
|
-
export { mergeGlobalAndStrapiBlogPostData, mergeGlobalAndStrapiCustomerStoryData, mergeGlobalAndStrapiPageData, mergeGlobalAndStrapiProjectData, strapiLinkUrl, strapiMediaUrl,
|
|
54
|
+
export { mergeGlobalAndStrapiBlogPostData, mergeGlobalAndStrapiCustomerStoryData, mergeGlobalAndStrapiPageData, mergeGlobalAndStrapiProjectData, strapiLinkUrl, strapiMediaUrl, };
|
|
56
55
|
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, };
|
|
@@ -414,12 +414,24 @@ var strapiMediaUrl = function strapiMediaUrl(media, preferredSize) {
|
|
|
414
414
|
var DEFAULT_SHARE_IMAGE = 'https://cdn.tree.ly/assets/v3/app/share-image-generic.webp';
|
|
415
415
|
var DEFAULT_SHARE_ALT = 'Share Image';
|
|
416
416
|
|
|
417
|
+
var EXTENDABLE_HEADER_SECTIONS = ['sections.hero', 'sections.map-hero', 'sections.full-width-image', 'sections.small-hero', 'sections.small-hero-light'];
|
|
418
|
+
var DARK_THEME_HEADER_SECTIONS = ['sections.hero', 'sections.small-hero'];
|
|
419
|
+
var SLICES_WITH_BLOG_POSTS = ['sections.blog', 'sections.blog-cards'];
|
|
420
|
+
var SLICES_WITH_CUSTOMER_STORIES = ['sections.customer-stories'];
|
|
421
|
+
var SLICES_WITH_PROJECTS = ['sections.projects-grid', 'sections.projects-map', 'sections.project-facts', 'sections.text-with-card'];
|
|
422
|
+
|
|
417
423
|
var mergeGlobalAndStrapiBlogPostData = function mergeGlobalAndStrapiBlogPostData(context, global, post, blog, projects) {
|
|
418
424
|
var _post$attributes$meta, _post$attributes$meta2, _post$attributes$meta3, _global$attributes$me, _post$attributes, _post$attributes$meta4, _post$attributes$meta5, _post$attributes$meta6, _post$attributes$meta7, _ref, _post$attributes$meta8, _post$attributes$meta9, _global$attributes$me2;
|
|
419
425
|
var metaShareImageUrl = (_post$attributes$meta = post.attributes.metadata) != null && _post$attributes$meta.shareImage ? strapiMediaUrl((_post$attributes$meta2 = (_post$attributes$meta3 = post.attributes.metadata) == null ? void 0 : _post$attributes$meta3.shareImage.media) != null ? _post$attributes$meta2 : (_global$attributes$me = global.attributes.metadata.shareImage) == null ? void 0 : _global$attributes$me.media, 'large') : DEFAULT_SHARE_IMAGE;
|
|
426
|
+
var returnBlog = post.attributes.slices.some(function (slice) {
|
|
427
|
+
return SLICES_WITH_BLOG_POSTS.includes(slice.__component);
|
|
428
|
+
});
|
|
429
|
+
var returnProjects = post.attributes.slices.some(function (slice) {
|
|
430
|
+
return SLICES_WITH_PROJECTS.includes(slice.__component);
|
|
431
|
+
});
|
|
420
432
|
return _extends({}, post, {
|
|
421
433
|
// Portfolio Projects
|
|
422
|
-
projects: projects,
|
|
434
|
+
projects: returnProjects ? projects : [],
|
|
423
435
|
// StrapiBlogPost
|
|
424
436
|
attributes: _extends({}, post == null ? void 0 : post.attributes, {
|
|
425
437
|
metadata: (post == null || (_post$attributes = post.attributes) == null ? void 0 : _post$attributes.metadata) || global.attributes.metadata
|
|
@@ -443,7 +455,7 @@ var mergeGlobalAndStrapiBlogPostData = function mergeGlobalAndStrapiBlogPostData
|
|
|
443
455
|
favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail')
|
|
444
456
|
},
|
|
445
457
|
slices: post == null ? void 0 : post.attributes.slices,
|
|
446
|
-
blogPosts: blog,
|
|
458
|
+
blogPosts: returnBlog ? blog : [],
|
|
447
459
|
banner: global.attributes.banner,
|
|
448
460
|
topBanner: (post == null ? void 0 : post.attributes.topBanner) || global.attributes.topBanner,
|
|
449
461
|
customerStories: []
|
|
@@ -453,6 +465,9 @@ var mergeGlobalAndStrapiBlogPostData = function mergeGlobalAndStrapiBlogPostData
|
|
|
453
465
|
var mergeGlobalAndStrapiCustomerStoryData = function mergeGlobalAndStrapiCustomerStoryData(context, global, customerStory, customerStories) {
|
|
454
466
|
var _customerStory$attrib, _customerStory$attrib2, _customerStory$attrib3, _global$attributes$me, _customerStory$attrib4, _customerStory$attrib5, _customerStory$attrib6, _customerStory$attrib7, _customerStory$attrib8, _ref, _customerStory$attrib9, _customerStory$attrib10, _global$attributes$me2;
|
|
455
467
|
var metaShareImageUrl = (_customerStory$attrib = customerStory.attributes.metadata) != null && _customerStory$attrib.shareImage ? strapiMediaUrl((_customerStory$attrib2 = (_customerStory$attrib3 = customerStory.attributes.metadata) == null ? void 0 : _customerStory$attrib3.shareImage.media) != null ? _customerStory$attrib2 : (_global$attributes$me = global.attributes.metadata.shareImage) == null ? void 0 : _global$attributes$me.media, 'large') : DEFAULT_SHARE_IMAGE;
|
|
468
|
+
var returnCustomerStories = customerStory.attributes.slices.some(function (slice) {
|
|
469
|
+
return SLICES_WITH_CUSTOMER_STORIES.includes(slice.__component);
|
|
470
|
+
});
|
|
456
471
|
return _extends({}, customerStory, {
|
|
457
472
|
// Portfolio Projects
|
|
458
473
|
projects: [],
|
|
@@ -478,25 +493,28 @@ var mergeGlobalAndStrapiCustomerStoryData = function mergeGlobalAndStrapiCustome
|
|
|
478
493
|
favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail')
|
|
479
494
|
},
|
|
480
495
|
slices: customerStory == null ? void 0 : customerStory.attributes.slices,
|
|
481
|
-
customerStories: customerStories,
|
|
496
|
+
customerStories: returnCustomerStories ? customerStories : [],
|
|
482
497
|
banner: global.attributes.banner,
|
|
483
498
|
topBanner: (customerStory == null ? void 0 : customerStory.attributes.topBanner) || global.attributes.topBanner,
|
|
484
499
|
blogPosts: []
|
|
485
500
|
});
|
|
486
501
|
};
|
|
487
502
|
|
|
488
|
-
var EXTENDABLE_HEADER_SECTIONS = ['sections.hero', 'sections.map-hero', 'sections.full-width-image', 'sections.small-hero', 'sections.small-hero-light'];
|
|
489
|
-
var DARK_THEME_HEADER_SECTIONS = ['sections.hero', 'sections.small-hero'];
|
|
490
|
-
var SECTIONS_WITH_BLOG_POSTS = ['sections.blog', 'sections.blog-cards'];
|
|
491
|
-
var SECTIONS_WITH_CUSTOMER_STORIES = ['sections.customer-stories'];
|
|
492
|
-
var SECTIONS_WITH_PROJECTS = ['sections.projects-grid', 'sections.projects-map', 'sections.project-facts', 'sections.text-with-card'];
|
|
493
|
-
|
|
494
503
|
var mergeGlobalAndStrapiPageData = function mergeGlobalAndStrapiPageData(context, global, page, blogPosts, customerStories, projects) {
|
|
495
504
|
var _page$attributes$meta, _page$attributes$meta2, _page$attributes$meta3, _global$attributes$me, _page$attributes$meta4, _page$attributes, _page$attributes$slic, _page$attributes$slic2, _page$attributes$meta5, _page$attributes$meta6, _page$attributes$meta7, _page$attributes$meta8, _ref, _page$attributes$meta9, _page$attributes$meta10, _global$attributes$me2;
|
|
496
505
|
var metaShareImageUrl = (_page$attributes$meta = page.attributes.metadata) != null && _page$attributes$meta.shareImage ? strapiMediaUrl((_page$attributes$meta2 = (_page$attributes$meta3 = page.attributes.metadata) == null ? void 0 : _page$attributes$meta3.shareImage.media) != null ? _page$attributes$meta2 : (_global$attributes$me = global.attributes.metadata.shareImage) == null ? void 0 : _global$attributes$me.media, 'large') : DEFAULT_SHARE_IMAGE;
|
|
506
|
+
var returnBlogPosts = page.attributes.slices.some(function (slice) {
|
|
507
|
+
return SLICES_WITH_BLOG_POSTS.includes(slice.__component);
|
|
508
|
+
});
|
|
509
|
+
var returnCustomerStories = page.attributes.slices.some(function (slice) {
|
|
510
|
+
return SLICES_WITH_CUSTOMER_STORIES.includes(slice.__component);
|
|
511
|
+
});
|
|
512
|
+
var returnProjects = page.attributes.slices.some(function (slice) {
|
|
513
|
+
return SLICES_WITH_PROJECTS.includes(slice.__component);
|
|
514
|
+
});
|
|
497
515
|
return _extends({}, page, {
|
|
498
516
|
// Portfolio Projects
|
|
499
|
-
projects: projects,
|
|
517
|
+
projects: returnProjects ? projects : [],
|
|
500
518
|
// StrapiPage
|
|
501
519
|
attributes: _extends({}, page == null ? void 0 : page.attributes, {
|
|
502
520
|
metadata: (_page$attributes$meta4 = page == null || (_page$attributes = page.attributes) == null ? void 0 : _page$attributes.metadata) != null ? _page$attributes$meta4 : global.attributes.metadata
|
|
@@ -520,19 +538,25 @@ var mergeGlobalAndStrapiPageData = function mergeGlobalAndStrapiPageData(context
|
|
|
520
538
|
favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail')
|
|
521
539
|
},
|
|
522
540
|
slices: page == null ? void 0 : page.attributes.slices,
|
|
523
|
-
blogPosts: blogPosts,
|
|
541
|
+
blogPosts: returnBlogPosts ? blogPosts : [],
|
|
524
542
|
banner: global.attributes.banner,
|
|
525
543
|
topBanner: (page == null ? void 0 : page.attributes.topBanner) || global.attributes.topBanner,
|
|
526
|
-
customerStories: customerStories
|
|
544
|
+
customerStories: returnCustomerStories ? customerStories : []
|
|
527
545
|
});
|
|
528
546
|
};
|
|
529
547
|
|
|
530
548
|
var mergeGlobalAndStrapiProject = function mergeGlobalAndStrapiProject(context, global, project, blogPosts, projects) {
|
|
531
549
|
var _project$attributes$m, _project$attributes$m2, _project$attributes$m3, _global$attributes$me, _project$attributes, _project$attributes$s, _project$attributes$s2, _project$attributes$m4, _project$attributes$m5, _project$attributes$m6, _project$attributes$m7, _ref, _project$attributes$m8, _project$attributes$m9, _global$attributes$me2;
|
|
532
550
|
var metaShareImageUrl = (_project$attributes$m = project.attributes.metadata) != null && _project$attributes$m.shareImage ? strapiMediaUrl((_project$attributes$m2 = (_project$attributes$m3 = project.attributes.metadata) == null ? void 0 : _project$attributes$m3.shareImage.media) != null ? _project$attributes$m2 : (_global$attributes$me = global.attributes.metadata.shareImage) == null ? void 0 : _global$attributes$me.media, 'large') : DEFAULT_SHARE_IMAGE;
|
|
551
|
+
var returnBlogPosts = project.attributes.slices.some(function (slice) {
|
|
552
|
+
return SLICES_WITH_BLOG_POSTS.includes(slice.__component);
|
|
553
|
+
});
|
|
554
|
+
var returnProjects = project.attributes.slices.some(function (slice) {
|
|
555
|
+
return SLICES_WITH_PROJECTS.includes(slice.__component);
|
|
556
|
+
});
|
|
533
557
|
return _extends({}, project, {
|
|
534
558
|
// Portfolio Projects
|
|
535
|
-
projects: projects,
|
|
559
|
+
projects: returnProjects ? projects : [],
|
|
536
560
|
// StrapiProject
|
|
537
561
|
attributes: _extends({}, project.attributes, {
|
|
538
562
|
metadata: (project == null || (_project$attributes = project.attributes) == null ? void 0 : _project$attributes.metadata) || global.attributes.metadata
|
|
@@ -556,7 +580,7 @@ var mergeGlobalAndStrapiProject = function mergeGlobalAndStrapiProject(context,
|
|
|
556
580
|
favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail')
|
|
557
581
|
},
|
|
558
582
|
slices: project.attributes.slices,
|
|
559
|
-
blogPosts: blogPosts,
|
|
583
|
+
blogPosts: returnBlogPosts ? blogPosts : [],
|
|
560
584
|
banner: global.attributes.banner,
|
|
561
585
|
topBanner: (project == null ? void 0 : project.attributes.topBanner) || global.attributes.topBanner,
|
|
562
586
|
customerStories: []
|
|
@@ -4915,9 +4939,6 @@ var SliceRenderer = function SliceRenderer(_ref) {
|
|
|
4915
4939
|
}));
|
|
4916
4940
|
};
|
|
4917
4941
|
|
|
4918
|
-
exports.SECTIONS_WITH_BLOG_POSTS = SECTIONS_WITH_BLOG_POSTS;
|
|
4919
|
-
exports.SECTIONS_WITH_CUSTOMER_STORIES = SECTIONS_WITH_CUSTOMER_STORIES;
|
|
4920
|
-
exports.SECTIONS_WITH_PROJECTS = SECTIONS_WITH_PROJECTS;
|
|
4921
4942
|
exports.SEOTags = SEOTags;
|
|
4922
4943
|
exports.SliceRenderer = SliceRenderer;
|
|
4923
4944
|
exports.mergeGlobalAndStrapiBlogPostData = mergeGlobalAndStrapiBlogPostData;
|