@m13v/seo-components 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/newsletter-route.ts +45 -12
package/package.json
CHANGED
|
@@ -4,7 +4,41 @@ import { NextRequest } from "next/server";
|
|
|
4
4
|
/* Default welcome email template (light theme, teal brand) */
|
|
5
5
|
/* ------------------------------------------------------------------ */
|
|
6
6
|
|
|
7
|
-
function defaultWelcomeEmailHtml(
|
|
7
|
+
function defaultWelcomeEmailHtml(
|
|
8
|
+
brand: string,
|
|
9
|
+
siteUrl: string,
|
|
10
|
+
bookingUrl?: string,
|
|
11
|
+
): string {
|
|
12
|
+
const bookingBlock = bookingUrl
|
|
13
|
+
? `
|
|
14
|
+
<!-- Booking CTA (primary) -->
|
|
15
|
+
<tr>
|
|
16
|
+
<td style="padding:0 32px 12px;">
|
|
17
|
+
<a href="${bookingUrl}" style="display:inline-block;padding:12px 24px;background-color:#14b8a6;color:#ffffff;font-size:15px;font-weight:600;text-decoration:none;border-radius:10px;">
|
|
18
|
+
Book a 15-min call
|
|
19
|
+
</a>
|
|
20
|
+
</td>
|
|
21
|
+
</tr>
|
|
22
|
+
<!-- Visit CTA (secondary) -->
|
|
23
|
+
<tr>
|
|
24
|
+
<td style="padding:0 32px 32px;color:#64748b;font-size:14px;line-height:1.6;">
|
|
25
|
+
Or <a href="${siteUrl}" style="color:#14b8a6;text-decoration:none;font-weight:600;">visit ${brand}</a> to read the latest.
|
|
26
|
+
</td>
|
|
27
|
+
</tr>`
|
|
28
|
+
: `
|
|
29
|
+
<!-- CTA Button -->
|
|
30
|
+
<tr>
|
|
31
|
+
<td style="padding:0 32px 32px;">
|
|
32
|
+
<a href="${siteUrl}" style="display:inline-block;padding:12px 24px;background-color:#14b8a6;color:#ffffff;font-size:15px;font-weight:600;text-decoration:none;border-radius:10px;">
|
|
33
|
+
Visit ${brand}
|
|
34
|
+
</a>
|
|
35
|
+
</td>
|
|
36
|
+
</tr>`;
|
|
37
|
+
|
|
38
|
+
const bodyCopy = bookingUrl
|
|
39
|
+
? `Thanks for subscribing! You'll receive our latest guides, tips, and updates straight to your inbox. If you want to talk shop, grab a time below.`
|
|
40
|
+
: `Thanks for subscribing! You'll receive our latest guides, tips, and updates straight to your inbox.`;
|
|
41
|
+
|
|
8
42
|
return `<!DOCTYPE html>
|
|
9
43
|
<html>
|
|
10
44
|
<head>
|
|
@@ -37,17 +71,9 @@ function defaultWelcomeEmailHtml(brand: string, siteUrl: string): string {
|
|
|
37
71
|
<!-- Body -->
|
|
38
72
|
<tr>
|
|
39
73
|
<td style="padding:0 32px 24px;color:#475569;font-size:15px;line-height:1.6;">
|
|
40
|
-
|
|
74
|
+
${bodyCopy}
|
|
41
75
|
</td>
|
|
42
|
-
</tr
|
|
43
|
-
<!-- CTA Button -->
|
|
44
|
-
<tr>
|
|
45
|
-
<td style="padding:0 32px 32px;">
|
|
46
|
-
<a href="${siteUrl}" style="display:inline-block;padding:12px 24px;background-color:#14b8a6;color:#ffffff;font-size:15px;font-weight:600;text-decoration:none;border-radius:10px;">
|
|
47
|
-
Visit ${brand}
|
|
48
|
-
</a>
|
|
49
|
-
</td>
|
|
50
|
-
</tr>
|
|
76
|
+
</tr>${bookingBlock}
|
|
51
77
|
<!-- Footer -->
|
|
52
78
|
<tr>
|
|
53
79
|
<td style="border-top:1px solid #e2e8f0;padding:20px 32px;color:#94a3b8;font-size:13px;line-height:1.5;">
|
|
@@ -75,6 +101,12 @@ export interface NewsletterConfig {
|
|
|
75
101
|
brand: string;
|
|
76
102
|
/** Site URL used in the default email template CTA link */
|
|
77
103
|
siteUrl: string;
|
|
104
|
+
/**
|
|
105
|
+
* Optional per-client booking URL (e.g. "https://cal.com/team/mediar/<slug>").
|
|
106
|
+
* When set, the default welcome template shows "Book a 15-min call" as the
|
|
107
|
+
* primary CTA. Consumers typically pass `BOOKING_URL` from `@/lib/booking`.
|
|
108
|
+
*/
|
|
109
|
+
bookingUrl?: string;
|
|
78
110
|
/** Env var name for the Resend API key (default: "RESEND_API_KEY") */
|
|
79
111
|
apiKeyEnv?: string;
|
|
80
112
|
/** Override the welcome email subject line */
|
|
@@ -102,6 +134,7 @@ export function createNewsletterHandler(config: NewsletterConfig) {
|
|
|
102
134
|
fromEmail,
|
|
103
135
|
brand,
|
|
104
136
|
siteUrl,
|
|
137
|
+
bookingUrl,
|
|
105
138
|
apiKeyEnv = "RESEND_API_KEY",
|
|
106
139
|
welcomeSubject,
|
|
107
140
|
welcomeHtml,
|
|
@@ -166,7 +199,7 @@ export function createNewsletterHandler(config: NewsletterConfig) {
|
|
|
166
199
|
const subject = welcomeSubject || `Welcome to ${brand}`;
|
|
167
200
|
const html = welcomeHtml
|
|
168
201
|
? welcomeHtml(email)
|
|
169
|
-
: defaultWelcomeEmailHtml(brand, siteUrl);
|
|
202
|
+
: defaultWelcomeEmailHtml(brand, siteUrl, bookingUrl);
|
|
170
203
|
|
|
171
204
|
let resendEmailId: string | null = null;
|
|
172
205
|
|