@maizzle/framework 5.0.0-beta.11 → 5.0.0-beta.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maizzle/framework",
3
- "version": "5.0.0-beta.11",
3
+ "version": "5.0.0-beta.13",
4
4
  "description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -4,8 +4,9 @@ import { cwd } from 'node:process'
4
4
  import { defu as merge } from 'defu'
5
5
  import expressions from 'posthtml-expressions'
6
6
  import { parseFrontMatter } from '../utils/node.js'
7
+ import defaultConfig from '../posthtml/defaultConfig.js'
7
8
  import { process as compilePostHTML } from '../posthtml/index.js'
8
- import { run as useTransformers, transformers } from '../transformers/index.js'
9
+ import { run as useTransformers } from '../transformers/index.js'
9
10
 
10
11
  export async function render(html = '', config = {}) {
11
12
  if (typeof html !== 'string') {
@@ -40,7 +41,7 @@ export async function render(html = '', config = {}) {
40
41
  })
41
42
  ]
42
43
  )
43
- .process(matter)
44
+ .process(matter, defaultConfig)
44
45
  .then(({ html }) => parseFrontMatter(`---${html}\n---`))
45
46
 
46
47
  const templateConfig = merge(matterData, config)
@@ -57,16 +58,18 @@ export async function render(html = '', config = {}) {
57
58
  *
58
59
  * @param {Object} options
59
60
  * @param {string} options.html - The HTML to be transformed
61
+ * @param {Object} options.matter - The front matter data
60
62
  * @param {Object} options.config - The current template config
61
- * @param {function} options.render - The render function
63
+ * @param {function} options.posthtml - The PostHTML compiler
64
+ * @param {Object} options.transform - The transformers object
62
65
  * @returns {string} - The transformed HTML, or the original one if nothing was returned
63
66
  */
64
67
  if (typeof templateConfig.beforeRender === 'function') {
65
68
  content = await templateConfig.beforeRender(({
66
69
  html: content,
70
+ matter: matterData,
67
71
  config: templateConfig,
68
72
  posthtml: compilePostHTML,
69
- transform: transformers,
70
73
  })) ?? content
71
74
  }
72
75
 
@@ -78,16 +81,18 @@ export async function render(html = '', config = {}) {
78
81
  *
79
82
  * @param {Object} options
80
83
  * @param {string} options.html - The HTML to be transformed
84
+ * @param {Object} options.matter - The front matter data
81
85
  * @param {Object} options.config - The current template config
82
- * @param {function} options.render - The render function
86
+ * @param {function} options.posthtml - The PostHTML compiler
87
+ * @param {Object} options.transform - The transformers object
83
88
  * @returns {string} - The transformed HTML, or the original one if nothing was returned
84
89
  */
85
90
  if (typeof templateConfig.afterRender === 'function') {
86
91
  compiled.html = await templateConfig.afterRender(({
87
92
  html: compiled.html,
93
+ matter: matterData,
88
94
  config: templateConfig,
89
95
  posthtml: compilePostHTML,
90
- transform: transformers,
91
96
  })) ?? compiled.html
92
97
  }
93
98
 
@@ -111,16 +116,18 @@ export async function render(html = '', config = {}) {
111
116
  *
112
117
  * @param {Object} options
113
118
  * @param {string} options.html - The HTML to be transformed
119
+ * @param {Object} options.matter - The front matter data
114
120
  * @param {Object} options.config - The current template config
115
- * @param {function} options.render - The render function
121
+ * @param {function} options.posthtml - The PostHTML compiler
122
+ * @param {Object} options.transform - The transformers object
116
123
  * @returns {string} - The transformed HTML, or the original one if nothing was returned
117
124
  */
118
125
  if (typeof templateConfig.afterTransformers === 'function') {
119
126
  compiled.html = await templateConfig.afterTransformers(({
120
127
  html: compiled.html,
128
+ matter: matterData,
121
129
  config: templateConfig,
122
130
  posthtml: compilePostHTML,
123
- transform: transformers,
124
131
  })) ?? compiled.html
125
132
  }
126
133
 
@@ -11,7 +11,7 @@ export default function posthtmlPlugin(attributes = {}) {
11
11
  role: 'none'
12
12
  },
13
13
  img: {
14
- alt: ''
14
+ alt: true,
15
15
  }
16
16
  }
17
17
 
@@ -37,7 +37,7 @@ const posthtmlPlugin = options => tree => {
37
37
 
38
38
  const { result: html } = emailComb(render(tree), options)
39
39
 
40
- return parse(html)
40
+ return parse(html, posthtmlConfig)
41
41
  }
42
42
 
43
43
  export default posthtmlPlugin
@@ -2,6 +2,7 @@ import posthtml from 'posthtml'
2
2
  import get from 'lodash-es/get.js'
3
3
  import { defu as merge } from 'defu'
4
4
 
5
+ import core from './core.js'
5
6
  import comb from './comb.js'
6
7
  import sixHex from './sixHex.js'
7
8
  import minify from './minify.js'
@@ -21,19 +22,17 @@ import replaceStrings from './replaceStrings.js'
21
22
  import attributeToStyle from './attributeToStyle.js'
22
23
  import removeAttributes from './removeAttributes.js'
23
24
 
24
- import coreTransformers from './core.js'
25
-
26
25
  import defaultPosthtmlConfig from '../posthtml/defaultConfig.js'
27
26
 
28
27
  /**
29
28
  * Use Maizzle Transformers on an HTML string.
30
29
  *
31
- * Only Transformers that are enabled in the `config` will be used.
30
+ * Only Transformers that are enabled in the passed
31
+ * `config` parameter will be used.
32
32
  *
33
33
  * @param {string} html The HTML content
34
34
  * @param {object} config The Maizzle config object
35
- * @returns {Promise<{ original: string, config: object, html: string }>}
36
- * A Promise resolving to an object containing the original HTML, modified HTML, and the config
35
+ * @returns {Promise<{ html: string }>} A Promise resolving to an object containing the modified HTML
37
36
  */
38
37
  export async function run(html = '', config = {}) {
39
38
  const posthtmlPlugins = []
@@ -46,16 +45,16 @@ export async function run(html = '', config = {}) {
46
45
  /**
47
46
  * 1. Core transformers
48
47
  *
49
- * Transformers that are always enabled
48
+ * Transformers that are always enabled.
50
49
  *
51
50
  */
52
- posthtmlPlugins.push(coreTransformers(config))
51
+ posthtmlPlugins.push(core(config))
53
52
 
54
53
  /**
55
54
  * 2. Safe class names
56
55
  *
57
56
  * Rewrite Tailwind CSS class names to email-safe alternatives,
58
- * unless explicitly disabled
57
+ * unless explicitly disabled.
59
58
  */
60
59
  if (get(config, 'css.safe') !== false) {
61
60
  posthtmlPlugins.push(
@@ -66,7 +65,6 @@ export async function run(html = '', config = {}) {
66
65
  /**
67
66
  * 3. Filters
68
67
  *
69
- * Apply filters to HTML.
70
68
  * Filters are always applied, unless explicitly disabled.
71
69
  */
72
70
  if (get(config, 'filters') !== false) {
@@ -78,7 +76,7 @@ export async function run(html = '', config = {}) {
78
76
  /**
79
77
  * 4. Markdown
80
78
  *
81
- * Convert Markdown to HTML with Markdown-it, unless explicitly disabled
79
+ * Convert Markdown to HTML with markdown-it, unless explicitly disabled.
82
80
  */
83
81
  if (get(config, 'markdown') !== false) {
84
82
  posthtmlPlugins.push(
@@ -88,7 +86,9 @@ export async function run(html = '', config = {}) {
88
86
 
89
87
  /**
90
88
  * 5. Prevent widow words
91
- * Always runs, unless explicitly disabled
89
+ *
90
+ * Enabled by default, will prevent widow words in elements
91
+ * wrapped with a `prevent-widows` attribute.
92
92
  */
93
93
  if (get(config, 'widowWords') !== false) {
94
94
  posthtmlPlugins.push(
@@ -110,7 +110,7 @@ export async function run(html = '', config = {}) {
110
110
  /**
111
111
  * 7. Inline CSS
112
112
  *
113
- * Inline CSS into HTML
113
+ * Inline CSS into HTML.
114
114
  */
115
115
  if (get(config, 'css.inline')) {
116
116
  posthtmlPlugins.push(inlineCSS(
@@ -150,7 +150,7 @@ export async function run(html = '', config = {}) {
150
150
  /**
151
151
  * 10. Shorthand CSS
152
152
  *
153
- * Convert longhand CSS properties to shorthand in `style` attributes
153
+ * Convert longhand CSS properties to shorthand in `style` attributes.
154
154
  */
155
155
  if (get(config, 'css.shorthand')) {
156
156
  posthtmlPlugins.push(
@@ -161,7 +161,7 @@ export async function run(html = '', config = {}) {
161
161
  /**
162
162
  * 11. Add attributes
163
163
  *
164
- * Add attributes to HTML tags
164
+ * Add attributes to HTML tags.
165
165
  */
166
166
  if (get(config, 'attributes.add') !== false) {
167
167
  posthtmlPlugins.push(
@@ -172,7 +172,7 @@ export async function run(html = '', config = {}) {
172
172
  /**
173
173
  * 12. Base URL
174
174
  *
175
- * Add a base URL to relative paths
175
+ * Add a base URL to relative paths.
176
176
  */
177
177
  if (get(config, 'baseURL', get(config, 'baseUrl'))) {
178
178
  posthtmlPlugins.push(
@@ -180,7 +180,7 @@ export async function run(html = '', config = {}) {
180
180
  )
181
181
  } else {
182
182
  /**
183
- * Set baseURL to `build.static.destination` if it's not already set
183
+ * Set baseURL to `build.static.destination` if it's not already set.
184
184
  */
185
185
  const destination = get(config, 'build.static.destination', '')
186
186
  if (destination && !config._dev) {
@@ -198,7 +198,7 @@ export async function run(html = '', config = {}) {
198
198
  /**
199
199
  * 13. URL parameters
200
200
  *
201
- * Add parameters to URLs
201
+ * Add parameters to URLs.
202
202
  */
203
203
  if (get(config, 'urlParameters')) {
204
204
  posthtmlPlugins.push(
@@ -209,8 +209,7 @@ export async function run(html = '', config = {}) {
209
209
  /**
210
210
  * 14. Six-digit HEX
211
211
  *
212
- * Convert three-digit HEX colors to six-digit
213
- * Always runs, unless explicitly disabled
212
+ * Enabled by default, converts three-digit HEX colors to six-digit.
214
213
  */
215
214
  if (get(config, 'css.sixHex') !== false) {
216
215
  posthtmlPlugins.push(
@@ -221,7 +220,7 @@ export async function run(html = '', config = {}) {
221
220
  /**
222
221
  * 15. PostHTML MSO
223
222
  *
224
- * Simplify writing MSO conditionals for Outlook
223
+ * Enabled by default, simplifies writing MSO conditionals for Outlook.
225
224
  */
226
225
  if (get(config, 'outlook') !== false) {
227
226
  posthtmlPlugins.push(
@@ -232,7 +231,7 @@ export async function run(html = '', config = {}) {
232
231
  /**
233
232
  * 16. Prettify
234
233
  *
235
- * Pretty-print HTML using js-beautify
234
+ * Pretty-print HTML using js-beautify.
236
235
  */
237
236
  if (get(config, 'prettify')) {
238
237
  posthtmlPlugins.push(
@@ -243,7 +242,7 @@ export async function run(html = '', config = {}) {
243
242
  /**
244
243
  * 17. Minify
245
244
  *
246
- * Minify HTML using html-crush
245
+ * Minify HTML using html-crush.
247
246
  */
248
247
  if (get(config, 'minify')) {
249
248
  posthtmlPlugins.push(
@@ -254,14 +253,14 @@ export async function run(html = '', config = {}) {
254
253
  /**
255
254
  * 18. <template> tags
256
255
  *
257
- * Replace <template> tags with their content
256
+ * Replace <template> tags with their content.
258
257
  */
259
258
  posthtmlPlugins.push(templateTag())
260
259
 
261
260
  /**
262
261
  * 19. Replace strings
263
262
  *
264
- * Replace strings through regular expressions
263
+ * Replace strings through regular expressions.
265
264
  */
266
265
  if (get(config, 'replaceStrings')) {
267
266
  posthtmlPlugins.push(
@@ -275,23 +274,3 @@ export async function run(html = '', config = {}) {
275
274
  html: result.html,
276
275
  }))
277
276
  }
278
-
279
- export const transformers = {
280
- comb,
281
- sixHex,
282
- minify,
283
- baseUrl,
284
- inlineCSS,
285
- prettify,
286
- filters,
287
- markdown,
288
- posthtmlMso,
289
- shorthandCss,
290
- preventWidows,
291
- addAttributes,
292
- urlParameters,
293
- safeClassNames,
294
- replaceStrings,
295
- attributeToStyle,
296
- removeAttributes,
297
- }
@@ -12,9 +12,10 @@ import isObject from 'lodash-es/isObject.js'
12
12
  import { parser as parse } from 'posthtml-parser'
13
13
  import { parseCSSRule } from '../utils/string.js'
14
14
  import { useAttributeSizes } from './useAttributeSizes.js'
15
+ import defaultPostHTMLConfig from '../posthtml/defaultConfig.js'
15
16
 
16
17
  const posthtmlPlugin = (options = {}) => tree => {
17
- return inline(render(tree), options).then(html => parse(html))
18
+ return inline(render(tree), options).then(html => parse(html, defaultPostHTMLConfig))
18
19
  }
19
20
 
20
21
  export default posthtmlPlugin
@@ -4,6 +4,7 @@ import { defu as merge } from 'defu'
4
4
  import { render } from 'posthtml-render'
5
5
  import { parser as parse } from 'posthtml-parser'
6
6
  import posthtmlConfig from '../posthtml/defaultConfig.js'
7
+ import defaultPostHTMLConfig from '../posthtml/defaultConfig.js'
7
8
 
8
9
  const posthtmlPlugin = (options = {}) => tree => {
9
10
  options = merge(options, {
@@ -12,7 +13,7 @@ const posthtmlPlugin = (options = {}) => tree => {
12
13
 
13
14
  const { result: html } = crush(render(tree), options)
14
15
 
15
- return parse(html)
16
+ return parse(html, defaultPostHTMLConfig)
16
17
  }
17
18
 
18
19
  export default posthtmlPlugin
@@ -4,6 +4,7 @@ import { render } from 'posthtml-render'
4
4
  import isEmpty from 'lodash-es/isEmpty.js'
5
5
  import { parser as parse } from 'posthtml-parser'
6
6
  import posthtmlConfig from '../posthtml/defaultConfig.js'
7
+ import defaultPostHTMLConfig from '../posthtml/defaultConfig.js'
7
8
 
8
9
  const posthtmlPlugin = (replacements = {}) => tree => {
9
10
  if (!isEmpty(replacements)) {
@@ -17,7 +18,8 @@ const posthtmlPlugin = (replacements = {}) => tree => {
17
18
  return replacement
18
19
  }
19
20
  }
20
- })
21
+ }),
22
+ defaultPostHTMLConfig
21
23
  )
22
24
  }
23
25
 
package/types/build.d.ts CHANGED
@@ -1,13 +1,7 @@
1
- import ComponentsConfig from './components';
2
1
  import type { SpinnerName } from 'cli-spinners';
3
2
  import type ExpressionsConfig from './expressions';
4
3
 
5
4
  export default interface BuildConfig {
6
- /**
7
- * Components configuration.
8
- */
9
- components?: ComponentsConfig;
10
-
11
5
  /**
12
6
  * Paths where Maizzle should look for Templates to compile.
13
7
  *
@@ -22,7 +16,7 @@ export default interface BuildConfig {
22
16
  * }
23
17
  * ```
24
18
  */
25
- content?: string | string[];
19
+ content?: string[];
26
20
 
27
21
  /**
28
22
  Configure expressions.
@@ -88,21 +82,6 @@ export default interface BuildConfig {
88
82
  * @default undefined
89
83
  */
90
84
  destination?: string;
91
- } | {
92
- /**
93
- * An array of objects specifying source and destination directories for static files.
94
- */
95
- static: Array<{
96
- /**
97
- * Array of paths where Maizzle should look for static files.
98
- */
99
- source: string[];
100
- /**
101
- * Directory where static files should be copied to,
102
- * relative to the `build.output` path.
103
- */
104
- destination: string;
105
- }>;
106
85
  };
107
86
 
108
87
  /**
package/types/config.d.ts CHANGED
@@ -1,9 +1,11 @@
1
+ import type Events from './events';
1
2
  import type BuildConfig from './build';
2
3
  import type MinifyConfig from './minify';
3
4
  import type PostHTMLConfig from './posthtml';
4
5
  import type MarkdownConfig from './markdown';
5
6
  import type { ProcessOptions } from 'postcss';
6
7
  import type PurgeCSSConfig from './css/purge';
8
+ import type PlaintextConfig from './plaintext';
7
9
  import type CSSInlineConfig from './css/inline';
8
10
  import type { SpinnerName } from 'cli-spinners';
9
11
  import type ComponentsConfig from './components';
@@ -11,20 +13,10 @@ import type WidowWordsConfig from './widowWords';
11
13
  import type { CoreBeautifyOptions } from 'js-beautify';
12
14
  import type { BaseURLConfig } from 'posthtml-base-url';
13
15
  import type URLParametersConfig from './urlParameters';
14
- import type {
15
- beforeCreateType,
16
- beforeRenderType,
17
- afterRenderType,
18
- afterTransformersType,
19
- afterBuildType
20
- } from './events';
21
- import type PlaintextConfig from './plaintext';
22
16
 
23
17
  import type { Config as TailwindConfig } from 'tailwindcss';
24
18
 
25
19
  export default interface Config {
26
- [key: string]: any; // eslint-disable-line
27
-
28
20
  /**
29
21
  * Add or remove attributes from elements.
30
22
  */
@@ -68,20 +60,8 @@ export default interface Config {
68
60
  }
69
61
 
70
62
  /**
71
- Configure build settings.
72
-
73
- @example
74
- ```
75
- export default {
76
- build: {
77
- components: ComponentsConfig,
78
- posthtml: PostHTMLConfig,
79
- tailwind: TailwindConfig,
80
- templates: TemplatesConfig,
81
- }
82
- }
83
- ```
84
- */
63
+ * Configure build settings.
64
+ */
85
65
  build: BuildConfig;
86
66
 
87
67
  /**
@@ -185,7 +165,6 @@ export default interface Config {
185
165
 
186
166
  /**
187
167
  * Use a custom Tailwind CSS configuration object.
188
- *
189
168
  */
190
169
  tailwind?: TailwindConfig;
191
170
  }
@@ -229,7 +208,7 @@ export default interface Config {
229
208
  * <p>{{ company.name }}</p>
230
209
  * ```
231
210
  */
232
- locals?: Record<string, any>; // eslint-disable-line
211
+ locals?: Record<string, any>;
233
212
 
234
213
  /**
235
214
  * Configure the Markdown parser.
@@ -488,83 +467,87 @@ export default interface Config {
488
467
  * @example
489
468
  * ```
490
469
  * export default {
491
- * beforeCreate: async (config) => {
470
+ * beforeCreate: async ({config}) => {
492
471
  * // do something with `config`
493
472
  * }
494
473
  * }
495
474
  * ```
496
475
  */
497
- beforeCreate: beforeCreateType;
476
+ beforeCreate: Events['beforeCreate'];
498
477
 
499
478
  /**
500
479
  * Runs after the Template's config has been computed, but just before it is compiled.
501
- * It exposes the Template's HTML, its config, and the Maizzle `render` function.
502
- * Must return the `html` string.
480
+ *
481
+ * Must return the `html` string, otherwise the original will be used.
503
482
  *
504
483
  * @default undefined
505
484
  *
506
485
  * @example
507
486
  * ```
508
487
  * export default {
509
- * beforeRender: async ({html, config, render}) => {
488
+ * beforeRender: async ({html, matter, config, posthtml, transform}) => {
510
489
  * // do something...
511
490
  * return html;
512
491
  * }
513
492
  * }
514
493
  * ```
515
494
  */
516
- beforeRender: beforeRenderType;
495
+ beforeRender: Events['beforeRender'];
517
496
 
518
497
  /**
519
498
  * Runs after the Template has been compiled, but before any Transformers have been applied.
520
- * Exposes the rendered `html` string and the `config`. Must return the `html` string.
499
+ *
500
+ * Must return the `html` string, otherwise the original will be used.
521
501
  *
522
502
  * @default undefined
523
503
  *
524
504
  * @example
525
505
  * ```
526
506
  * export default {
527
- * afterRender: async ({html, config}) => {
507
+ * afterRender: async ({html, matter, config, posthtml, transform}) => {
528
508
  * // do something...
529
509
  * return html;
530
510
  * }
531
511
  * }
532
512
  * ```
533
513
  */
534
- afterRender: afterRenderType;
514
+ afterRender: Events['afterRender'];
535
515
 
536
516
  /**
537
517
  * Runs after all Transformers have been applied, just before the final HTML is returned.
538
- * Exposes the rendered `html` string and the `config`. Must return the `html` string.
518
+ *
519
+ * Must return the `html` string, otherwise the original will be used.
539
520
  *
540
521
  * @default undefined
541
522
  *
542
523
  * @example
543
524
  * ```
544
525
  * export default {
545
- * afterTransformers: async ({html, config, render}) => {
526
+ * afterTransformers: async ({html, matter, config, posthtml, transform}) => {
546
527
  * // do something...
547
528
  * return html;
548
529
  * }
549
530
  * }
550
531
  * ```
551
532
  */
552
- afterTransformers: afterTransformersType;
533
+ afterTransformers: Events['afterTransformers'];
553
534
 
554
535
  /**
555
536
  * Runs after all Templates have been compiled and output to disk.
556
- * The files parameter will contain the paths to all the files inside the `build.templates.destination.path` directory.
537
+ * `files` will contain the paths to all the files inside the `build.output.path` directory.
557
538
  *
558
539
  * @default undefined
559
540
  *
560
541
  * @example
561
542
  * ```
562
543
  * export default {
563
- * afterBuild: async ({files, config, render}) => {
544
+ * afterBuild: async ({files, config, transform}) => {
564
545
  * // do something...
565
546
  * }
566
547
  * }
567
548
  * ```
568
549
  */
569
- afterBuild: afterBuildType;
550
+ afterBuild: Events['afterBuild'];
551
+
552
+ [key: string]: any;
570
553
  }
package/types/events.d.ts CHANGED
@@ -1,5 +1,165 @@
1
- export type beforeCreateType = (config: object) => Promise<void>;
2
- export type beforeRenderType = (html: string, config: object, render: (html: string, config: object) => Promise<string>) => Promise<string>;
3
- export type afterRenderType = ({ html, config }: { html: string, config: object }) => Promise<string>;
4
- export type afterTransformersType = ({ html, config, render }: { html: string, config: object, render: (html: string, config: object) => Promise<string> }) => Promise<string>;
5
- export type afterBuildType = ({ files, config, render }: { files: string[], config: object, render: (html: string, config: object) => Promise<string> }) => Promise<void>;
1
+ import type Config from "./config";
2
+
3
+ type PostHTMLType = (html: string, config: Config) => { html: string; config: Config };
4
+
5
+ export default interface Events {
6
+ /**
7
+ * Runs after the Environment config has been computed, but before Templates are processed.
8
+ * Exposes the `config` object so you can further customize it.
9
+ *
10
+ * @default undefined
11
+ *
12
+ * @example
13
+ * ```
14
+ * export default {
15
+ * beforeCreate: async ({config}) => {
16
+ * // do something with `config`
17
+ * }
18
+ * }
19
+ * ```
20
+ */
21
+ beforeCreate?: (params: { config: Config }) => void | Promise<void>;
22
+
23
+ /**
24
+ * Runs after the Template's config has been computed, but just before it is compiled.
25
+ *
26
+ * Must return the `html` string, otherwise the original will be used.
27
+ *
28
+ * @default undefined
29
+ *
30
+ * @example
31
+ * ```
32
+ * export default {
33
+ * beforeRender: async ({html, matter, config, posthtml}) => {
34
+ * // do something...
35
+ * return html;
36
+ * }
37
+ * }
38
+ * ```
39
+ */
40
+ beforeRender?: (params: {
41
+ /**
42
+ * The Template's HTML string.
43
+ */
44
+ html: string;
45
+ /**
46
+ * The Template's Front Matter.
47
+ */
48
+ matter: { [key: string]: string };
49
+ /**
50
+ * The Template's computed config.
51
+ */
52
+ config: Config;
53
+ /**
54
+ * A function to process an HTML string with PostHTML.
55
+ *
56
+ * @param {string} html The HTML string to process.
57
+ * @param {Config} config The Maizzle config object.
58
+ */
59
+ posthtml: PostHTMLType;
60
+ }) => string | Promise<string>;
61
+
62
+ /**
63
+ * Runs after the Template has been compiled, but before any Transformers have been applied.
64
+ *
65
+ * Must return the `html` string, otherwise the original will be used.
66
+ *
67
+ * @default undefined
68
+ *
69
+ * @example
70
+ * ```
71
+ * export default {
72
+ * afterRender: async async ({html, matter, config, posthtml}) => {
73
+ * // do something...
74
+ * return html;
75
+ * }
76
+ * }
77
+ * ```
78
+ */
79
+ afterRender?: (params: {
80
+ /**
81
+ * The Template's HTML string.
82
+ */
83
+ html: string;
84
+ /**
85
+ * The Template's Front Matter.
86
+ */
87
+ matter: { [key: string]: string };
88
+ /**
89
+ * The Template's computed config.
90
+ */
91
+ config: Config;
92
+ /**
93
+ * A function to process an HTML string with PostHTML.
94
+ *
95
+ * @param {string} html The HTML string to process.
96
+ * @param {Config} config The Maizzle config object.
97
+ */
98
+ posthtml: PostHTMLType;
99
+ }) => string | Promise<string>;
100
+
101
+ /**
102
+ * Runs after all Transformers have been applied, just before the final HTML is returned.
103
+ *
104
+ * Must return the `html` string, otherwise the original will be used.
105
+ *
106
+ * @default undefined
107
+ *
108
+ * @example
109
+ * ```
110
+ * export default {
111
+ * afterTransformers: async ({html, matter, config, posthtml}) => {
112
+ * // do something...
113
+ * return html;
114
+ * }
115
+ * }
116
+ * ```
117
+ */
118
+ afterTransformers?: (params: {
119
+ /**
120
+ * The Template's HTML string.
121
+ */
122
+ html: string;
123
+ /**
124
+ * The Template's Front Matter.
125
+ */
126
+ matter: { [key: string]: string };
127
+ /**
128
+ * The Template's computed config.
129
+ */
130
+ config: Config;
131
+ /**
132
+ * A function to process an HTML string with PostHTML.
133
+ *
134
+ * @param {string} html The HTML string to process.
135
+ * @param {Config} config The Maizzle config object.
136
+ */
137
+ posthtml: PostHTMLType;
138
+ }) => string | Promise<string>;
139
+
140
+ /**
141
+ * Runs after all Templates have been compiled and output to disk.
142
+ * `files` will contain the paths to all the files inside the `build.output.path` directory.
143
+ *
144
+ * @default undefined
145
+ *
146
+ * @example
147
+ * ```
148
+ * export default {
149
+ * afterBuild: async ({files, config}) => {
150
+ * // do something...
151
+ * }
152
+ * }
153
+ * ```
154
+ */
155
+ afterBuild?: (params: {
156
+ /**
157
+ * An array of paths to all the files inside the `build.output.path` directory.
158
+ */
159
+ files: string[];
160
+ /**
161
+ * The Maizzle config object.
162
+ */
163
+ config: Config;
164
+ }) => string | Promise<string>;
165
+ }
@@ -1,7 +1,7 @@
1
1
  import type { URLParametersConfig as URLParamsConfig } from 'posthtml-url-parameters';
2
2
 
3
3
  export default interface URLParametersConfig {
4
- [key: string]: any; // eslint-disable-line
4
+ [key: string]: any;
5
5
 
6
6
  _options?: {
7
7
  /**