Skip to content

Commit 97686a7

Browse files
committed
Support custom previews
And ensure when these previews are used that no email body is appended
1 parent 17a4b92 commit 97686a7

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/core/email/templates/base.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,43 @@ import {
1010
Image,
1111
InText,
1212
Mjml,
13+
Preview,
1314
Raw,
1415
Section,
1516
Style,
1617
Text,
1718
Title,
1819
Wrapper,
1920
} from '@seedcompany/nestjs-email/templates';
20-
import type { ComponentProps, ReactElement, ReactNode } from 'react';
21+
import {
22+
type ComponentProps,
23+
Fragment,
24+
type ReactElement,
25+
type ReactNode,
26+
} from 'react';
2127
import { useFrontendUrl } from './frontend-url';
2228

2329
export const EmailTemplate = ({
2430
title,
31+
preview,
2532
children,
2633
}: {
2734
title: string;
35+
preview?: ReactNode;
2836
children: ReactNode;
2937
}) => (
3038
<Mjml lang="en">
3139
<Head>
3240
<Title>{`${title} - CORD Field`}</Title>
41+
{preview != null && (
42+
<Preview>
43+
{preview}
44+
{/* Fill the remaining space with nothing-ness so the email context is avoided */}
45+
{[...Array(140).keys()].map((i) => (
46+
<Fragment key={i}>&#847;&zwnj;&nbsp;</Fragment>
47+
))}
48+
</Preview>
49+
)}
3350
<Theme />
3451
<Style
3552
inline

0 commit comments

Comments
 (0)