diff options
| author | Bertrand Yuan <189593334+bertyuan@users.noreply.github.com> | 2026-04-27 15:51:27 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-27 15:51:27 +0800 |
| commit | 658798b3a2378bb6df16cfbb16d707c6fb719e1e (patch) | |
| tree | 63fc32f5f7fda4bbf718f490e3b1640311dbf994 /src/lib | |
| parent | 8b9c0139a93c8b9d41068e5271d0fc6917d34fab (diff) | |
| parent | 2e7d98420900e1d6749729ea2a94c334e7d65754 (diff) | |
Merge pull request #19 from bertyuan/copilot/fix-front-backend-connection
fix: patch rough frontend-backend connection issues
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/resend.ts | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/lib/resend.ts b/src/lib/resend.ts index 5ab7032..fb39186 100644 --- a/src/lib/resend.ts +++ b/src/lib/resend.ts @@ -1,9 +1,10 @@ +import { env } from '@/env'; import { baseUrl } from '@/lib/constants'; import { Resend, type UpdateContactOptions } from 'resend'; import NewsletterWelcomeEmail from '../../emails/newsletter-welcome'; -import type { getPosts } from './source'; +import type { BlogPost } from './payload-posts'; -const resend = new Resend(process.env.RESEND_API_KEY as string); +const resend = new Resend(env.RESEND_API_KEY); export async function updateContact({ email, @@ -53,18 +54,21 @@ export async function sendWelcomeEmail({ firstName, to, }: { - posts: ReturnType<typeof getPosts>; + posts: BlogPost[]; firstName: string; to: string; }) { - const EMAIL_FROM = process.env.EMAIL_FROM as string; - if (!EMAIL_FROM) throw new Error('Missing EMAIL_FROM environment variable'); + const EMAIL_FROM = env.EMAIL_FROM; if (!firstName || !to) throw new Error('Missing required email fields'); const formattedPosts = posts.map((post) => ({ - ...post.data, - image: `${baseUrl}${post.data.image}`, - url: `${baseUrl}${post.url}`, + title: post.title, + description: post.description, + date: post.date, + tags: post.tags, + image: post.image ? new URL(post.image, baseUrl).href : undefined, + author: post.author, + url: new URL(post.url, baseUrl).href, })); const { data: res, error } = await resend.emails.send({ |
