From da3e5f55cb0ec59cfdec44f01d841f8b7734986f Mon Sep 17 00:00:00 2001 From: Josh Worden Date: Thu, 1 Feb 2024 14:28:38 -0600 Subject: [PATCH] Add unified email-x render component --- .../components/marko.json | 20 +++++++++++++++ .../components/render.marko | 25 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 packages/marko-newsletters-email-x/components/render.marko 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 /> +