@pronto-tools-and-more/custom-js-functions 10.14.0 → 10.15.1

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
@@ -9,6 +9,8 @@
9
9
  // src/parts/Functions/Functions.ts
10
10
  var Functions_exports = {};
11
11
  __export(Functions_exports, {
12
+ fixRender: () => fixRender,
13
+ getReadTime: () => getReadTime,
12
14
  id: () => id
13
15
  });
14
16
 
@@ -23,6 +25,38 @@
23
25
  return current;
24
26
  };
25
27
 
28
+ // src/parts/FixRender/FixRender.ts
29
+ var fixRender = (that) => {
30
+ const root = that.parentNode.parentNode.parentNode.parentNode.parentNode;
31
+ const ancestor = that.parentNode.parentNode.parentNode.parentNode;
32
+ const realNodes = [];
33
+ for (let i = 1; i < 2; i++) {
34
+ const child = ancestor.children[i];
35
+ const realNodeClassName = child.children[0].className;
36
+ const realNode = child.children[0].children[0];
37
+ realNode.className = realNodeClassName;
38
+ realNodes.push(realNode);
39
+ }
40
+ const realChildren = [];
41
+ for (let i = 2; i < ancestor.children.length; i++) {
42
+ const child = ancestor.children[i];
43
+ if (child.nodeName === "storefront-section") {
44
+ realChildren.push(child.children[0].children[0]);
45
+ } else {
46
+ realChildren.push(child);
47
+ }
48
+ }
49
+ realNodes[0].append(...realChildren);
50
+ root.replaceWith(realNodes[0]);
51
+ };
52
+
53
+ // src/parts/ReadTime/ReadTime.ts
54
+ var getReadTime = (content) => {
55
+ const parsedSeo = JSON.parse(content?.properties?.purple_seo_meta);
56
+ const readTime = parsedSeo?.twitter_misc?.["Est. reading time"] || "n/a";
57
+ return readTime;
58
+ };
59
+
26
60
  // src/parts/Main/Main.ts
27
61
  var main = () => {
28
62
  const ref = window.$functions || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/custom-js-functions",
3
- "version": "10.14.0",
3
+ "version": "10.15.1",
4
4
  "description": "",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",
@@ -17,6 +17,7 @@
17
17
  "devDependencies": {
18
18
  "@types/node": "^22.9.0",
19
19
  "esbuild": "^0.24.0",
20
+ "jest-environment-jsdom": "^29.7.0",
20
21
  "ts-jest": "^29.2.5"
21
22
  },
22
23
  "engines": {
@@ -0,0 +1,27 @@
1
+ export const fixRender = (that) => {
2
+ const root = that.parentNode.parentNode.parentNode.parentNode.parentNode;
3
+ const ancestor = that.parentNode.parentNode.parentNode.parentNode;
4
+ const realNodes = [];
5
+ for (let i = 1; i < 2; i++) {
6
+ const child = ancestor.children[i];
7
+ const realNodeClassName = child.children[0].className;
8
+ const realNode = child.children[0].children[0];
9
+ realNode.className = realNodeClassName;
10
+ // @ts-ignore
11
+ realNodes.push(realNode);
12
+ }
13
+ const realChildren = [];
14
+ for (let i = 2; i < ancestor.children.length; i++) {
15
+ const child = ancestor.children[i];
16
+ if (child.nodeName === "storefront-section") {
17
+ // @ts-ignore
18
+ realChildren.push(child.children[0].children[0]);
19
+ } else {
20
+ // @ts-ignore
21
+ realChildren.push(child);
22
+ }
23
+ }
24
+ // @ts-ignore
25
+ realNodes[0].append(...realChildren);
26
+ root.replaceWith(realNodes[0]);
27
+ };
@@ -1 +1,3 @@
1
1
  export * from "../FunctionId/FunctionId.js";
2
+ export * from "../FixRender/FixRender.ts";
3
+ export * from "../ReadTime/ReadTime.ts";
@@ -0,0 +1,5 @@
1
+ export const getReadTime = (content: any) => {
2
+ const parsedSeo = JSON.parse(content?.properties?.purple_seo_meta);
3
+ const readTime = parsedSeo?.twitter_misc?.["Est. reading time"] || "n/a";
4
+ return readTime;
5
+ };