Skip to content

Commit 4a4986b

Browse files
committed
feat(docs): Section for PreviewProps
1 parent 24a9f54 commit 4a4986b

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

apps/docs/cli.mdx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ icon: 'square-terminal'
1010

1111
Starts a local development server that will watch your files and automatically rebuild your email when you make changes.
1212

13-
### Where can I place my static files for previewing
13+
### Where can I place my static files for previewing?
1414

1515
Almost always you will need to have static files in your emails, and seeing
1616
them on the preview server without having to first host on a CDN is very helpful.
@@ -60,7 +60,29 @@ export default Email(props) {
6060

6161
You can refer to our [demo emails source code](https://demo.react.email/preview/vercel-invite-user.tsx?view=source) for an example of how we do this.
6262

63-
### How to make the preview server ignore directories
63+
### How can I define props specific to the email's preview?
64+
65+
Considering that you are already default exporting the React component
66+
that will render as your email template, you can just define a `PreviewProps` with it as follows:
67+
68+
```jsx
69+
export default Email(props) {
70+
return (
71+
<div>
72+
<a src={props.source}>click here if you want candy 👀</a>
73+
</div>
74+
)
75+
}
76+
77+
Email.PreviewProps = {
78+
source: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
79+
}
80+
```
81+
82+
And then when opening this email's preview the `PreviewProps`
83+
will be used as props into Email.
84+
85+
### How to make the preview server ignore directories?
6486

6587
Once the preview server has started and is now open on `localhost`, the preview server
6688
reads recursively down into all of your files and directories. This can be disabled

0 commit comments

Comments
 (0)