Skip to content

Commit

Permalink
Accept URL instead of path for WATcloud blog update email
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-z committed Oct 13, 2024
1 parent 38e060f commit 79941c5
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions emails/blog-update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getAsset, registerAsset, WATcloudURI } from "../utils/watcloud-uri";
import { WATcloudEmail } from "./_common/watcloud-email";

const WATcloudBlogUpdateEmailProps = z.object({
path: z.string(),
url: z.string().url(),
title: z.string(),
author: z.string(),
date: z.string(),
Expand All @@ -26,39 +26,37 @@ export function init({ image }: WATcloudBlogUpdateEmailProps) {
}

export function WATcloudBlogUpdateEmail(props: WATcloudBlogUpdateEmailProps) {
const { path, title, author, date, abstract, image } = WATcloudBlogUpdateEmailProps.parse(props);
const { url, title, author, date, abstract, image } = WATcloudBlogUpdateEmailProps.parse(props);

if (process.env.NODE_ENV === "development") {
init(props);
}

const previewText = `New WATcloud Blog Post: ${title}`;

const link = `https://cloud.watonomous.ca/blog/${path}`;

const imageSrc = getAsset(image).resolveFromCache();

return (
<WATcloudEmail previewText={previewText}>
<Text>Hello! WATcloud has published a new blog post.</Text>
<Hr style={{ marginTop: "20px", marginBottom: "20px" }} />
<Img src={imageSrc} alt={title} height="200" />
<Link href={link}>
<Link href={url}>
<Heading as="h2" style={{ marginBottom: 0 }}>{title}</Heading>
</Link>
<Text style={{ marginTop: 0 }}>
By {author} on {date}
</Text>
<Markdown markdownContainerStyles={{ color: "#333", fontSize: "14px", lineHeight: "24px" }}>{abstract}</Markdown>
<Link href={link}>Read more →</Link>
<Link href={url}>Read more →</Link>
<Hr style={{ marginTop: "20px", marginBottom: "20px" }} />
<Text style={{ color: "#666", fontSize: "12px" }}>You are receiving this email because you are subscribed to the WATcloud blog.</Text>
</WATcloudEmail>
);
};

WATcloudBlogUpdateEmail.PreviewProps = {
path: "what-is-watcloud",
url: "https://cloud.watonomous.ca/blog/what-is-watcloud",
title: "Under the Hood: What is WATcloud?",
author: "Ben Zhang",
date: "Sunday, September 22, 2024",
Expand Down

0 comments on commit 79941c5

Please sign in to comment.