diff --git a/packages/marko-newsletters-email-x/components/marko.json b/packages/marko-newsletters-email-x/components/marko.json index 608497180..df6454871 100644 --- a/packages/marko-newsletters-email-x/components/marko.json +++ b/packages/marko-newsletters-email-x/components/marko.json @@ -33,5 +33,25 @@ "@include-advertiser": "boolean" }, "@decoded-params": "array" + }, + "": { + "template": "./render.marko", + "": { + "": { + "": { + "@height": "number", + "@mindfulCreativeId": "string", + "@width": "number" + } + }, + "@imageSrc": "string" + }, + "": { + "@href": "string", + "@attrs": "object" + }, + "": { + "@attrs": "object" + } } } diff --git a/packages/marko-newsletters-email-x/components/render.marko b/packages/marko-newsletters-email-x/components/render.marko new file mode 100644 index 000000000..d57bd6b65 --- /dev/null +++ b/packages/marko-newsletters-email-x/components/render.marko @@ -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 }), + }, +}; + + + <@link target="_blank" ...linkAttrs /> +