@pronto-tools-and-more/custom-js-functions 10.37.0 → 10.39.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
@@ -407,6 +407,7 @@
407
407
  __export(Functions_exports, {
408
408
  dateHelper: () => dateHelper,
409
409
  debugId: () => debugId,
410
+ getPrimaryCategoryProperty: () => getPrimaryCategoryProperty,
410
411
  getReadTime: () => getReadTime,
411
412
  handleMenuItems: () => handleMenuItems,
412
413
  id: () => id
@@ -440,6 +441,18 @@
440
441
  return current;
441
442
  };
442
443
 
444
+ // src/parts/GetCategoryProperty/GetCategoryProperty.ts
445
+ var getPrimaryCategoryProperty = (content, key) => {
446
+ const primaryCategoryId = content.properties["taxonomy.category.primary"];
447
+ const category = content.taxonomies.find(
448
+ (taxonomy) => taxonomy.id === primaryCategoryId
449
+ );
450
+ if (!category) {
451
+ return "";
452
+ }
453
+ return category[key];
454
+ };
455
+
443
456
  // src/parts/HandleMenuItems/HandleMenuItems.ts
444
457
  var handleMenuItems = (items, active) => {
445
458
  const index = items.findIndex((item) => item.id === active);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/custom-js-functions",
3
- "version": "10.37.0",
3
+ "version": "10.39.0",
4
4
  "description": "",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",
@@ -1,5 +1,6 @@
1
1
  export * from "../DateHelper/DateHelper.ts";
2
2
  export * from "../FunctionDebugId/FunctionDebugId.ts";
3
3
  export * from "../FunctionId/FunctionId.ts";
4
+ export * from "../GetCategoryProperty/GetCategoryProperty.ts";
4
5
  export * from "../HandleMenuItems/HandleMenuItems.ts";
5
6
  export * from "../ReadTime/ReadTime.ts";
@@ -0,0 +1,10 @@
1
+ export const getPrimaryCategoryProperty = (content, key) => {
2
+ const primaryCategoryId = content.properties["taxonomy.category.primary"];
3
+ const category = content.taxonomies.find(
4
+ (taxonomy) => taxonomy.id === primaryCategoryId
5
+ );
6
+ if (!category) {
7
+ return "";
8
+ }
9
+ return category[key];
10
+ };