Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept URL instead of path for WATcloud blog update email #15

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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