-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from jwade1327/case-of-the-day
Create case of the day newsletter
- Loading branch information
Showing
14 changed files
with
253 additions
and
1 deletion.
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
41 changes: 41 additions & 0 deletions
41
packages/common/components/blocks/ad/promotion-case-native.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,41 @@ | ||
import { get, getAsObject } from "@parameter1/base-cms-object-path"; | ||
import { URLSearchParams } from "url"; | ||
|
||
$ const { content, urlParams, date } = input; | ||
|
||
$ const queryString = (urlParams && content.type !== 'promotion') ? `?${new URLSearchParams(urlParams)}` : ""; | ||
$ const contentUrl = `${content.siteContext.url}${queryString}`; | ||
|
||
$ const imgStyles = { | ||
"border": 0, | ||
"outline": "none", | ||
"text-decoration": "none", | ||
"display": "block", | ||
"height": "auto !important", | ||
"max-width": "100% !important", | ||
}; | ||
|
||
$ const imgLinkStyles = { | ||
"font-family": "'Roboto', arial, sans-serif", | ||
"border": 0, | ||
"outline": "none", | ||
"text-decoration": "none", | ||
}; | ||
|
||
<table role="presentation" width="610" border="0" align="center" cellpadding="0" cellspacing="0" class="wrap003"> | ||
<tr> | ||
<td align="center"> | ||
<marko-core-obj-value|{ value: image }| obj=content field="primaryImage" as="object"> | ||
<marko-newsletter-imgix | ||
src=image.src | ||
alt=image.alt | ||
options={ w: 400, fit: "crop", auto: "format,compress" } | ||
attrs={ border: 0, style: imgStyles } | ||
> | ||
<@link href=contentUrl target="_blank" attrs={ style: imgLinkStyles } /> | ||
</marko-newsletter-imgix> | ||
</marko-core-obj-value> | ||
</td> | ||
</tr> | ||
<common-table-spacer-element height="20" /> | ||
</table> |
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
84 changes: 84 additions & 0 deletions
84
packages/common/components/blocks/content/api-list-item.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,84 @@ | ||
import { get, getAsArray } from "@parameter1/base-cms-object-path"; | ||
import defaultValue from "@parameter1/base-cms-marko-core/utils/default-value"; | ||
import buildLinkUrl from '@science-medicine-group/package-common/utils/build-link-url'; | ||
|
||
$ const { content, ctaLinkStyle } = input; | ||
$ const url = buildLinkUrl(content.siteContext.url); | ||
$ const withImage = defaultValue(input.withImage, true); | ||
$ const imagePosition = defaultValue(input.imagePosition, 'right'); | ||
|
||
$ const imgStyles = { | ||
"border": 0, | ||
"outline": "none", | ||
"text-decoration": "none", | ||
"display": "block", | ||
"height": "auto !important", | ||
"max-width": "100% !important", | ||
}; | ||
|
||
$ const imgLinkStyles = { | ||
"font-family": "'Roboto', arial, sans-serif", | ||
"border": 0, | ||
"outline": "none", | ||
"text-decoration": "none", | ||
}; | ||
|
||
$ const linkLabel = input.storyLocation ? `story|${input.storyLocation}|${content.name}` : input.linkLabel; | ||
|
||
<tr> | ||
<td align="center" valign="top"> | ||
<table role="presentation" width="610" border="0" align="center" cellpadding="0" cellspacing="0" class="wrap003"> | ||
<if(withImage && imagePosition === 'right' && content.primaryImage)> | ||
<tr> | ||
<td align="center" valign="top"> | ||
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0"> | ||
<tr> | ||
<td align="left" valign="top"> | ||
<table role="presentation" width="100%" border="0" cellpadding="0" cellspacing="0" class="pad" style="padding: 0 20px 0px 0;"> | ||
<tr> | ||
<td align="left" valign="top"> | ||
<a style="font-family: 'Roboto', arial, sans-serif;font-size: 24px;line-height: 28px;color: #202022;font-weight: 700;text-decoration: none;" href=url target="_blank"> | ||
$!{content.teaser} | ||
</a> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
<td align="right" valign="top" width="150" class="wdt"> | ||
<marko-core-obj-value|{ value: image }| obj=content field="primaryImage" as="object"> | ||
<marko-newsletter-imgix | ||
src=image.src | ||
alt=image.alt | ||
options={ w: 400, h: 266, fit: "crop", auto: "format,compress" } | ||
class="img_resize2" | ||
attrs={ border: 0, width: 200, height: 133, style: imgStyles } | ||
> | ||
<@link href=url target="_blank" attrs={ style: imgLinkStyles, linklabel: linkLabel } /> | ||
</marko-newsletter-imgix> | ||
</marko-core-obj-value> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td align="left" valign="top" class="hide_on_mobile" style="display: none;mso-hide: all;"> | ||
<table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0" style="mso-hide: all;"> | ||
<common-table-spacer-element height="10" /> | ||
<tr> | ||
<td align="left" valign="top"> | ||
<a style="font-family: 'Roboto', arial, sans-serif;font-size: 17px;line-height: 23px;color: #202022;font-weight: 400;text-decoration: none;" href=url> | ||
$!{content.teaser} | ||
</a> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
</if> | ||
<common-table-spacer-element height="16" /> | ||
<common-table-hr-element height="2" /> | ||
<common-table-spacer-element height="16" /> | ||
</table> | ||
</td> | ||
</tr> |
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
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,41 @@ | ||
import fetch from "node-fetch"; | ||
|
||
$ const { log } = console; | ||
$ const { apiUrl, ctaLinkStyle } = input; | ||
|
||
$ const apiCall = async (url) => { | ||
if (url) { | ||
const response = await fetch(url); | ||
const jsonResponse = await response.json(); | ||
if (!response.ok) { | ||
log('Unsuccesssful external API response!', apiUrl, jsonResponse); | ||
return []; | ||
} | ||
return jsonResponse; | ||
} | ||
return []; | ||
}; | ||
<marko-web-resolve|{ resolved }| promise=apiCall(apiUrl)> | ||
$ const nodes = input.resolvedToNodesConverter({ resolved }) || resolved; | ||
<if(nodes && nodes.length)> | ||
$ const heroNode = nodes.slice(0, 1)[0]; | ||
$ const heroImageNode = { | ||
id: heroNode.id, | ||
type: heroNode.type, | ||
siteContext: heroNode.siteContext, | ||
primaryImage: heroNode.primaryImage, | ||
}; | ||
|
||
<for|heroNode| of=nodes> | ||
<table> | ||
<common-content-api-list-item-block | ||
content=heroNode | ||
with-image=true | ||
image-position="right" | ||
cta-link-style=ctaLinkStyle | ||
/> | ||
</table> | ||
</for> | ||
</if> | ||
</marko-web-resolve> |
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
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
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,57 @@ | ||
import { get } from "@parameter1/base-cms-object-path"; | ||
import { parseBooleanHeader } from "@parameter1/base-cms-utils"; | ||
import queryFragment from "@science-medicine-group/package-common/graphql/fragments/content-list"; | ||
import defaultValue from "@parameter1/base-cms-marko-core/utils/default-value"; | ||
|
||
$ const { website, config, req } = out.global; | ||
$ const { newsletter, date } = input.data; | ||
|
||
$ const emailX = config.get("emailX"); | ||
$ const nativeX = config.getAsObject("nativeX"); | ||
$ const { id, alias, name, pageNode } = input; | ||
|
||
$ const newsletterConfig = config.get(newsletter.alias); | ||
$ const ctaLinkStyle = defaultValue(newsletterConfig.ctaLinkStyle, undefined); | ||
|
||
$ const resolvedToNodesConverter = ({ resolved }) => (resolved.map((node) => ({ | ||
id: node.ID, | ||
type: 'Case', | ||
shortName: node.name, | ||
teaser: node.description, | ||
siteContext: { url: `https://my.drbicuspid.com/cases/${node.url}` }, | ||
primaryImage: { src: node.imagepath } | ||
}))); | ||
|
||
<marko-newsletter-root | ||
title=newsletter.name | ||
description=newsletter.description | ||
date=date | ||
> | ||
<@head> | ||
<common-head-block /> | ||
</@head> | ||
<@body style="padding:0; margin:0;font-family: 'Roboto', Arial, sans-serif; -webkit-text-size-adjust:100%;"> | ||
<common-body-wrapper-block newsletter=newsletter date=date> | ||
<@body> | ||
|
||
<common-ad-wrapper-block | ||
date=date | ||
newsletter=newsletter | ||
promotion-component="case-native-block" | ||
placement-id=get(nativeX, `placements.${newsletter.alias}.case-sponsor`) | ||
/> | ||
|
||
<common-external-api-block | ||
api-url="https://my.drbicuspid.com/wp-json/mo/v1/getCase/3" | ||
resolved-to-nodes-converter=resolvedToNodesConverter | ||
name="Case of the Week" | ||
description="Check out our Case of the Week!" | ||
button={ link: "https://my.drbicuspid.com/cases", text: "View All Cases" } | ||
native-x={ placementName: 'cases', placementAliases: ['cases'] } | ||
cta-link-style=ctaLinkStyle | ||
/> | ||
|
||
</@body> | ||
</common-body-wrapper-block> | ||
</@body> | ||
</marko-newsletter-root> |
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
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
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
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
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 @@ | ||
<common-case-layout data=data /> |