@treely/strapi-slices 3.2.1 → 3.3.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 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}
@@ -417,9 +417,15 @@ var DEFAULT_SHARE_ALT = 'Share Image';
417
417
  var mergeGlobalAndStrapiBlogPostData = function mergeGlobalAndStrapiBlogPostData(context, global, post, blog, projects) {
418
418
  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
419
  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;
420
+ var returnBlog = post.attributes.slices.some(function (slice) {
421
+ return SECTIONS_WITH_BLOG_POSTS.includes(slice.__component);
422
+ });
423
+ var returnProjects = post.attributes.slices.some(function (slice) {
424
+ return SECTIONS_WITH_PROJECTS.includes(slice.__component);
425
+ });
420
426
  return _extends({}, post, {
421
427
  // Portfolio Projects
422
- projects: projects,
428
+ projects: returnProjects ? projects : [],
423
429
  // StrapiBlogPost
424
430
  attributes: _extends({}, post == null ? void 0 : post.attributes, {
425
431
  metadata: (post == null || (_post$attributes = post.attributes) == null ? void 0 : _post$attributes.metadata) || global.attributes.metadata
@@ -443,7 +449,7 @@ var mergeGlobalAndStrapiBlogPostData = function mergeGlobalAndStrapiBlogPostData
443
449
  favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail')
444
450
  },
445
451
  slices: post == null ? void 0 : post.attributes.slices,
446
- blogPosts: blog,
452
+ blogPosts: returnBlog ? blog : [],
447
453
  banner: global.attributes.banner,
448
454
  topBanner: (post == null ? void 0 : post.attributes.topBanner) || global.attributes.topBanner,
449
455
  customerStories: []
@@ -453,6 +459,9 @@ var mergeGlobalAndStrapiBlogPostData = function mergeGlobalAndStrapiBlogPostData
453
459
  var mergeGlobalAndStrapiCustomerStoryData = function mergeGlobalAndStrapiCustomerStoryData(context, global, customerStory, customerStories) {
454
460
  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
461
  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;
462
+ var returnCustomerStories = customerStory.attributes.slices.some(function (slice) {
463
+ return SECTIONS_WITH_CUSTOMER_STORIES.includes(slice.__component);
464
+ });
456
465
  return _extends({}, customerStory, {
457
466
  // Portfolio Projects
458
467
  projects: [],
@@ -478,7 +487,7 @@ var mergeGlobalAndStrapiCustomerStoryData = function mergeGlobalAndStrapiCustome
478
487
  favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail')
479
488
  },
480
489
  slices: customerStory == null ? void 0 : customerStory.attributes.slices,
481
- customerStories: customerStories,
490
+ customerStories: returnCustomerStories ? customerStories : [],
482
491
  banner: global.attributes.banner,
483
492
  topBanner: (customerStory == null ? void 0 : customerStory.attributes.topBanner) || global.attributes.topBanner,
484
493
  blogPosts: []
@@ -494,9 +503,18 @@ var SECTIONS_WITH_PROJECTS = ['sections.projects-grid', 'sections.projects-map',
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 SECTIONS_WITH_BLOG_POSTS.includes(slice.__component);
508
+ });
509
+ var returnCustomerStories = page.attributes.slices.some(function (slice) {
510
+ return SECTIONS_WITH_CUSTOMER_STORIES.includes(slice.__component);
511
+ });
512
+ var returnProjects = page.attributes.slices.some(function (slice) {
513
+ return SECTIONS_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 SECTIONS_WITH_BLOG_POSTS.includes(slice.__component);
553
+ });
554
+ var returnProjects = project.attributes.slices.some(function (slice) {
555
+ return SECTIONS_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: []