Repository navigation
Replies: 1 comment
|
Yeah, the Rough shape: import { render } from "react-email";
import fs from "node:fs/promises";
import path from "node:path";
import Welcome from "./emails/welcome";
import Receipt from "./emails/receipt";
const locales = ["en", "de", "fr"];
const emails = { welcome: Welcome, receipt: Receipt };
for (const locale of locales) {
for (const [name, Email] of Object.entries(emails)) {
const html = await render(<Email locale={locale} />);
const dir = path.join("out", locale);
await fs.mkdir(dir, { recursive: true });
await fs.writeFile(path.join(dir, `${name}.html`), html);
}
}Note The one thing to get right is how the locale reaches your components. If your emails take a |
Uh oh!
There was an error while loading. Please reload this page.
I found out that
exportcli command doesn't support locale specification. Unfortunately I got that too late, when all emails and their translations already implemented. Rendered emails will be used in non-js environment, so I cannot render them in runtime.How I can render all the emails on each available localization?
All reactions