Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #862 from solocommand/newsletter-email-x-render
Browse files Browse the repository at this point in the history
Add unified email-x render component
  • Loading branch information
solocommand authored Feb 1, 2024
2 parents ab0829d + da3e5f5 commit e811fb3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/marko-newsletters-email-x/components/marko.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,25 @@
"@include-advertiser": "boolean"
},
"@decoded-params": "array"
},
"<marko-newsletters-email-x-render>": {
"template": "./render.marko",
"<response>": {
"<data>": {
"<ad>": {
"@height": "number",
"@mindfulCreativeId": "string",
"@width": "number"
}
},
"@imageSrc": "string"
},
"<link>": {
"@href": "string",
"@attrs": "object"
},
"<image>": {
"@attrs": "object"
}
}
}
25 changes: 25 additions & 0 deletions packages/marko-newsletters-email-x/components/render.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { getAsObject, get } from "@parameter1/base-cms-object-path";

$ const response = getAsObject(input, "response");
$ const imageSrc = get(input, "response.imageSrc");
$ const { ad } = response.data;

$ const imageAttrs = {
...getAsObject(input, "image.attrs"),
width: ad.width,
height: ad.height,
};

$ const mindfulCreativeId = get(response, "data.ad.mindfulCreativeId");
$ const linkAttrs = {
href: ad.url,
...(getAsObject(input, "link")),
attrs: {
...(getAsObject(input, "link.attrs")),
...(mindfulCreativeId && { "data-mindful-creative-id": mindfulCreativeId }),
},
};

<marko-core-img ...input.image src=imageSrc attrs=imageAttrs>
<@link target="_blank" ...linkAttrs />
</marko-core-img>

0 comments on commit e811fb3

Please sign in to comment.