gatsby-core-theme 44.25.2 → 44.25.3
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,14 @@
|
|
|
1
|
+
## [44.25.3](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.25.2...v44.25.3) (2026-06-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add tests ([ef7bba6](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/ef7bba67ffc98946830fe0d6c59a1c5e11753463))
|
|
7
|
+
* update short codes to include images and different operator types ([8c48199](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/8c48199182778c9d1b87d09d5c407f7c754eba5f))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
* Merge branch 'en-441-shortcodes' into 'master' ([658d10f](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/658d10fc7c5b0b57631468b8ff44c2a381fd8e07))
|
|
11
|
+
|
|
1
12
|
## [44.25.2](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.25.1...v44.25.2) (2026-06-02)
|
|
2
13
|
|
|
3
14
|
|
package/package.json
CHANGED
package/src/helpers/getters.mjs
CHANGED
|
@@ -581,9 +581,13 @@ export const mapEntitiesByKey = ({ data = {}, keyField }) =>
|
|
|
581
581
|
|
|
582
582
|
if (!key) return acc;
|
|
583
583
|
|
|
584
|
-
|
|
584
|
+
const normalizedKey = String(key).toLowerCase();
|
|
585
585
|
|
|
586
|
+
if (!acc[normalizedKey]) {
|
|
587
|
+
acc[normalizedKey] = [];
|
|
588
|
+
}
|
|
586
589
|
|
|
590
|
+
acc[normalizedKey].push(item);
|
|
587
591
|
|
|
588
592
|
return acc;
|
|
589
593
|
}, {});
|
|
@@ -169,3 +169,131 @@ describe("resolveOperatorContentShortcode", () => {
|
|
|
169
169
|
expect(result).toBeNull();
|
|
170
170
|
});
|
|
171
171
|
});
|
|
172
|
+
|
|
173
|
+
describe("new array and operator_type behavior", () => {
|
|
174
|
+
beforeEach(() => {
|
|
175
|
+
process.env.IMAGE_CDN_URL = "https://cdn.example.com";
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test("returns operator matching operator_type", () => {
|
|
179
|
+
const operators = {
|
|
180
|
+
142: [
|
|
181
|
+
{
|
|
182
|
+
id: 76387,
|
|
183
|
+
type: "casino",
|
|
184
|
+
name: "Bet365 Casino",
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: 60184,
|
|
188
|
+
type: "sportsbook",
|
|
189
|
+
name: "Bet365 Sportsbook",
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const match = "[field=name type=operator id=142 operator_type=sportsbook]";
|
|
195
|
+
|
|
196
|
+
const result = resolveOperatorContentShortcode(match, operators, {});
|
|
197
|
+
|
|
198
|
+
expect(result).toEqual("Bet365 Sportsbook");
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("returns first operator when operator_type is not provided", () => {
|
|
202
|
+
const operators = {
|
|
203
|
+
142: [
|
|
204
|
+
{
|
|
205
|
+
type: "casino",
|
|
206
|
+
name: "Bet365 Casino",
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
type: "sportsbook",
|
|
210
|
+
name: "Bet365 Sportsbook",
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const match = "[field=name type=operator id=142]";
|
|
216
|
+
|
|
217
|
+
const result = resolveOperatorContentShortcode(match, operators, {});
|
|
218
|
+
|
|
219
|
+
expect(result).toEqual("Bet365 Casino");
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test("returns null when operator_type does not match", () => {
|
|
223
|
+
const operators = {
|
|
224
|
+
142: [
|
|
225
|
+
{
|
|
226
|
+
type: "casino",
|
|
227
|
+
name: "Bet365 Casino",
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
const match = "[field=name type=operator id=142 operator_type=sportsbook]";
|
|
233
|
+
|
|
234
|
+
const result = resolveOperatorContentShortcode(match, operators, {});
|
|
235
|
+
|
|
236
|
+
expect(result).toBeNull();
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
test("returns first game when game entity is an array", () => {
|
|
240
|
+
const games = {
|
|
241
|
+
1962: [
|
|
242
|
+
{
|
|
243
|
+
game_id: 1962,
|
|
244
|
+
name: "Wolf Gold",
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
const match = "[field=name type=game id=1962]";
|
|
250
|
+
|
|
251
|
+
const result = resolveOperatorContentShortcode(match, {}, games);
|
|
252
|
+
|
|
253
|
+
expect(result).toEqual("Wolf Gold");
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
test("returns standardized logo img tag", () => {
|
|
257
|
+
const operators = {
|
|
258
|
+
1: {
|
|
259
|
+
logo: {
|
|
260
|
+
filename: "logo.png",
|
|
261
|
+
width: 100,
|
|
262
|
+
height: 50,
|
|
263
|
+
alt: "Bet365",
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const match = "[field=standardized_logo type=operator id=1]";
|
|
269
|
+
|
|
270
|
+
const result = resolveOperatorContentShortcode(match, operators, {});
|
|
271
|
+
|
|
272
|
+
expect(result).toContain("<img");
|
|
273
|
+
expect(result).toContain("logo.png");
|
|
274
|
+
expect(result).toContain('alt="Bet365"');
|
|
275
|
+
expect(result).toContain('width="100"');
|
|
276
|
+
expect(result).toContain('height="50"');
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
test("handles operator_type case-insensitively", () => {
|
|
280
|
+
const operators = {
|
|
281
|
+
142: [
|
|
282
|
+
{
|
|
283
|
+
type: "casino",
|
|
284
|
+
name: "Bet365 Casino",
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
type: "sportsbook",
|
|
288
|
+
name: "Bet365 Sportsbook",
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
const match = "[field=name type=operator id=142 operator_type=SPORTSBOOK]";
|
|
294
|
+
|
|
295
|
+
const result = resolveOperatorContentShortcode(match, operators, {});
|
|
296
|
+
|
|
297
|
+
expect(result).toEqual("Bet365 Sportsbook");
|
|
298
|
+
});
|
|
299
|
+
});
|
|
@@ -1,9 +1,49 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-cycle
|
|
2
|
+
|
|
3
|
+
const getImageExtension = (filename) => filename && filename.split(".").pop();
|
|
4
|
+
|
|
5
|
+
const imagePrettyUrl = (filename, width = null, height = null) => {
|
|
6
|
+
if (filename) {
|
|
7
|
+
const extension = getImageExtension(filename);
|
|
8
|
+
|
|
9
|
+
const hasFilters = extension !== "svg" && extension !== "gif";
|
|
10
|
+
const cdnURL =
|
|
11
|
+
// eslint-disable-next-line no-nested-ternary
|
|
12
|
+
(hasFilters
|
|
13
|
+
? process.env.IMAGE_CDN_URL
|
|
14
|
+
: process.env.IMAGE_CDN_URL
|
|
15
|
+
? process.env.IMAGE_CDN_URL.replace("/filters:format(webp)", "")
|
|
16
|
+
: "") || process.env.STORYBOOK_IMAGE_CDN_URL;
|
|
17
|
+
|
|
18
|
+
if (width && height && hasFilters) {
|
|
19
|
+
const urlPath = "/fit-in";
|
|
20
|
+
const urlSize = `/${width}x${height}`;
|
|
21
|
+
|
|
22
|
+
return `${cdnURL}${urlPath}${urlSize}/${filename}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return `${cdnURL}/${filename}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return "/images/placeholder-image.jpg";
|
|
29
|
+
};
|
|
30
|
+
|
|
1
31
|
const stripHtml = (html = "") => html.replace(/<[^>]*>/g, "").trim();
|
|
2
32
|
|
|
3
33
|
const getMainBonus = (operator) =>
|
|
4
34
|
Object.values(operator.bonuses || {})[0] || {};
|
|
5
35
|
|
|
6
36
|
const operatorFieldResolvers = {
|
|
37
|
+
standardized_logo: (operator) => `<img
|
|
38
|
+
src="${imagePrettyUrl(
|
|
39
|
+
operator.logo.filename,
|
|
40
|
+
operator.logo.width,
|
|
41
|
+
operator.logo.height,
|
|
42
|
+
)}"
|
|
43
|
+
alt="${operator.logo.alt}"
|
|
44
|
+
width="${operator.logo.width || ""}"
|
|
45
|
+
height="${operator.logo.height || ""}"
|
|
46
|
+
/>`,
|
|
7
47
|
average_rating: (operator) => operator.rating,
|
|
8
48
|
|
|
9
49
|
currencies: (operator) =>
|
|
@@ -35,6 +75,8 @@ export const resolveOperatorContentShortcode = (match, operators, games) => {
|
|
|
35
75
|
const fieldMatch = match.match(/field=([^\s\]]+)/i);
|
|
36
76
|
const typeMatch = match.match(/type=([^\s\]]+)/i);
|
|
37
77
|
const idMatch = match.match(/id=(\d+)/);
|
|
78
|
+
const operatorTypeMatch = match.match(/operator_type=([^\s\]]+)/i);
|
|
79
|
+
const operatorType = operatorTypeMatch?.[1]?.toLowerCase();
|
|
38
80
|
|
|
39
81
|
const field = fieldMatch?.[1];
|
|
40
82
|
const type = typeMatch?.[1]?.toLowerCase();
|
|
@@ -47,10 +89,17 @@ export const resolveOperatorContentShortcode = (match, operators, games) => {
|
|
|
47
89
|
game: games,
|
|
48
90
|
};
|
|
49
91
|
|
|
50
|
-
|
|
51
92
|
if (!entityMaps[type]) return null;
|
|
52
93
|
|
|
53
|
-
|
|
94
|
+
let entity = entityMaps[type]?.[String(id).toLowerCase()];
|
|
95
|
+
|
|
96
|
+
if (Array.isArray(entity)) {
|
|
97
|
+
if (type === "operator" && operatorType) {
|
|
98
|
+
entity = entity.find((op) => op.type?.toLowerCase() === operatorType);
|
|
99
|
+
} else {
|
|
100
|
+
[entity] = entity;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
54
103
|
|
|
55
104
|
if (!entity) return null;
|
|
56
105
|
|