gatsby-core-theme 26.0.0 → 27.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/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ # [27.0.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v26.0.0...v27.0.0) (2023-08-18)
2
+
3
+
4
+ ### Code Refactoring
5
+
6
+ * add reading time to cards to show correct card reading time instead of page reading ([ad014ae](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/ad014aeddd44011b1fb470fd5080312d945090fc))
7
+ * complete changes to add reading time to all pages including to modules in search pages and archive pages ([4afbd96](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4afbd960d21abbd09b3ca998aa5a0d9bdb518862))
8
+ * minor change for form ([c9f4eaf](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c9f4eafeceb7c9c091736019acfd745447ab7dd7))
9
+
10
+
11
+ * Merge branch 'tm-3573-news' into 'master' ([4dc2e41](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4dc2e41e9714e4e3c053958da65425a4da67b637))
12
+ * Merge branch 'master' into tm-3573-news ([a2366b1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a2366b1de8ca7acb3f7daa2dad1de9f1733de2cf))
13
+
14
+
15
+ ### Tests
16
+
17
+ * add test ([69eabbd](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/69eabbda0e957f31bd3e76f8ec97619b0af23827))
18
+
1
19
  # [26.0.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v25.0.14...v26.0.0) (2023-08-16)
2
20
 
3
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "26.0.0",
3
+ "version": "27.0.0",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -20,6 +20,7 @@
20
20
 
21
21
  @include min(tablet) {
22
22
  padding: 2.4rem;
23
+ gap: 2.4rem;
23
24
  }
24
25
 
25
26
  h2 {
@@ -196,7 +197,7 @@
196
197
 
197
198
  @include min(tablet) {
198
199
  display: grid;
199
- grid-template-columns: repeat(2, 1fr);
200
+ grid-template-columns: repeat(2, minmax(0, 1fr));
200
201
  column-gap: 4.8rem;
201
202
  row-gap: 1.6rem;
202
203
  }
@@ -12,6 +12,7 @@ export const pickPageKeys = [
12
12
  'description',
13
13
  'true_votes',
14
14
  'false_votes',
15
+ 'reading_time',
15
16
  ];
16
17
 
17
18
  export const topListPickKeys = [
@@ -106,9 +106,6 @@ export function processSections(sections, skipPost = false, page, translations,
106
106
  const pageId = page ? page.id : null;
107
107
  const relationData = page && page.relation;
108
108
 
109
- let minutes = 0;
110
- let seconds = 0;
111
-
112
109
  Object.keys(sections).forEach((sectionKey) => {
113
110
  if (skipPost && sectionKey.includes('post_main')) {
114
111
  return;
@@ -139,7 +136,20 @@ export function processSections(sections, skipPost = false, page, translations,
139
136
  savedModules[module.module_value_id] = module;
140
137
  }
141
138
  }
139
+ });
140
+ }
141
+ });
142
142
 
143
+ return sections;
144
+ }
145
+
146
+ export function getReadingTime(sections) {
147
+ let minutes = 0;
148
+ let seconds = 0;
149
+
150
+ Object.keys(sections).forEach((sectionKey) => {
151
+ if (sections[sectionKey] && sections[sectionKey].modules) {
152
+ sections[sectionKey].modules.forEach((module) => {
143
153
  // calculate reading time
144
154
  if (module.name === 'content') {
145
155
  const nrOfWords = removeTags(module.value).split(' ').length / 250;
@@ -152,6 +162,7 @@ export function processSections(sections, skipPost = false, page, translations,
152
162
  });
153
163
  }
154
164
  });
165
+
155
166
  // transform seconds to minutes as last step
156
167
  if (seconds > 60) {
157
168
  const mins = Math.floor(seconds / 60);
@@ -161,11 +172,7 @@ export function processSections(sections, skipPost = false, page, translations,
161
172
  seconds = decimalSeconds;
162
173
  }
163
174
 
164
- if (page) {
165
- page.reading_time = getRoundMinutes(`${zeroPadding(minutes, 2)}:${zeroPadding(seconds, 2)}`);
166
- }
167
-
168
- return sections;
175
+ return getRoundMinutes(`${zeroPadding(minutes, 2)}:${zeroPadding(seconds, 2)}`) || null;
169
176
  }
170
177
 
171
178
  function processSearchData(data, fs) {
@@ -311,6 +318,9 @@ export default {
311
318
  transformedPages[market][pageType][index].page_styles = data.page_styles[page.style_id];
312
319
  }
313
320
 
321
+ // add reading time for each page
322
+ transformedPages[market][pageType][index].reading_time = getReadingTime(transformedPages[market][pageType][index]?.sections);
323
+
314
324
  // add breadcrumbs array to page
315
325
  const pageBreadcrumbIds = transformedPages[market][pageType][index].breadcrumb_ids;
316
326
  if (pageBreadcrumbIds) {
@@ -1,7 +1,21 @@
1
- import { transform, processExtraFields, processSections, processSitemapPages } from './index';
1
+ import { transform, processExtraFields, processSections, getReadingTime } from './index';
2
2
  import pages from '~tests/factories/pages/pages.factory.js';
3
+ import getPageList from '~tests/factories/pages/page.factory';
3
4
  import multipleMarketsPages from '~tests/factories/pages/multiple-markets-pages.factory.js';
4
5
 
6
+ const tempContent = {
7
+ value: `What is Lorem Ipsum?
8
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
9
+ Why do we use it?
10
+ It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
11
+ Where does it come from?
12
+ Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
13
+ The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
14
+ Where can I get some?
15
+ There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.`,
16
+ name: 'content',
17
+ };
18
+
5
19
  describe('Index Processor', () => {
6
20
  test('Transform', () => {
7
21
  const results = transform(pages);
@@ -31,4 +45,47 @@ describe('Index Processor', () => {
31
45
  const result = processSections(pages.prefilled_market_modules);
32
46
  expect(result).toBeTruthy();
33
47
  });
48
+ test('reading time', () => {
49
+ const relationType = 'author';
50
+ const market = 'ie_en';
51
+ const page = {
52
+ [market]: {
53
+ [relationType]: getPageList({
54
+ template: relationType,
55
+ count: 3,
56
+ relation: null,
57
+ relation_id: 5,
58
+ }),
59
+ },
60
+ };
61
+ const result = getReadingTime(page[market][relationType][0].sections);
62
+ page.reading_time = result;
63
+
64
+ expect(result).toBe(1);
65
+ expect(page.reading_time).toBeTruthy();
66
+ expect(page.reading_time).toBe(result);
67
+
68
+ // Add more content for testing purpose of longer reading time
69
+ const page1 = {
70
+ [market]: {
71
+ [relationType]: getPageList({
72
+ template: relationType,
73
+ count: 3,
74
+ relation: null,
75
+ relation_id: 5,
76
+ }),
77
+ },
78
+ };
79
+
80
+ // eslint-disable-next-line no-plusplus
81
+ for (let index = 0; index < 5; index++) {
82
+ page1[market][relationType][1].sections.main.modules.push(tempContent);
83
+ }
84
+ const result1 = getReadingTime(page1[market][relationType][1].sections);
85
+ page.reading_time = result1;
86
+
87
+ expect(result1).toBe(11);
88
+ expect(page.reading_time).toBeTruthy();
89
+ expect(page.reading_time).toBe(result1);
90
+ });
34
91
  });
@@ -14,7 +14,48 @@ const getDefaultProps = (index = 1, template) => ({
14
14
  logo_url: '#',
15
15
  banner: '313df295c19d7c5f137ceda9d0cc5df7.jpeg',
16
16
  rating: '4.88',
17
- sections: { main: { extra_fields: { logos: { value: 339, type: 'default' } } } },
17
+ sections: {
18
+ main: {
19
+ modules: [
20
+ {
21
+ value:
22
+ "<p>'<em>'Whether it's crafting blog posts, articles, product descriptions, or marketing copy, I approach every project with the same level of passion and dedication. My ability to adapt my writing style to suit different niches and target audiences has earned me a reputation as a versatile and dependable writer</em>.''</p>",
23
+ name: 'content',
24
+ },
25
+ {
26
+ mode: 'image_text',
27
+ show_read_more: null,
28
+ read_more_text: null,
29
+ items: [Array],
30
+ module_value_id: 401446,
31
+ name: 'spotlights',
32
+ },
33
+ {
34
+ cards_page_type: null,
35
+ cards_page_type_id: null,
36
+ cards_selector: 'use_filters',
37
+ cards_selector_manual_list: [],
38
+ cards_selector_filters_limit: null,
39
+ cards_selector_filters: [Object],
40
+ cards_selector_filters_sort_by: 'latest',
41
+ cards_enable_pagination: false,
42
+ module_value_id: 401448,
43
+ name: 'cards_v2',
44
+ anchored: 0,
45
+ },
46
+ {
47
+ value_id: 309998,
48
+ value_type: 'prefilled_module_market',
49
+ anchor_label: null,
50
+ anchor_slug: null,
51
+ module_value_id: 401447,
52
+ },
53
+ ],
54
+ extra_fields: {
55
+ logos: { value: 339, type: 'default' },
56
+ },
57
+ },
58
+ },
18
59
  extra_fields: { related_operator: {} },
19
60
  breadcrumbs: [{ label: 'Sport', path: 'sport' }],
20
61
  preconnect_links: ['1', '2', '3'],