@maizzle/framework 5.0.0-beta.11 → 5.0.0-beta.12
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 +1 -1
- package/src/generators/render.js +14 -4
- package/types/config.d.ts +20 -24
- package/types/events.d.ts +346 -5
package/package.json
CHANGED
package/src/generators/render.js
CHANGED
|
@@ -4,6 +4,7 @@ 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
9
|
import { run as useTransformers, transformers } from '../transformers/index.js'
|
|
9
10
|
|
|
@@ -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,13 +58,16 @@ 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.
|
|
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
73
|
transform: transformers,
|
|
@@ -78,13 +82,16 @@ export async function render(html = '', config = {}) {
|
|
|
78
82
|
*
|
|
79
83
|
* @param {Object} options
|
|
80
84
|
* @param {string} options.html - The HTML to be transformed
|
|
85
|
+
* @param {Object} options.matter - The front matter data
|
|
81
86
|
* @param {Object} options.config - The current template config
|
|
82
|
-
* @param {function} options.
|
|
87
|
+
* @param {function} options.posthtml - The PostHTML compiler
|
|
88
|
+
* @param {Object} options.transform - The transformers object
|
|
83
89
|
* @returns {string} - The transformed HTML, or the original one if nothing was returned
|
|
84
90
|
*/
|
|
85
91
|
if (typeof templateConfig.afterRender === 'function') {
|
|
86
92
|
compiled.html = await templateConfig.afterRender(({
|
|
87
93
|
html: compiled.html,
|
|
94
|
+
matter: matterData,
|
|
88
95
|
config: templateConfig,
|
|
89
96
|
posthtml: compilePostHTML,
|
|
90
97
|
transform: transformers,
|
|
@@ -111,13 +118,16 @@ export async function render(html = '', config = {}) {
|
|
|
111
118
|
*
|
|
112
119
|
* @param {Object} options
|
|
113
120
|
* @param {string} options.html - The HTML to be transformed
|
|
121
|
+
* @param {Object} options.matter - The front matter data
|
|
114
122
|
* @param {Object} options.config - The current template config
|
|
115
|
-
* @param {function} options.
|
|
123
|
+
* @param {function} options.posthtml - The PostHTML compiler
|
|
124
|
+
* @param {Object} options.transform - The transformers object
|
|
116
125
|
* @returns {string} - The transformed HTML, or the original one if nothing was returned
|
|
117
126
|
*/
|
|
118
127
|
if (typeof templateConfig.afterTransformers === 'function') {
|
|
119
128
|
compiled.html = await templateConfig.afterTransformers(({
|
|
120
129
|
html: compiled.html,
|
|
130
|
+
matter: matterData,
|
|
121
131
|
config: templateConfig,
|
|
122
132
|
posthtml: compilePostHTML,
|
|
123
133
|
transform: transformers,
|
package/types/config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
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';
|
|
@@ -11,20 +12,11 @@ import type WidowWordsConfig from './widowWords';
|
|
|
11
12
|
import type { CoreBeautifyOptions } from 'js-beautify';
|
|
12
13
|
import type { BaseURLConfig } from 'posthtml-base-url';
|
|
13
14
|
import type URLParametersConfig from './urlParameters';
|
|
14
|
-
import type {
|
|
15
|
-
beforeCreateType,
|
|
16
|
-
beforeRenderType,
|
|
17
|
-
afterRenderType,
|
|
18
|
-
afterTransformersType,
|
|
19
|
-
afterBuildType
|
|
20
|
-
} from './events';
|
|
21
15
|
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
|
*/
|
|
@@ -488,83 +480,87 @@ export default interface Config {
|
|
|
488
480
|
* @example
|
|
489
481
|
* ```
|
|
490
482
|
* export default {
|
|
491
|
-
* beforeCreate: async (config) => {
|
|
483
|
+
* beforeCreate: async ({config}) => {
|
|
492
484
|
* // do something with `config`
|
|
493
485
|
* }
|
|
494
486
|
* }
|
|
495
487
|
* ```
|
|
496
488
|
*/
|
|
497
|
-
beforeCreate:
|
|
489
|
+
beforeCreate: Events['beforeCreate'];
|
|
498
490
|
|
|
499
491
|
/**
|
|
500
492
|
* Runs after the Template's config has been computed, but just before it is compiled.
|
|
501
|
-
*
|
|
502
|
-
* Must return the `html` string.
|
|
493
|
+
*
|
|
494
|
+
* Must return the `html` string, otherwise the original will be used.
|
|
503
495
|
*
|
|
504
496
|
* @default undefined
|
|
505
497
|
*
|
|
506
498
|
* @example
|
|
507
499
|
* ```
|
|
508
500
|
* export default {
|
|
509
|
-
* beforeRender: async ({html, config,
|
|
501
|
+
* beforeRender: async ({html, matter, config, posthtml, transform}) => {
|
|
510
502
|
* // do something...
|
|
511
503
|
* return html;
|
|
512
504
|
* }
|
|
513
505
|
* }
|
|
514
506
|
* ```
|
|
515
507
|
*/
|
|
516
|
-
beforeRender:
|
|
508
|
+
beforeRender: Events['beforeRender'];
|
|
517
509
|
|
|
518
510
|
/**
|
|
519
511
|
* Runs after the Template has been compiled, but before any Transformers have been applied.
|
|
520
|
-
*
|
|
512
|
+
*
|
|
513
|
+
* Must return the `html` string, otherwise the original will be used.
|
|
521
514
|
*
|
|
522
515
|
* @default undefined
|
|
523
516
|
*
|
|
524
517
|
* @example
|
|
525
518
|
* ```
|
|
526
519
|
* export default {
|
|
527
|
-
* afterRender: async ({html, config}) => {
|
|
520
|
+
* afterRender: async ({html, matter, config, posthtml, transform}) => {
|
|
528
521
|
* // do something...
|
|
529
522
|
* return html;
|
|
530
523
|
* }
|
|
531
524
|
* }
|
|
532
525
|
* ```
|
|
533
526
|
*/
|
|
534
|
-
afterRender:
|
|
527
|
+
afterRender: Events['afterRender'];
|
|
535
528
|
|
|
536
529
|
/**
|
|
537
530
|
* Runs after all Transformers have been applied, just before the final HTML is returned.
|
|
538
|
-
*
|
|
531
|
+
*
|
|
532
|
+
* Must return the `html` string, otherwise the original will be used.
|
|
539
533
|
*
|
|
540
534
|
* @default undefined
|
|
541
535
|
*
|
|
542
536
|
* @example
|
|
543
537
|
* ```
|
|
544
538
|
* export default {
|
|
545
|
-
* afterTransformers: async ({html, config,
|
|
539
|
+
* afterTransformers: async ({html, matter, config, posthtml, transform}) => {
|
|
546
540
|
* // do something...
|
|
547
541
|
* return html;
|
|
548
542
|
* }
|
|
549
543
|
* }
|
|
550
544
|
* ```
|
|
551
545
|
*/
|
|
552
|
-
afterTransformers:
|
|
546
|
+
afterTransformers: Events['afterTransformers'];
|
|
553
547
|
|
|
554
548
|
/**
|
|
555
549
|
* Runs after all Templates have been compiled and output to disk.
|
|
556
|
-
*
|
|
550
|
+
* `files` will contain the paths to all the files inside the `build.output.path` directory.
|
|
557
551
|
*
|
|
558
552
|
* @default undefined
|
|
559
553
|
*
|
|
560
554
|
* @example
|
|
561
555
|
* ```
|
|
562
556
|
* export default {
|
|
563
|
-
* afterBuild: async ({files, config,
|
|
557
|
+
* afterBuild: async ({files, config, transform}) => {
|
|
564
558
|
* // do something...
|
|
565
559
|
* }
|
|
566
560
|
* }
|
|
567
561
|
* ```
|
|
568
562
|
*/
|
|
569
|
-
afterBuild:
|
|
563
|
+
afterBuild: Events['afterBuild'];
|
|
564
|
+
|
|
565
|
+
[key: string]: any;
|
|
570
566
|
}
|
package/types/events.d.ts
CHANGED
|
@@ -1,5 +1,346 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type Config from "./config";
|
|
2
|
+
import type {
|
|
3
|
+
safeClassNames,
|
|
4
|
+
markdown,
|
|
5
|
+
preventWidows,
|
|
6
|
+
attributeToStyle,
|
|
7
|
+
inlineCSS,
|
|
8
|
+
shorthandCSS,
|
|
9
|
+
removeUnusedCSS,
|
|
10
|
+
purgeCSS,
|
|
11
|
+
removeAttributes,
|
|
12
|
+
addAttributes,
|
|
13
|
+
prettify,
|
|
14
|
+
applyBaseURL,
|
|
15
|
+
addUrlParams,
|
|
16
|
+
sixHEX,
|
|
17
|
+
minify,
|
|
18
|
+
replaceStrings,
|
|
19
|
+
plaintext,
|
|
20
|
+
} from "./index";
|
|
21
|
+
|
|
22
|
+
type PostHTMLType = (html: string, config: Config) => { html: string; config: Config };
|
|
23
|
+
|
|
24
|
+
type TransformType = {
|
|
25
|
+
/**
|
|
26
|
+
* Normalize escaped character class names like `\:` or `\/` by replacing them with email-safe alternatives.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} html The HTML string to normalize.
|
|
29
|
+
* @param {Record<string, string>} replacements A dictionary of replacements to apply.
|
|
30
|
+
* @returns {string} The normalized HTML string.
|
|
31
|
+
* @see https://maizzle.com/docs/transformers/safe-class-names
|
|
32
|
+
*/
|
|
33
|
+
safeClassNames: typeof safeClassNames;
|
|
34
|
+
/**
|
|
35
|
+
* Compile Markdown to HTML.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} input The Markdown string to compile.
|
|
38
|
+
* @param {MarkdownConfig} [options] A configuration object for the Markdown compiler.
|
|
39
|
+
* @returns {string} The compiled HTML string.
|
|
40
|
+
* @see https://maizzle.com/docs/transformers/markdown
|
|
41
|
+
*/
|
|
42
|
+
markdown: typeof markdown;
|
|
43
|
+
/**
|
|
44
|
+
* Prevent widow words inside a tag by adding a ` ` between its last two words.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} html The HTML string to process.
|
|
47
|
+
* @param {WidowWordsConfig} [options] A configuration object for the widow words transformer.
|
|
48
|
+
* @returns {string} The processed HTML string.
|
|
49
|
+
* @see https://maizzle.com/docs/transformers/widows
|
|
50
|
+
*/
|
|
51
|
+
preventWidows: typeof preventWidows;
|
|
52
|
+
/**
|
|
53
|
+
* Duplicate HTML attributes to inline CSS.
|
|
54
|
+
*
|
|
55
|
+
* @param {string} html The HTML string to process.
|
|
56
|
+
* @param {AttributeToStyleSupportedAttributes[]} attributes An array of attributes to inline.
|
|
57
|
+
* @param {PostHTMLConfig} [posthtmlConfig] A configuration object for PostHTML.
|
|
58
|
+
* @returns {string} The processed HTML string.
|
|
59
|
+
* @see https://maizzle.com/docs/transformers/attribute-to-style
|
|
60
|
+
*/
|
|
61
|
+
attributeToStyle: typeof attributeToStyle;
|
|
62
|
+
/**
|
|
63
|
+
* Inline CSS styles in an HTML string.
|
|
64
|
+
*
|
|
65
|
+
* @param {string} html The HTML string to process.
|
|
66
|
+
* @param {CSSInlineConfig} [options] A configuration object for the CSS inliner.
|
|
67
|
+
* @returns {string} The processed HTML string.
|
|
68
|
+
* @see https://maizzle.com/docs/transformers/inline-css
|
|
69
|
+
*/
|
|
70
|
+
inlineCSS: typeof inlineCSS;
|
|
71
|
+
/**
|
|
72
|
+
* Rewrite longhand CSS inside style attributes with shorthand syntax.
|
|
73
|
+
* Only works with margin, padding and border, and only when all sides are specified.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} html The HTML string to process.
|
|
76
|
+
* @returns {string} The processed HTML string.
|
|
77
|
+
* @see https://maizzle.com/docs/transformers/shorthand-css
|
|
78
|
+
*/
|
|
79
|
+
shorthandCSS: typeof shorthandCSS;
|
|
80
|
+
/**
|
|
81
|
+
* Remove unused CSS from `<style>` tags and HTML elements.
|
|
82
|
+
*
|
|
83
|
+
* @param {string} html The HTML string to process.
|
|
84
|
+
* @param {PurgeCSSConfig} [options] A configuration object for `email-comb`.
|
|
85
|
+
* @returns {string} The processed HTML string.
|
|
86
|
+
* @see https://maizzle.com/docs/transformers/remove-unused-css
|
|
87
|
+
*/
|
|
88
|
+
removeUnusedCSS: typeof removeUnusedCSS;
|
|
89
|
+
/**
|
|
90
|
+
* Remove HTML attributes from an HTML string.
|
|
91
|
+
*
|
|
92
|
+
* @param {string} html The HTML string to process.
|
|
93
|
+
* @param {string[] | Array<{ name: string; value: string | RegExp }>} [options] An array of attribute names to remove, or an array of objects with `name` and `value` properties.
|
|
94
|
+
* @returns {string} The processed HTML string.
|
|
95
|
+
* @see https://maizzle.com/docs/transformers/remove-attributes
|
|
96
|
+
*/
|
|
97
|
+
removeAttributes: typeof removeAttributes;
|
|
98
|
+
/**
|
|
99
|
+
* Add attributes to elements in an HTML string.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} html The HTML string to process.
|
|
102
|
+
* @param {Record<string, unknown>} [options] A dictionary of attributes to add.
|
|
103
|
+
* @returns {string} The processed HTML string.
|
|
104
|
+
* @see https://maizzle.com/docs/transformers/add-attributes
|
|
105
|
+
*/
|
|
106
|
+
addAttributes: typeof addAttributes;
|
|
107
|
+
/**
|
|
108
|
+
* Pretty-print an HTML string.
|
|
109
|
+
*
|
|
110
|
+
* @param {string} html The HTML string to prettify.
|
|
111
|
+
* @param {HTMLBeautifyOptions} [options] A configuration object for `js-beautify`.
|
|
112
|
+
* @returns {string} The prettified HTML string.
|
|
113
|
+
* @see https://maizzle.com/docs/transformers/prettify
|
|
114
|
+
*/
|
|
115
|
+
prettify: typeof prettify;
|
|
116
|
+
/**
|
|
117
|
+
* Prepend a string to sources and hrefs in an HTML string.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} html The HTML string to process.
|
|
120
|
+
* @param {string | BaseURLConfig} [options] A string to prepend to sources and hrefs, or a configuration object for `posthtml-base-url`.
|
|
121
|
+
* @returns {string} The processed HTML string.
|
|
122
|
+
* @see https://maizzle.com/docs/transformers/base-url
|
|
123
|
+
*/
|
|
124
|
+
applyBaseURL: typeof applyBaseURL;
|
|
125
|
+
/**
|
|
126
|
+
* Append parameters to URLs in an HTML string.
|
|
127
|
+
*
|
|
128
|
+
* @param {string} html The HTML string to process.
|
|
129
|
+
* @param {URLParametersConfig} [options] A configuration object for `posthtml-url-parameters`.
|
|
130
|
+
* @returns {string} The processed HTML string.
|
|
131
|
+
* @see https://maizzle.com/docs/transformers/url-parameters
|
|
132
|
+
*/
|
|
133
|
+
addUrlParams: typeof addUrlParams;
|
|
134
|
+
/**
|
|
135
|
+
* Ensure that all HEX colors inside `bgcolor` and `color` attributes are defined with six digits.
|
|
136
|
+
*
|
|
137
|
+
* @param {string} html The HTML string to process.
|
|
138
|
+
* @returns {string} The processed HTML string.
|
|
139
|
+
* @see https://maizzle.com/docs/transformers/six-hex
|
|
140
|
+
*/
|
|
141
|
+
sixHEX: typeof sixHEX;
|
|
142
|
+
/**
|
|
143
|
+
* Minify an HTML string, with email client considerations.
|
|
144
|
+
*
|
|
145
|
+
* @param {string} html The HTML string to minify.
|
|
146
|
+
* @param {MinifyConfig} [options] A configuration object for `html-minifier`.
|
|
147
|
+
* @returns {string} The minified HTML string.
|
|
148
|
+
* @see https://maizzle.com/docs/transformers/minify
|
|
149
|
+
*/
|
|
150
|
+
minify: typeof minify;
|
|
151
|
+
/**
|
|
152
|
+
* Batch-replace strings in an HTML string.
|
|
153
|
+
*
|
|
154
|
+
* @param {string} html The HTML string to process.
|
|
155
|
+
* @param {Record<string, string>} [replacements] A dictionary of strings to replace.
|
|
156
|
+
* @returns {string} The processed HTML string.
|
|
157
|
+
* @see https://maizzle.com/docs/transformers/replace-strings
|
|
158
|
+
*/
|
|
159
|
+
replaceStrings: typeof replaceStrings;
|
|
160
|
+
/**
|
|
161
|
+
* Generate a plaintext version of an HTML string.
|
|
162
|
+
* @param {string} html - The HTML string to convert to plaintext.
|
|
163
|
+
* @param {PlaintextConfig} [options] - A configuration object for the plaintext generator.
|
|
164
|
+
* @returns {Promise<string>} The plaintext version of the HTML string.
|
|
165
|
+
* @see https://maizzle.com/docs/plaintext
|
|
166
|
+
*/
|
|
167
|
+
plaintext: typeof plaintext;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export default interface Events {
|
|
171
|
+
/**
|
|
172
|
+
* Runs after the Environment config has been computed, but before Templates are processed.
|
|
173
|
+
* Exposes the `config` object so you can further customize it.
|
|
174
|
+
*
|
|
175
|
+
* @default undefined
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```
|
|
179
|
+
* export default {
|
|
180
|
+
* beforeCreate: async ({config}) => {
|
|
181
|
+
* // do something with `config`
|
|
182
|
+
* }
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
beforeCreate?: (params: { config: Config }) => void | Promise<void>;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Runs after the Template's config has been computed, but just before it is compiled.
|
|
190
|
+
*
|
|
191
|
+
* Must return the `html` string, otherwise the original will be used.
|
|
192
|
+
*
|
|
193
|
+
* @default undefined
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```
|
|
197
|
+
* export default {
|
|
198
|
+
* beforeRender: async ({html, matter, config, posthtml, transform}) => {
|
|
199
|
+
* // do something...
|
|
200
|
+
* return html;
|
|
201
|
+
* }
|
|
202
|
+
* }
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
beforeRender?: (params: {
|
|
206
|
+
/**
|
|
207
|
+
* The Template's HTML string.
|
|
208
|
+
*/
|
|
209
|
+
html: string;
|
|
210
|
+
/**
|
|
211
|
+
* The Template's Front Matter.
|
|
212
|
+
*/
|
|
213
|
+
matter: { [key: string]: string };
|
|
214
|
+
/**
|
|
215
|
+
* The Template's computed config.
|
|
216
|
+
*/
|
|
217
|
+
config: Config;
|
|
218
|
+
/**
|
|
219
|
+
* A function to process an HTML string with PostHTML.
|
|
220
|
+
*
|
|
221
|
+
* @param {string} html The HTML string to process.
|
|
222
|
+
* @param {Config} config The Maizzle config object.
|
|
223
|
+
*/
|
|
224
|
+
posthtml: PostHTMLType;
|
|
225
|
+
/**
|
|
226
|
+
* A collection of Maizzle Transformers.
|
|
227
|
+
*/
|
|
228
|
+
transform: TransformType;
|
|
229
|
+
}) => string | Promise<string>;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Runs after the Template has been compiled, but before any Transformers have been applied.
|
|
233
|
+
*
|
|
234
|
+
* Must return the `html` string, otherwise the original will be used.
|
|
235
|
+
*
|
|
236
|
+
* @default undefined
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```
|
|
240
|
+
* export default {
|
|
241
|
+
* afterRender: async async ({html, matter, config, posthtml, transform}) => {
|
|
242
|
+
* // do something...
|
|
243
|
+
* return html;
|
|
244
|
+
* }
|
|
245
|
+
* }
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
afterRender?: (params: {
|
|
249
|
+
/**
|
|
250
|
+
* The Template's HTML string.
|
|
251
|
+
*/
|
|
252
|
+
html: string;
|
|
253
|
+
/**
|
|
254
|
+
* The Template's Front Matter.
|
|
255
|
+
*/
|
|
256
|
+
matter: { [key: string]: string };
|
|
257
|
+
/**
|
|
258
|
+
* The Template's computed config.
|
|
259
|
+
*/
|
|
260
|
+
config: Config;
|
|
261
|
+
/**
|
|
262
|
+
* A function to process an HTML string with PostHTML.
|
|
263
|
+
*
|
|
264
|
+
* @param {string} html The HTML string to process.
|
|
265
|
+
* @param {Config} config The Maizzle config object.
|
|
266
|
+
*/
|
|
267
|
+
posthtml: PostHTMLType;
|
|
268
|
+
/**
|
|
269
|
+
* A collection of Maizzle Transformers.
|
|
270
|
+
*/
|
|
271
|
+
transform: TransformType;
|
|
272
|
+
}) => string | Promise<string>;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Runs after all Transformers have been applied, just before the final HTML is returned.
|
|
276
|
+
*
|
|
277
|
+
* Must return the `html` string, otherwise the original will be used.
|
|
278
|
+
*
|
|
279
|
+
* @default undefined
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```
|
|
283
|
+
* export default {
|
|
284
|
+
* afterTransformers: async ({html, matter, config, posthtml, transform}) => {
|
|
285
|
+
* // do something...
|
|
286
|
+
* return html;
|
|
287
|
+
* }
|
|
288
|
+
* }
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
afterTransformers?: (params: {
|
|
292
|
+
/**
|
|
293
|
+
* The Template's HTML string.
|
|
294
|
+
*/
|
|
295
|
+
html: string;
|
|
296
|
+
/**
|
|
297
|
+
* The Template's Front Matter.
|
|
298
|
+
*/
|
|
299
|
+
matter: { [key: string]: string };
|
|
300
|
+
/**
|
|
301
|
+
* The Template's computed config.
|
|
302
|
+
*/
|
|
303
|
+
config: Config;
|
|
304
|
+
/**
|
|
305
|
+
* A function to process an HTML string with PostHTML.
|
|
306
|
+
*
|
|
307
|
+
* @param {string} html The HTML string to process.
|
|
308
|
+
* @param {Config} config The Maizzle config object.
|
|
309
|
+
*/
|
|
310
|
+
posthtml: PostHTMLType;
|
|
311
|
+
/**
|
|
312
|
+
* A collection of Maizzle Transformers.
|
|
313
|
+
*/
|
|
314
|
+
transform: TransformType;
|
|
315
|
+
}) => string | Promise<string>;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Runs after all Templates have been compiled and output to disk.
|
|
319
|
+
* `files` will contain the paths to all the files inside the `build.output.path` directory.
|
|
320
|
+
*
|
|
321
|
+
* @default undefined
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```
|
|
325
|
+
* export default {
|
|
326
|
+
* afterBuild: async ({files, config, transform}) => {
|
|
327
|
+
* // do something...
|
|
328
|
+
* }
|
|
329
|
+
* }
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
afterBuild?: (params: {
|
|
333
|
+
/**
|
|
334
|
+
* An array of paths to all the files inside the `build.output.path` directory.
|
|
335
|
+
*/
|
|
336
|
+
files: string[];
|
|
337
|
+
/**
|
|
338
|
+
* The Maizzle config object.
|
|
339
|
+
*/
|
|
340
|
+
config: Config;
|
|
341
|
+
/**
|
|
342
|
+
* A collection of Maizzle Transformers.
|
|
343
|
+
*/
|
|
344
|
+
transform: TransformType;
|
|
345
|
+
}) => string | Promise<string>;
|
|
346
|
+
}
|