@pronto-tools-and-more/custom-js-functions 12.46.0 → 12.48.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
@@ -412,7 +412,8 @@
|
|
412
412
|
getPrimaryCategoryProperty: () => getPrimaryCategoryProperty,
|
413
413
|
getReadTime: () => getReadTime,
|
414
414
|
handleMenuItems: () => handleMenuItems,
|
415
|
-
id: () => id
|
415
|
+
id: () => id,
|
416
|
+
parse: () => parse
|
416
417
|
});
|
417
418
|
|
418
419
|
// src/parts/Assign/Assign.ts
|
@@ -460,19 +461,24 @@
|
|
460
461
|
return taxonomy.type === "category";
|
461
462
|
};
|
462
463
|
var getPrimaryCategoryProperty = (content, key) => {
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
primaryCategory
|
470
|
-
|
471
|
-
|
472
|
-
|
464
|
+
try {
|
465
|
+
const primaryCategoryId = content.properties["taxonomy.category.primary"];
|
466
|
+
const categories = content.taxonomies.filter(isCategory);
|
467
|
+
let primaryCategory = categories.find(
|
468
|
+
(category) => category.id === primaryCategoryId
|
469
|
+
);
|
470
|
+
if (!primaryCategory) {
|
471
|
+
primaryCategory = categories[0];
|
472
|
+
}
|
473
|
+
if (!primaryCategory) {
|
474
|
+
return "n/a";
|
475
|
+
}
|
476
|
+
const value = primaryCategory[key] || "n/a";
|
477
|
+
return value;
|
478
|
+
} catch (error) {
|
479
|
+
console.error(`Category Error: ${error}`);
|
480
|
+
return `category error`;
|
473
481
|
}
|
474
|
-
const value = primaryCategory[key] || "n/a";
|
475
|
-
return value;
|
476
482
|
};
|
477
483
|
|
478
484
|
// src/parts/HandleMenuItems/HandleMenuItems.ts
|
@@ -484,6 +490,11 @@
|
|
484
490
|
return `highlight-${index}`;
|
485
491
|
};
|
486
492
|
|
493
|
+
// src/parts/Parse/Parse.ts
|
494
|
+
var parse = (content) => {
|
495
|
+
return JSON.parse(content);
|
496
|
+
};
|
497
|
+
|
487
498
|
// src/parts/ReadTime/ReadTime.ts
|
488
499
|
var getReadTime = (content) => {
|
489
500
|
const parsedSeo = JSON.parse(content?.properties?.purple_seo_meta);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pronto-tools-and-more/custom-js-functions",
|
3
|
-
"version": "12.
|
3
|
+
"version": "12.48.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/main.js",
|
6
6
|
"type": "module",
|
@@ -17,7 +17,7 @@
|
|
17
17
|
"devDependencies": {
|
18
18
|
"@types/node": "^22.10.0",
|
19
19
|
"dayjs": "^1.11.13",
|
20
|
-
"esbuild": "^0.
|
20
|
+
"esbuild": "^0.25.0",
|
21
21
|
"jest-environment-jsdom": "^29.7.0",
|
22
22
|
"ts-jest": "^29.2.5"
|
23
23
|
},
|
@@ -5,4 +5,5 @@ export * from "../FunctionDebugId/FunctionDebugId.ts";
|
|
5
5
|
export * from "../FunctionId/FunctionId.ts";
|
6
6
|
export * from "../GetCategoryProperty/GetCategoryProperty.ts";
|
7
7
|
export * from "../HandleMenuItems/HandleMenuItems.ts";
|
8
|
+
export * from "../Parse/Parse.ts";
|
8
9
|
export * from "../ReadTime/ReadTime.ts";
|
@@ -3,17 +3,22 @@ const isCategory = (taxonomy) => {
|
|
3
3
|
};
|
4
4
|
|
5
5
|
export const getPrimaryCategoryProperty = (content, key) => {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
primaryCategory
|
6
|
+
try {
|
7
|
+
const primaryCategoryId = content.properties["taxonomy.category.primary"];
|
8
|
+
const categories = content.taxonomies.filter(isCategory);
|
9
|
+
let primaryCategory = categories.find(
|
10
|
+
(category) => category.id === primaryCategoryId
|
11
|
+
);
|
12
|
+
if (!primaryCategory) {
|
13
|
+
primaryCategory = categories[0];
|
14
|
+
}
|
15
|
+
if (!primaryCategory) {
|
16
|
+
return "n/a";
|
17
|
+
}
|
18
|
+
const value = primaryCategory[key] || "n/a";
|
19
|
+
return value;
|
20
|
+
} catch (error) {
|
21
|
+
console.error(`Category Error: ${error}`);
|
22
|
+
return `category error`;
|
13
23
|
}
|
14
|
-
if (!primaryCategory) {
|
15
|
-
return "n/a";
|
16
|
-
}
|
17
|
-
const value = primaryCategory[key] || "n/a";
|
18
|
-
return value;
|
19
24
|
};
|