@treely/strapi-slices 5.12.0 → 5.14.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treely/strapi-slices",
3
- "version": "5.12.0",
3
+ "version": "5.14.0",
4
4
  "license": "MIT",
5
5
  "author": "Tree.ly FlexCo",
6
6
  "description": "@treely/strapi-slices is a open source library maintained by Tree.ly.",
@@ -28,6 +28,7 @@ interface PageProps {
28
28
  topBanner?: StrapiTopBanner;
29
29
  customerStories: IStrapiData<StrapiCustomerStory>[];
30
30
  preview: boolean;
31
+ isFallbackLocale: boolean;
31
32
  }
32
33
 
33
34
  export default PageProps;
@@ -74,7 +74,8 @@ type Variant = {
74
74
  const variants: { shape: Variant; image: Variant } = {
75
75
  shape: {
76
76
  padding: ['6', null, null, '8'],
77
- positionIcon: (index: number) => shapePositions[index],
77
+ positionIcon: (index: number) =>
78
+ shapePositions[index % shapePositions.length],
78
79
  width: '40',
79
80
  height: '40',
80
81
  position: 'absolute',
@@ -7,7 +7,7 @@ import portfolioProjectMock from '../test/integrationMocks/portfolioProjectMock'
7
7
 
8
8
  describe('The mergeGlobalAndStrapiBlogPostData util', () => {
9
9
  it('returns the global metadata if there is no page metadata', () => {
10
- const pageDataWithoutMetadata = {
10
+ const blogPostDataWithoutMetadata = {
11
11
  ...strapiBlogPostMock,
12
12
  attributes: {
13
13
  ...strapiBlogPostMock.attributes,
@@ -18,7 +18,7 @@ describe('The mergeGlobalAndStrapiBlogPostData util', () => {
18
18
  const result = mergeGlobalAndStrapiBlogPostData(
19
19
  getStaticPropsContextMock,
20
20
  minimalGlobalData,
21
- pageDataWithoutMetadata,
21
+ blogPostDataWithoutMetadata,
22
22
  [],
23
23
  []
24
24
  );
@@ -32,10 +32,11 @@ describe('The mergeGlobalAndStrapiBlogPostData util', () => {
32
32
  expect(result.metadata.description).toBe(
33
33
  minimalGlobalData.attributes.metadata.description
34
34
  );
35
+ expect(result.isFallbackLocale).toBeFalsy();
35
36
  });
36
37
 
37
38
  it('returns the pages metadata if the page data includes metadata', () => {
38
- const pageDataWithMetadata = {
39
+ const blogPostDataWithMetadata = {
39
40
  ...strapiBlogPostMock,
40
41
  data: {
41
42
  ...strapiBlogPostMock,
@@ -49,7 +50,7 @@ describe('The mergeGlobalAndStrapiBlogPostData util', () => {
49
50
  const result = mergeGlobalAndStrapiBlogPostData(
50
51
  getStaticPropsContextMock,
51
52
  minimalGlobalData,
52
- pageDataWithMetadata,
53
+ blogPostDataWithMetadata,
53
54
  [],
54
55
  []
55
56
  );
@@ -198,4 +199,24 @@ describe('The mergeGlobalAndStrapiBlogPostData util', () => {
198
199
  expect(result.blogPosts).toStrictEqual([]);
199
200
  expect(result.projects).toStrictEqual([portfolioProjectMock]);
200
201
  });
202
+
203
+ it('returns isFallbackLocale=true if the blog post is in a different language', () => {
204
+ const blogPostDataInDe = {
205
+ ...strapiBlogPostMock,
206
+ attributes: {
207
+ ...strapiBlogPostMock.attributes,
208
+ locale: 'de',
209
+ },
210
+ };
211
+
212
+ const result = mergeGlobalAndStrapiBlogPostData(
213
+ getStaticPropsContextMock,
214
+ minimalGlobalData,
215
+ blogPostDataInDe,
216
+ [],
217
+ []
218
+ );
219
+
220
+ expect(result.isFallbackLocale).toBeTruthy();
221
+ });
201
222
  });
@@ -74,6 +74,7 @@ const mergeGlobalAndStrapiBlogPostData = (
74
74
  topBanner: post?.attributes.topBanner || global.attributes.topBanner,
75
75
  customerStories: [],
76
76
  preview: !!context.preview,
77
+ isFallbackLocale: context.locale !== post.attributes.locale,
77
78
  };
78
79
  };
79
80
 
@@ -6,7 +6,7 @@ import { strapiMetadataMock } from '../test/strapiMocks/strapiMetadata';
6
6
 
7
7
  describe('The mergeGlobalAndStrapiCustomerStoryData util', () => {
8
8
  it('returns the global metadata if there is no page metadata', () => {
9
- const pageDataWithoutMetadata = {
9
+ const customerStoryDataWithoutMetadata = {
10
10
  ...strapiCustomerStoryMock,
11
11
  attributes: {
12
12
  ...strapiCustomerStoryMock.attributes,
@@ -17,7 +17,7 @@ describe('The mergeGlobalAndStrapiCustomerStoryData util', () => {
17
17
  const result = mergeGlobalAndStrapiCustomerStoryData(
18
18
  getStaticPropsContextMock,
19
19
  minimalGlobalData,
20
- pageDataWithoutMetadata,
20
+ customerStoryDataWithoutMetadata,
21
21
  []
22
22
  );
23
23
 
@@ -30,10 +30,11 @@ describe('The mergeGlobalAndStrapiCustomerStoryData util', () => {
30
30
  expect(result.metadata.description).toBe(
31
31
  minimalGlobalData.attributes.metadata.description
32
32
  );
33
+ expect(result.isFallbackLocale).toBeFalsy();
33
34
  });
34
35
 
35
36
  it('returns the pages metadata if the page data includes metadata', () => {
36
- const pageDataWithMetadata = {
37
+ const customerStoryDataWithMetadata = {
37
38
  ...strapiCustomerStoryMock,
38
39
  data: {
39
40
  ...strapiCustomerStoryMock,
@@ -47,7 +48,7 @@ describe('The mergeGlobalAndStrapiCustomerStoryData util', () => {
47
48
  const result = mergeGlobalAndStrapiCustomerStoryData(
48
49
  getStaticPropsContextMock,
49
50
  minimalGlobalData,
50
- pageDataWithMetadata,
51
+ customerStoryDataWithMetadata,
51
52
  []
52
53
  );
53
54
 
@@ -167,4 +168,23 @@ describe('The mergeGlobalAndStrapiCustomerStoryData util', () => {
167
168
 
168
169
  expect(result.customerStories).toStrictEqual([strapiCustomerStoryMock]);
169
170
  });
171
+
172
+ it('returns isFallbackLocale=true if the customer story is in a different language', () => {
173
+ const customerStoryDataInDe = {
174
+ ...strapiCustomerStoryMock,
175
+ attributes: {
176
+ ...strapiCustomerStoryMock.attributes,
177
+ locale: 'de',
178
+ },
179
+ };
180
+
181
+ const result = mergeGlobalAndStrapiCustomerStoryData(
182
+ getStaticPropsContextMock,
183
+ minimalGlobalData,
184
+ customerStoryDataInDe,
185
+ []
186
+ );
187
+
188
+ expect(result.isFallbackLocale).toBeTruthy();
189
+ });
170
190
  });
@@ -68,6 +68,7 @@ const mergeGlobalAndStrapiCustomerStoryData = (
68
68
  customerStory?.attributes.topBanner || global.attributes.topBanner,
69
69
  blogPosts: [],
70
70
  preview: !!context.preview,
71
+ isFallbackLocale: context.locale !== customerStory.attributes.locale,
71
72
  };
72
73
  };
73
74
 
@@ -35,6 +35,7 @@ describe('The mergeGlobalAndStrapiPageData util', () => {
35
35
  expect(result.metadata.description).toBe(
36
36
  minimalGlobalData.attributes.metadata.description
37
37
  );
38
+ expect(result.isFallbackLocale).toBeFalsy();
38
39
  });
39
40
 
40
41
  it('returns the pages metadata if the page data includes metadata', () => {
@@ -317,4 +318,25 @@ describe('The mergeGlobalAndStrapiPageData util', () => {
317
318
  expect(result.blogPosts).toStrictEqual([]);
318
319
  expect(result.customerStories).toStrictEqual([]);
319
320
  });
321
+
322
+ it('returns isFallbackLocale=true if the page is in a different language', () => {
323
+ const pageDataInDe = {
324
+ ...strapiPageMock,
325
+ attributes: {
326
+ ...strapiPageMock.attributes,
327
+ locale: 'de',
328
+ },
329
+ };
330
+
331
+ const result = mergeGlobalAndStrapiPageData(
332
+ getStaticPropsContextMock,
333
+ minimalGlobalData,
334
+ pageDataInDe,
335
+ [],
336
+ [],
337
+ []
338
+ );
339
+
340
+ expect(result.isFallbackLocale).toBeTruthy();
341
+ });
320
342
  });
@@ -89,6 +89,7 @@ const mergeGlobalAndStrapiPageData = (
89
89
  topBanner: page?.attributes.topBanner || global.attributes.topBanner,
90
90
  customerStories: returnCustomerStories ? customerStories : [],
91
91
  preview: !!context.preview,
92
+ isFallbackLocale: context.locale !== page.attributes.locale,
92
93
  };
93
94
  };
94
95
 
@@ -8,7 +8,7 @@ import mergeGlobalAndStrapiProjectData from './mergeGlobalAndStrapiProjectData';
8
8
 
9
9
  describe('The mergeGlobalAndStrapiProjectData util', () => {
10
10
  it('returns the global metadata if there is no page metadata', () => {
11
- const pageDataWithoutMetadata = {
11
+ const projectDataWithoutMetadata = {
12
12
  ...strapiProjectMock,
13
13
  attributes: {
14
14
  ...strapiProjectMock.attributes,
@@ -19,7 +19,7 @@ describe('The mergeGlobalAndStrapiProjectData util', () => {
19
19
  const result = mergeGlobalAndStrapiProjectData(
20
20
  getStaticPropsContextMock,
21
21
  minimalGlobalData,
22
- pageDataWithoutMetadata,
22
+ projectDataWithoutMetadata,
23
23
  [],
24
24
  []
25
25
  );
@@ -33,10 +33,11 @@ describe('The mergeGlobalAndStrapiProjectData util', () => {
33
33
  expect(result.metadata.description).toBe(
34
34
  minimalGlobalData.attributes.metadata.description
35
35
  );
36
+ expect(result.isFallbackLocale).toBeFalsy();
36
37
  });
37
38
 
38
39
  it('returns the pages metadata if the page data includes metadata', () => {
39
- const pageDataWithMetadata = {
40
+ const projectDataWithMetadata = {
40
41
  ...strapiProjectMock,
41
42
  attributes: {
42
43
  ...strapiProjectMock.attributes,
@@ -47,7 +48,7 @@ describe('The mergeGlobalAndStrapiProjectData util', () => {
47
48
  const result = mergeGlobalAndStrapiProjectData(
48
49
  getStaticPropsContextMock,
49
50
  minimalGlobalData,
50
- pageDataWithMetadata,
51
+ projectDataWithMetadata,
51
52
  [],
52
53
  []
53
54
  );
@@ -280,4 +281,24 @@ describe('The mergeGlobalAndStrapiProjectData util', () => {
280
281
  expect(result.blogPosts).toStrictEqual([]);
281
282
  expect(result.projects).toStrictEqual([portfolioProjectMock]);
282
283
  });
284
+
285
+ it('returns isFallbackLocale=true if the project is in a different language', () => {
286
+ const projectDataInDe = {
287
+ ...strapiProjectMock,
288
+ attributes: {
289
+ ...strapiProjectMock.attributes,
290
+ locale: 'de',
291
+ },
292
+ };
293
+
294
+ const result = mergeGlobalAndStrapiProjectData(
295
+ getStaticPropsContextMock,
296
+ minimalGlobalData,
297
+ projectDataInDe,
298
+ [],
299
+ []
300
+ );
301
+
302
+ expect(result.isFallbackLocale).toBeTruthy();
303
+ });
283
304
  });
@@ -83,6 +83,7 @@ const mergeGlobalAndStrapiProject = (
83
83
  topBanner: project?.attributes.topBanner || global.attributes.topBanner,
84
84
  customerStories: [],
85
85
  preview: !!context.preview,
86
+ isFallbackLocale: context.locale !== project.attributes.locale,
86
87
  };
87
88
  };
88
89