@pronto-tools-and-more/components-renderer 10.0.0 → 10.1.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/components-renderer",
3
- "version": "10.0.0",
3
+ "version": "10.1.0",
4
4
  "description": "",
5
5
  "main": "src/componentsRendererMain.js",
6
6
  "type": "module",
@@ -3,25 +3,25 @@ import * as RenderCustomElementCollection from "../RenderCustomElementCollection
3
3
  import * as RenderCustomElementList from "../RenderCustomElementList/RenderCustomElementList.js";
4
4
  import * as RenderCustomElementSearchResults from "../RenderCustomElementSearchResults/RenderCustomElementSearchResults.js";
5
5
  import * as RenderCustomElementUnknown from "../RenderCustomElementUnknown/RenderCustomElementUnknown.js";
6
+ import * as RenderCustomElementAuthorList from "../RenderCustomElementAuthorList/RenderCustomElementAuthorList.js";
7
+
8
+ const renderers = [
9
+ RenderCustomElementAuthorList.renderCustomElementAuthorList,
10
+ RenderCustomElementCategoryList.renderCustomElementCategoryList,
11
+ RenderCustomElementCollection.renderCustomElementCollection,
12
+ RenderCustomElementList.renderCustomElementList,
13
+ RenderCustomElementSearchResults.renderCustomElementSearchResults,
14
+ ];
6
15
 
7
16
  export const renderCustomElement = (element, renderElement) => {
8
- return (
9
- RenderCustomElementCollection.renderCustomElementCollection(
10
- element,
11
- renderElement
12
- ) ||
13
- RenderCustomElementList.renderCustomElementList(element, renderElement) ||
14
- RenderCustomElementCategoryList.renderCustomElementCategoryList(
15
- element,
16
- renderElement
17
- ) ||
18
- RenderCustomElementSearchResults.renderCustomElementSearchResults(
19
- element,
20
- renderElement
21
- ) ||
22
- RenderCustomElementUnknown.renderCustomElementUnknown(
23
- element,
24
- renderElement
25
- )
17
+ for (const renderer of renderers) {
18
+ const result = renderer(element, renderElement);
19
+ if (result) {
20
+ return result;
21
+ }
22
+ }
23
+ return RenderCustomElementUnknown.renderCustomElementUnknown(
24
+ element,
25
+ renderElement
26
26
  );
27
27
  };
@@ -0,0 +1,22 @@
1
+ export const renderCustomElementAuthorList = (element, renderElement) => {
2
+ if (
3
+ element.type === "list" &&
4
+ element.class &&
5
+ element.class.includes("data-custom-author-list")
6
+ ) {
7
+ const { render, ...rest } = element;
8
+ const node = render({
9
+ id: `$functions.id($context, 'context', 'id')`,
10
+ name: `$functions.id($context, 'context', 'name')`,
11
+ type: `$functions.id($context, 'context', 'type')`,
12
+ language: `$functions.id($context, 'context', 'properties', 'lang')`,
13
+ imageSrc: `$functions.id($context, 'context', 'properties', 'thumbnails', 'default')`,
14
+ });
15
+ const final = renderElement(node);
16
+ return {
17
+ ...rest,
18
+ content: final,
19
+ };
20
+ }
21
+ return undefined;
22
+ };
@@ -11,7 +11,15 @@ export const renderCustomElementCategoryList = (element, renderElement) => {
11
11
  type: `$functions.id($context, 'context', 'type')`,
12
12
  language: `$functions.id($context, 'context', 'properties', 'lang')`,
13
13
  });
14
- const final = renderElement(node);
14
+ const condition = {
15
+ value: "$context.context.type",
16
+ operation: "EQUALS",
17
+ compareValue: "category",
18
+ };
19
+ const final = {
20
+ ...renderElement(node),
21
+ condition,
22
+ };
15
23
  return {
16
24
  ...rest,
17
25
  content: final,