This repository has been archived by the owner on Dec 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unified email-x render component
- Loading branch information
1 parent
ab0829d
commit da3e5f5
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/marko-newsletters-email-x/components/render.marko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |