Create static email templates using the power of Astro. And the convenience of SolidJs
I was using a custom static email builder based on react which hacked react server components renderer to generate html file. It was fine but with astro I was able to replicate the functionality with minimal changes. Astro support features like file based routing, in-line styles, a vite based build system and at the end generates a clean html code.
- Node v18 (or higher)
- pnpm
- Basic knowledge of SolidJs.
- Basic knowledge of Astro. (it's not that complicated)
- Basic knowledge of making an email templates.
pnpm install- (Optional) copy
.env.exampleas.envand change the parameters pnpm devto start creating email templatespnpm buildto render email templates. they are stored indistfolder
Each email template is treated as a route and placed in src/pages directory. (checkout src/pages/emailer-one.astro)
Reusable components are placed (not mandatory) in src/components directory. (checkout src/components/H1.astro)
Reusable layouts are placed (not mandatory) in src/layouts directory. (checkout src/layouts/DefaultLayout.astro)
Images are placed in public/email directory
rendered email templates are stored in dist folder
A fully type checked function to pass inline css.
The project can be configured accordingly using .env file. copy .env.example as .env
Set the email template file extension. By default it's html
Enable/disable Html compression. By default it's FALSE, set TRUE to enable compression.
dynamic local path agreeing public email public/email/ folder. it's left blank by default