@maily-to/render 2.0.0-beta.6 → 2.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/readme.md CHANGED
@@ -1,12 +1,7 @@
1
- <div align="center"><img height="150" src="https://maily.to/brand/icon.svg" /></div>
2
- <br>
3
-
4
- <div align="center"><strong>@maily-to/render</strong></div>
5
- <div align="center">Transform <a href="https://maily.to">Maily</a> content into HTML email templates.</div>
6
- <br />
1
+ [![@maily-to/render](../../_static/render.jpg)](https://maily.to)
7
2
 
8
3
  <p align="center">
9
- <a href="https://github.com/arikchakma/maily.to/blob/main/license">
4
+ <a href="https://github.com/arikchakma/maily.to/blob/main/LICENSE">
10
5
  <img src="https://img.shields.io/badge/License-MIT-222222.svg" />
11
6
  </a>
12
7
  <a href="https://buymeacoffee.com/arikchakma">
@@ -49,9 +44,40 @@ const html = await render({
49
44
  });
50
45
  ```
51
46
 
47
+ A document is normalised into a body and a container before it renders, so a
48
+ bare list of blocks and a full `doc > body > container` tree both produce the
49
+ same email.
50
+
51
+ #### Plain text
52
+
53
+ `renderText` walks the same document and returns the plain-text part of a
54
+ multipart email.
55
+
56
+ ```ts
57
+ import { renderText } from '@maily-to/render';
58
+
59
+ const text = await renderText(doc);
60
+ ```
61
+
62
+ #### Styling
63
+
64
+ The renderer applies no theme of its own. Every colour, spacing, and font comes
65
+ from the `style` attribute the document carries, so the email matches what the
66
+ editor showed. Pass `theme` only to render a document that has none of its own.
67
+
68
+ ```ts
69
+ import { BASIC_NODE_THEME } from '@maily-to/shared';
70
+
71
+ const html = await render(doc, { theme: BASIC_NODE_THEME });
72
+ ```
73
+
74
+ The `<head>` carries an `@font-face` rule for every family the document's style
75
+ attributes name. Add `fontFamilies` to describe a web font the document uses.
76
+
52
77
  #### Variables
53
78
 
54
- All user-provided data lives under a single `variables` key — string substitution, visibility checks, repeat arrays, and link overrides.
79
+ All user-provided data lives under a single `variables` key — string
80
+ substitution, visibility checks, repeat arrays, and link overrides.
55
81
 
56
82
  ```ts
57
83
  import { render } from '@maily-to/render';
@@ -72,6 +98,19 @@ Variable resolution follows a 3-stage priority chain:
72
98
  2. `variables` — the map above
73
99
  3. `variableFormatter` — fallback that produces a placeholder string
74
100
 
101
+ #### Config
102
+
103
+ | Option | Description |
104
+ | ------------------- | ------------------------------------------------------- |
105
+ | `variables` | The data map described above |
106
+ | `variableFormatter` | Fallback for a variable the map does not resolve |
107
+ | `theme` | `NodeThemeOptions` for a document that carries no theme |
108
+ | `preview` | Preview text, as a string or as Maily JSON |
109
+ | `fontFamilies` | Web fonts to declare in the head |
110
+ | `meta` | Extra `<meta>` descriptors |
111
+ | `htmlProps` | Attributes for the root `<html>` element |
112
+ | `openTrackingPixel` | URL of a tracking pixel to append |
113
+
75
114
  ### Contributions
76
115
 
77
116
  Feel free to submit pull requests, create issues, or spread the word.