@pronto-tools-and-more/custom-js-functions 10.39.0 → 10.40.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/dist/main.js
CHANGED
@@ -442,15 +442,23 @@
|
|
442
442
|
};
|
443
443
|
|
444
444
|
// src/parts/GetCategoryProperty/GetCategoryProperty.ts
|
445
|
+
var isCategory = (taxonomy) => {
|
446
|
+
return taxonomy.type === "category";
|
447
|
+
};
|
445
448
|
var getPrimaryCategoryProperty = (content, key) => {
|
446
449
|
const primaryCategoryId = content.properties["taxonomy.category.primary"];
|
447
|
-
const
|
448
|
-
|
450
|
+
const categories = content.taxonomies.filter(isCategory);
|
451
|
+
let primaryCategory = categories.find(
|
452
|
+
(category) => category.id === primaryCategoryId
|
449
453
|
);
|
450
|
-
if (!
|
451
|
-
|
454
|
+
if (!primaryCategory) {
|
455
|
+
primaryCategory = categories[0];
|
456
|
+
}
|
457
|
+
if (!primaryCategory) {
|
458
|
+
return "n/a";
|
452
459
|
}
|
453
|
-
|
460
|
+
const value = primaryCategory[key] || "n/a";
|
461
|
+
return value;
|
454
462
|
};
|
455
463
|
|
456
464
|
// src/parts/HandleMenuItems/HandleMenuItems.ts
|
package/package.json
CHANGED
@@ -1,10 +1,19 @@
|
|
1
|
+
const isCategory = (taxonomy) => {
|
2
|
+
return taxonomy.type === "category";
|
3
|
+
};
|
4
|
+
|
1
5
|
export const getPrimaryCategoryProperty = (content, key) => {
|
2
6
|
const primaryCategoryId = content.properties["taxonomy.category.primary"];
|
3
|
-
const
|
4
|
-
|
7
|
+
const categories = content.taxonomies.filter(isCategory);
|
8
|
+
let primaryCategory = categories.find(
|
9
|
+
(category) => category.id === primaryCategoryId
|
5
10
|
);
|
6
|
-
if (!
|
7
|
-
|
11
|
+
if (!primaryCategory) {
|
12
|
+
primaryCategory = categories[0];
|
13
|
+
}
|
14
|
+
if (!primaryCategory) {
|
15
|
+
return "n/a";
|
8
16
|
}
|
9
|
-
|
17
|
+
const value = primaryCategory[key] || "n/a";
|
18
|
+
return value;
|
10
19
|
};
|