-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add email template for blog update (#10)
This PR creates an email template for blog updates. <img width="613" alt="image" src="https://github.com/user-attachments/assets/3ac49628-2e58-4af9-a738-e8a4bc337f7d">
- Loading branch information
Showing
5 changed files
with
105 additions
and
13 deletions.
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
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,77 @@ | ||
import { | ||
Body, | ||
Container, | ||
Head, | ||
Heading, | ||
Hr, | ||
Html, | ||
Img, | ||
Link, | ||
Preview, | ||
Section, | ||
Text | ||
} from "@react-email/components"; | ||
import dedent from "dedent-js"; | ||
import { z } from "zod"; | ||
import { WATcloudEmail } from "./_common/watcloud-email"; | ||
import { getAsset, registerAsset, WATcloudURI } from "../utils/watcloud-uri"; | ||
|
||
const WATcloudBlogUpdateEmailProps = z.object({ | ||
path: z.string(), | ||
title: z.string(), | ||
author: z.string(), | ||
date: z.string(), | ||
abstract: z.string(), | ||
image: z.string(), | ||
}); | ||
|
||
type WATcloudBlogUpdateEmailProps = z.infer<typeof WATcloudBlogUpdateEmailProps>; | ||
|
||
export function init({ image }: WATcloudBlogUpdateEmailProps) { | ||
registerAsset(image, new WATcloudURI(image)); | ||
} | ||
|
||
export function WATcloudBlogUpdateEmail(props: WATcloudBlogUpdateEmailProps) { | ||
const { path, 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}> | ||
<Heading as="h2" style={{ marginBottom: 0 }}>{title}</Heading> | ||
</Link> | ||
<Text style={{ color: "#333", marginTop: 0 }}> | ||
By {author} on {date} | ||
</Text> | ||
<Text style={{ color: "#333" }}> | ||
{abstract} | ||
</Text> | ||
<Link href={link}>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", | ||
title: "Under the Hood: What is WATcloud?", | ||
author: "Ben Zhang", | ||
date: "Sunday, September 22, 2024", | ||
abstract: "Curious about how WATcloud makes computing resources easily and fairly accessible to everyone? Join us as we kick off a blog series exploring our four-year journey of refining our compute cluster's hardware and software—from servers and networking to user provisioning and observability systems.", | ||
image: "watcloud://v1/sha256:5cc9868176110e693921b642ef69b43ea1d6728c822d824bb405e1fc1631b345?name=under-the-hood-wide.png", | ||
} as WATcloudBlogUpdateEmailProps; | ||
|
||
export default WATcloudBlogUpdateEmail; |
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