payload-plugin-newsletter 0.14.1 → 0.14.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## [0.14.2] - 2025-07-22
2
+
3
+ ### Added
4
+ - Custom email template support for transactional emails (magic link, welcome, sign-in)
5
+ - Configure via `customTemplates` in plugin config
6
+ - Full React Email component support
7
+ - Fallback to built-in templates when custom ones not provided
8
+ - Comprehensive email template documentation
9
+ - Guide for creating custom broadcast templates
10
+ - Guide for creating custom transactional templates
11
+ - Examples and best practices for template development
12
+ - Extension patterns for advanced use cases
13
+
14
+ ### Fixed
15
+ - Custom templates now properly used when configured in plugin settings
16
+ - All email rendering functions now accept config parameter for template customization
17
+
1
18
  ## [0.14.1] - 2025-07-22
2
19
 
3
20
  ### Changed
package/dist/index.cjs CHANGED
@@ -792,8 +792,15 @@ var SignInEmail = (props) => {
792
792
 
793
793
  // src/emails/render.tsx
794
794
  var import_jsx_runtime4 = require("react/jsx-runtime");
795
- async function renderEmail(template, data) {
795
+ async function renderEmail(template, data, config) {
796
796
  try {
797
+ if (config?.customTemplates) {
798
+ const customTemplate = config.customTemplates[template];
799
+ if (customTemplate) {
800
+ const CustomComponent = customTemplate;
801
+ return (0, import_render.render)(/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CustomComponent, { ...data }));
802
+ }
803
+ }
797
804
  switch (template) {
798
805
  case "magic-link": {
799
806
  const magicLinkData = data;
@@ -1071,7 +1078,7 @@ var createSubscribersCollection = (pluginConfig) => {
1071
1078
  siteName: settings?.brandSettings?.siteName || "Newsletter",
1072
1079
  preferencesUrl: `${serverURL}/account/preferences`
1073
1080
  // This could be customized
1074
- });
1081
+ }, pluginConfig);
1075
1082
  await emailService.send({
1076
1083
  to: doc.email,
1077
1084
  subject: settings?.brandSettings?.siteName ? `Welcome to ${settings.brandSettings.siteName}!` : "Welcome!",
@@ -2097,7 +2104,7 @@ var createSubscribeEndpoint = (config) => {
2097
2104
  email: updated.email,
2098
2105
  siteName: settings2?.brandSettings?.siteName || "Newsletter",
2099
2106
  siteUrl: req.payload.config.serverURL || ""
2100
- });
2107
+ }, config);
2101
2108
  await emailService.send({
2102
2109
  to: updated.email,
2103
2110
  subject: `Welcome back to ${settings2?.brandSettings?.siteName || "our newsletter"}!`,
@@ -2133,7 +2140,7 @@ var createSubscribeEndpoint = (config) => {
2133
2140
  email: subscriber2.email,
2134
2141
  siteName: settings2?.brandSettings?.siteName || "Newsletter",
2135
2142
  expiresIn: config.auth?.tokenExpiration || "7d"
2136
- });
2143
+ }, config);
2137
2144
  await emailService.send({
2138
2145
  to: subscriber2.email,
2139
2146
  subject: `Sign in to ${settings2?.brandSettings?.siteName || "your account"}`,
@@ -2221,7 +2228,7 @@ var createSubscribeEndpoint = (config) => {
2221
2228
  email: subscriber.email,
2222
2229
  siteName: settings?.brandSettings?.siteName || "Newsletter",
2223
2230
  expiresIn: config.auth?.tokenExpiration || "7d"
2224
- });
2231
+ }, config);
2225
2232
  await emailService.send({
2226
2233
  to: subscriber.email,
2227
2234
  subject: settings?.brandSettings?.siteName ? `Verify your email for ${settings.brandSettings.siteName}` : "Verify your email",
@@ -2345,7 +2352,7 @@ var createVerifyMagicLinkEndpoint = (config) => {
2345
2352
  siteName: settings?.brandSettings?.siteName || "Newsletter",
2346
2353
  preferencesUrl: `${serverURL}/account/preferences`
2347
2354
  // This could be customized
2348
- });
2355
+ }, config);
2349
2356
  await emailService.send({
2350
2357
  to: subscriber.email,
2351
2358
  subject: settings?.brandSettings?.siteName ? `Welcome to ${settings.brandSettings.siteName}!` : "Welcome!",
@@ -2730,7 +2737,7 @@ var createSigninEndpoint = (config) => {
2730
2737
  email: subscriber.email,
2731
2738
  siteName: settings?.brandSettings?.siteName || "Newsletter",
2732
2739
  expiresIn: config.auth?.tokenExpiration || "7d"
2733
- });
2740
+ }, config);
2734
2741
  await emailService.send({
2735
2742
  to: subscriber.email,
2736
2743
  subject: settings?.brandSettings?.siteName ? `Sign in to ${settings.brandSettings.siteName}` : "Sign in to your account",