gatsby-core-theme 1.6.13 → 1.6.14

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,16 @@
1
+ ## [1.6.14](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.6.13...v1.6.14) (2021-12-01)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * added clean up html tags in faq schema data ([0b9ae93](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/0b9ae937928ede9f1f710ee0749108bf99b16757))
7
+ * added clean up html tags in faq schema data ([1b22637](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/1b22637bfadd48e9731e01d82b39e7db97e156ac))
8
+ * added new cdn env var for gifs ([e5bb4bc](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/e5bb4bc6507688fbb8060a4df349fe5ff534a009))
9
+ * geturl func ([c531ed3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c531ed335ae4e35aaa5b94010cb136d419826ac7))
10
+
11
+
12
+ * Merge branch 'fix-gif-images' into 'master' ([0fd8aab](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/0fd8aab0d3798b6487d0cc5a3d1a5a8c14d45c7f))
13
+
1
14
  ## [1.6.13](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.6.12...v1.6.13) (2021-11-28)
2
15
 
3
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "1.6.13",
3
+ "version": "1.6.14",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -90,8 +90,15 @@ export function image(filename, width, height, fit = 'cover') {
90
90
  return `${cloudFrontUrl}/${Buffer.from(imageRequest).toString('base64')}`;
91
91
  }
92
92
 
93
+ export function getImageExtension(filename) {
94
+ return filename && filename.split('.').pop();
95
+ }
96
+
93
97
  export function imagePrettyUrl(filename = 'image.png', width = null, height = null) {
94
- const cdnURL = process.env.IMAGE_CDN_URL || process.env.STORYBOOK_IMAGE_CDN_URL;
98
+ const cdnURL =
99
+ (getImageExtension(filename) === 'gif'
100
+ ? process.env.GIFS_CDN_URL
101
+ : process.env.IMAGE_CDN_URL) || process.env.STORYBOOK_IMAGE_CDN_URL;
95
102
 
96
103
  if (width && height) {
97
104
  const urlPath = '/fit-in';
@@ -262,7 +269,8 @@ export function getUrl(path) {
262
269
  if (path === '/') {
263
270
  return process.env.GATSBY_SITE_URL;
264
271
  }
265
- return `${process.env.GATSBY_SITE_URL}${path}`;
272
+
273
+ return `${process.env.GATSBY_SITE_URL}${path.replace(/^\//, '')}`;
266
274
  }
267
275
 
268
276
  export function getLanguage(language) {
@@ -68,6 +68,12 @@ describe('Getters Helper', () => {
68
68
  );
69
69
  });
70
70
 
71
+ test('getImageExtension()', () => {
72
+ expect(Getters.getImageExtension('photo.jpg')).toBeTruthy();
73
+ expect(Getters.getImageExtension('photo.jpg')).toEqual('jpg');
74
+ expect(Getters.getImageExtension(null)).toEqual(null);
75
+ });
76
+
71
77
  test('getPageImage()', () => {
72
78
  expect(
73
79
  Getters.getPageImage({ type: 'operator', relation: { default_logo_url: 'foo.jpg' } })
@@ -191,8 +197,9 @@ describe('Getters Helper', () => {
191
197
  });
192
198
 
193
199
  test('getUrl()', () => {
194
- expect(Getters.getUrl('/')).toEqual('http://urltest.com');
200
+ expect(Getters.getUrl('/')).toEqual('http://urltest.com/');
195
201
  expect(Getters.getUrl('/games')).toEqual('http://urltest.com/games');
202
+ expect(Getters.getUrl('games')).toEqual('http://urltest.com/games');
196
203
  });
197
204
 
198
205
  test('getLanguage()', () => {
@@ -1,4 +1,5 @@
1
1
  import { getGameRating, getUrl, getLanguage } from './getters';
2
+ import { cleanHTML } from './strings';
2
3
 
3
4
  /* HardCoded Start */
4
5
  const isIL = process.env.GATSBY_SITE_NAME === 'Irishluck.ie';
@@ -178,9 +179,9 @@ export function moduleSchemas(modules) {
178
179
  '@type': 'Question',
179
180
  acceptedAnswer: {
180
181
  '@type': 'Answer',
181
- text: item.answer,
182
+ text: cleanHTML(item.answer),
182
183
  },
183
- name: item.question,
184
+ name: cleanHTML(item.question),
184
185
  })),
185
186
  };
186
187
 
@@ -370,8 +370,9 @@ describe('Schema Helper', () => {
370
370
  test('schemaGenerator()', () => {
371
371
  const output = Schema.schemaGenerator({
372
372
  seo_json_schema: 'SEO JSON Schema',
373
- breadcrumbs: [{}],
373
+ breadcrumbs: [{ path: '/test' }],
374
374
  type: 'article',
375
+ path: '/test-path',
375
376
  sections: { main: { modules: [{ name: 'faq' }] } },
376
377
  });
377
378
 
@@ -51,3 +51,7 @@ export function truncateString(str, num, dots = '...') {
51
51
  trimmedString = trimmedString.substr(0, trimmedString.lastIndexOf(' '));
52
52
  return `${trimmedString}${dots}`;
53
53
  }
54
+
55
+ export function cleanHTML(string) {
56
+ return string && string.replace(/(<([^>]+)>)/gi, '');
57
+ }
@@ -26,7 +26,11 @@ describe('Strings Helper', () => {
26
26
  });
27
27
 
28
28
  test('truncateString()', () => {
29
- expect(Strings.truncateString('hello i think',5)).toEqual('hello...');
30
- expect(Strings.truncateString('hello i think',10)).toEqual('hello i...');
29
+ expect(Strings.truncateString('hello i think', 5)).toEqual('hello...');
30
+ expect(Strings.truncateString('hello i think', 10)).toEqual('hello i...');
31
+ });
32
+
33
+ test('cleanHTML()', () => {
34
+ expect(Strings.cleanHTML('<p>hello <a>i</a> think</p>')).toEqual('hello i think');
31
35
  });
32
36
  });
package/tests/envVars.js CHANGED
@@ -1,5 +1,5 @@
1
1
  process.env.GATSBY_SITE_NAME = 'norskespilleautomater.com';
2
- process.env.GATSBY_SITE_URL = 'http://urltest.com';
2
+ process.env.GATSBY_SITE_URL = 'http://urltest.com/';
3
3
  process.env.IMAGE_CDN_URL = 'https://cdn.images.com';
4
4
  process.env.TRACKER_LINK_FORMAT_MAIN = '[no],[visit],short_name';
5
5
  process.env.TRACKER_LINK_FORMAT_NON_MAIN = '[no],[visit],short_name,type,[tracker]';