I write our newsletters in Google Docs which exports nicely to Markdown.
Inspired by Josh W Comeau, I wanted a way to write in Markdown and generate both a blog post and an email.
This repository generates emails from .mdx files.
- Takes an
.mdxfile as input. - References a library of components, sections and snippets.
- Renders
.mjmland.htmlfiles.
Difference between each type of element:
- Component: low-level building block, like
<p>. - Section: MJML is divided into "sections". These elements support the creation of different section layouts.
- Snippet: A pre-designed "snippet" that makes use of several components.
mdx-to-email.walkthrough.v2.mp4
Install Bun with their install script.
Install dependencies:
bun install
Run it:
bun main.js inputs/name-of-input-file.mdx
- Refactor away from one large
main.jsfile. - Support different themes/brands. This might be as simple as including different
.cssfiles but the inlining doesn't seem to work as fully as I'd like yet. - Automatically detect which components have an
MjmlSectioncomponent as these need to be handled differently during rendering.
MIT license.