Skip to content

Commit

Permalink
chore: add release-it
Browse files Browse the repository at this point in the history
  • Loading branch information
multivoltage committed Apr 12, 2023
1 parent d814798 commit 798b61d
Show file tree
Hide file tree
Showing 3 changed files with 4,259 additions and 169 deletions.
66 changes: 41 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Intro

Emails are hard to develop. there is some awesome libs that makes the development more easy. But each library allow us to do a single thing without focus on a full development flow. This project wants to mix up MJML, a template enigne for variables/logic and a web server.

## 🚀 Usage
Expand All @@ -8,27 +9,32 @@ Emails are hard to develop. there is some awesome libs that makes the developmen
```sh
npm i marilena
```

### How to use it

1 - create a `marilena.config.js` file under root of your project:

```js
// this is an example of config structure
module.exports = {
templateSuffix: ".html",
inputFolder: "input",
outputFolder: "output",
locales: ["en","it"],
templateOptions: {
engine: "eta",
variablesType: "json",
prepareEngine: (xxx) => {
// engine eta => xxx = eta
// engine handlebars => xxx = handlebars
// read below about this part
},
},
templateSuffix: ".html",
inputFolder: "input",
outputFolder: "output",
locales: ["en", "it"],
templateOptions: {
engine: "eta",
variablesType: "json",
prepareEngine: (xxx) => {
// engine eta => xxx = eta
// engine handlebars => xxx = handlebars
// read below about this part
},
},
};
```

2 - create a file structures based on your config. PLease remember that each email template requires `index` as name, and variables are loaded only from `variables.json`

```
project
| marilena.config.js
Expand All @@ -41,7 +47,9 @@ project
││││││└─── it
│││││││││││└── variables.json
```

3 - fill your emails template with MJML syntax

```html
<mjml>
<mj-body>
Expand All @@ -53,35 +61,41 @@ project
</mj-section>
</mj-body>
</mjml>

```

4 - run one of these 2 commands

```sh
# open a server on http://localhost:8080
npm run start
```

```sh
# build all emails based on config (template engine, output folder, and locales)
npm run build
```

---

## Configuration

Under the hood a default configuration will be loaded but a file `marilena.config.js` allow us to set:
| name | required | description | default |
| name | required | description | default |
|-----------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
| templateSuffix | X | extension of files used for email. Used for filter and can any value | .html |
| inputFolder | X | folder where email are in the project | input |
| outputFolder | X | folder used for generated email (when run build command) | output |
| locales | X | array of languages used. If you company has only spanish email use an array of single value | ["en"] |
| templateOptions | | if you chose to use one of supported engines, this part id required to setup custom partial and other settings for the template engine selected. Read below for some use cases | empty |

| templateSuffix | X | extension of files used for email. Used for filter and can any value | .html |
| inputFolder | X | folder where email are in the project | input |
| outputFolder | X | folder used for generated email (when run build command) | output |
| locales | X | array of languages used. If you company has only spanish email use an array of single value | ["en"] |
| templateOptions | | if you chose to use one of supported engines, this part id required to setup custom partial and other settings for the template engine selected. Read below for some use cases | empty |

## About templateOptions

This project can producte output html from input template. But in a real word probably we store variables in some part and render some content multiple times (example a footer). In this case `templateOptions` can define:
- `engine`: a subset of fastify supported template engine. At this moment `["eta","handlebars"]` are supported.

- `engine`: a subset of fastify supported template engine. At this moment `["eta","handlebars"]` are supported. Apart `eta`, which is used also in the project library, all others require and installation of the engine since `marilena` use lazy import for engines.
- `variablesType`: define if variables are loaded from json file or yaml file. At this moment only `json` are supported.
- `prepareEngine`: define a callback where we can setup our engine. Basically you can define all things before the render. For example:

```js
templateOptions: {
engine: "eta",
Expand All @@ -93,6 +107,7 @@ This project can producte output html from input template. But in a real word pr
},
},
```

```js
templateOptions: {
engine: "handlebars",
Expand All @@ -104,17 +119,18 @@ This project can producte output html from input template. But in a real word pr
},
},
```

---

## 🚀 features
## 🚀 features

- [x] MJML support
- [x] load variables with template engine
- [x] eta.js, handlebars
- [ ] ejs, nunjucks, mustache, dot, liquid
- [ ] ejs, nunjucks, mustache, dot, liquid
- [x] fast-refresh on variables changes
- [x] fast-refresh on template change
- [ ] fast-refresh on config change
- [ ] load varibles from yaml format
- [ ] load common variables
- [ ] easy way to send a real email

0 comments on commit 798b61d

Please sign in to comment.