You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> 🚧 **This SDK is not stable yet.** The API might change as more features are added. Please pay attention to the [CHANGELOG](CHANGELOG.md) for breaking changes.
93
+
There are more C# examples in the [examples](examples) folder ✨
94
+
95
+
> [!NOTE]
96
+
> 🚧 **The SDK is not stable yet.** This API might change as more features are added. Please watch the repo for the changes in the [CHANGELOG](CHANGELOG.md).
97
+
98
+
## 🔳 Components
99
+
100
+
Emails are crafted programmatically by making function calls. There's no dealing with HTML or drag-and-drop builders.
101
+
102
+
All of the following components can be mixed and matched to create dynamic emails:
81
103
82
-
Examples:
104
+
<details>
105
+
<summary>Text / Markdown</summary>
83
106
84
-
1. Get your **free API key** here: <https://app.templateless.com> ✨
85
-
1. There are more JavaScript examples in the [examples](examples) folder
107
+
Text component allow you to insert a paragraph. Each paragraph supports basic markdown:
86
108
87
-
```bash
88
-
TEMPLATELESS_API_KEY=<Your API Key> \
89
-
TEMPLATELESS_EMAIL_ADDRESS=<Your Own Email Address> \
90
-
node examples/simple
109
+
- Bold text: `**bold text**`
110
+
- Italic text: `_italic text_`
111
+
- Link: `[link text](https://example.com)`
112
+
- Also a link: `<https://example.com>`
113
+
- Headers (h1-h6):
114
+
115
+
-`# Big Header`
116
+
-`###### Small Header`
117
+
118
+
- Unordered list:
119
+
120
+
```md
121
+
- item one
122
+
- item two
123
+
- item three
91
124
```
92
125
126
+
- Ordered list:
127
+
128
+
```md
129
+
1. item one
130
+
1. item two
131
+
1. item three
132
+
```
133
+
134
+
```javascript
135
+
Content.builder()
136
+
.text("## Thank you for signing up")
137
+
.text("Please **verify your email** by [clicking here](https://example.com/confirm?token=XYZ)")
138
+
.build()
139
+
```
140
+
141
+
</details>
142
+
<details><summary>Link</summary>
143
+
144
+
Link component adds an anchor tag. This is the same as a text component with the link written in markdown:
Image component will link to an image within your email. Keep in mind that a lot of email clients will prevent images from being loaded automatically for privacy reasons.
168
+
169
+
```javascript
170
+
Content.builder()
171
+
.image(
172
+
"https://placekitten.com/300/200", // where the image is hosted
173
+
"https://example.com", // [optional] link url, if you want it to be clickable
174
+
300, // [optional] width
175
+
200, // [optional] height
176
+
"Alt text"// [optional] alternate text
177
+
)
178
+
.build()
179
+
```
180
+
181
+
Only the `src` parameter is required; everything else is optional.
182
+
183
+
**If you have "Image Optimization" turned on:**
184
+
185
+
1. Your images will be cached and distributed by our CDN for faster loading. The cache does not expire. If you'd like to re-cache, simply append a query parameter to the end of your image url.
186
+
1. Images will be converted into formats that are widely supported by email clients. The following image formats will be processed automatically:
187
+
188
+
- Jpeg
189
+
- Png
190
+
- Gif
191
+
- WebP
192
+
- Tiff
193
+
- Ico
194
+
- Bmp
195
+
- Svg
196
+
197
+
1. Maximum image size is 5MB for free accounts and 20MB for paid accounts.
198
+
1. You can specify `width` and/or `height` if you'd like (they are optional). Keep in mind that images will be scaled down to fit within the email theme, if they're too large.
199
+
200
+
</details>
201
+
<details><summary>One-Time Password</summary>
202
+
203
+
OTP component is designed for showing temporary passwords and reset codes.
204
+
205
+
```javascript
206
+
Content.builder()
207
+
.text("Here's your **temporary login code**:")
208
+
.otp("XY78-2BT0-YFNB-ALW9")
209
+
.build()
210
+
```
211
+
212
+
</details>
213
+
<details><summary>Social Icons</summary>
214
+
215
+
You can easily add social icons with links by simply specifying the username. Usually, this component is placed in the footer of the email.
newSocialItem(Service.Phone, '123-456-7890'), // `tel:` link
225
+
newSocialItem(Service.Facebook, 'ExampleApp'),
226
+
newSocialItem(Service.YouTube, 'ChannelID'),
227
+
newSocialItem(Service.Twitter, 'ExampleApp'),
228
+
newSocialItem(Service.X, 'ExampleApp'),
229
+
newSocialItem(Service.GitHub, 'ExampleApp'),
230
+
newSocialItem(Service.Instagram, 'ExampleApp'),
231
+
newSocialItem(Service.LinkedIn, 'ExampleApp'),
232
+
newSocialItem(Service.Slack, 'Org'),
233
+
newSocialItem(Service.Discord, 'ExampleApp'),
234
+
newSocialItem(Service.TikTok, 'ExampleApp'),
235
+
newSocialItem(Service.Snapchat, 'ExampleApp'),
236
+
newSocialItem(Service.Threads, 'ExampleApp'),
237
+
newSocialItem(Service.Telegram, 'ExampleApp'),
238
+
])
239
+
.build()
240
+
```
241
+
242
+
</details>
243
+
<details><summary>View in Browser</summary>
244
+
245
+
If you'd like your recipients to be able to read the email in a browser, you can add the "view in browser" component that will automatically generate a link. Usually, this is placed in the header or footer of the email.
246
+
247
+
You can optionally provide the text for the link. If none is provided, default is used: "View in browser"
248
+
249
+
**This will make the email public to anyone that has access to the link.**
250
+
251
+
```javascript
252
+
Content.builder()
253
+
.viewInBrowser("Read Email in Browser")
254
+
.build()
255
+
```
256
+
257
+
</details>
258
+
259
+
---
260
+
261
+
Components can be placed in the header, body and footer of the email. Header and footer styling is usually a bit different from the body (for example the text is smaller).
262
+
263
+
```javascript
264
+
constheader=Header.builder() // header of the email
265
+
.text("Smaller text")
266
+
.build()
267
+
268
+
constcontent=Content.builder() // body of the email
269
+
.text("Normal text")
270
+
.build()
271
+
```
272
+
273
+
Currently there are 2 themes to choose from: `Theme.Unstyled` and `Theme.Simple`
274
+
275
+
```javascript
276
+
constcontent=Content.builder()
277
+
.theme(Theme.Simple)
278
+
.text("Hello world")
279
+
.build()
280
+
```
281
+
93
282
## 🤝 Contributing
94
283
95
-
- Contributions are more than welcome <3
96
-
- Please **star this repo** for more visibility ★
284
+
- Contributions are more than welcome
285
+
- Please **star this repo** for more visibility <3
97
286
98
287
## 📫 Get in touch
99
288
@@ -103,7 +292,7 @@ Examples:
103
292
104
293
- For feature requests, please [start a discussion](https://github.com/templateless/templateless-javascript/discussions)
105
294
- Found a bug? [Open an issue!](https://github.com/templateless/templateless-javascript/issues)
106
-
-We are also on Twitter: [@Templateless](https://twitter.com/templateless)
295
+
-Say hi [@Templateless](https://twitter.com/templateless) 👋
0 commit comments