@maizzle/framework 5.0.0-beta.8 → 5.0.0
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 +33 -31
- package/src/commands/build.js +106 -30
- package/src/generators/plaintext.js +22 -18
- package/src/generators/render.js +16 -18
- package/src/index.js +3 -3
- package/src/posthtml/defaultComponentsConfig.js +10 -2
- package/src/posthtml/defaultConfig.js +13 -3
- package/src/posthtml/index.js +59 -14
- package/src/server/index.js +171 -98
- package/src/server/routes/index.js +51 -13
- package/src/server/views/404.html +59 -0
- package/src/server/views/index.html +162 -14
- package/src/transformers/addAttributes.js +2 -3
- package/src/transformers/attributeToStyle.js +1 -3
- package/src/transformers/baseUrl.js +6 -6
- package/src/transformers/filters/index.js +1 -2
- package/src/transformers/index.js +57 -95
- package/src/transformers/inline.js +44 -48
- package/src/transformers/markdown.js +14 -7
- package/src/transformers/minify.js +4 -3
- package/src/transformers/posthtmlMso.js +1 -3
- package/src/transformers/prettify.js +4 -3
- package/src/transformers/preventWidows.js +15 -65
- package/src/transformers/{comb.js → purge.js} +9 -8
- package/src/transformers/removeAttributes.js +3 -4
- package/src/transformers/replaceStrings.js +7 -5
- package/src/transformers/safeClassNames.js +1 -2
- package/src/transformers/shorthandCss.js +1 -3
- package/src/transformers/sixHex.js +1 -3
- package/src/transformers/template.js +9 -9
- package/src/transformers/urlParameters.js +1 -3
- package/src/transformers/useAttributeSizes.js +1 -3
- package/src/utils/getConfigByFilePath.js +10 -0
- package/src/utils/node.js +0 -23
- package/src/utils/string.js +34 -12
- package/types/build.d.ts +51 -28
- package/types/config.d.ts +127 -64
- package/types/css/inline.d.ts +10 -26
- package/types/css/purge.d.ts +3 -3
- package/types/events.d.ts +153 -5
- package/types/index.d.ts +4 -3
- package/types/posthtml.d.ts +3 -3
- package/types/urlParameters.d.ts +1 -1
- package/types/widowWords.d.ts +16 -36
- package/types/components.d.ts +0 -195
- package/types/expressions.d.ts +0 -100
|
@@ -4,21 +4,169 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Maizzle | Templates</title>
|
|
7
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
8
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
9
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet" media="screen">
|
|
10
|
+
<style>
|
|
11
|
+
body {
|
|
12
|
+
padding: 7rem 6.25rem;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@media (max-width: 425px) {
|
|
16
|
+
body {
|
|
17
|
+
padding: 3rem 1.5rem;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* General styling */
|
|
22
|
+
ul {
|
|
23
|
+
margin: 0;
|
|
24
|
+
padding: 0;
|
|
25
|
+
list-style-type: none;
|
|
26
|
+
font-family: Inter, Arial, Helvetica, sans-serif;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Folder styling */
|
|
30
|
+
li > strong {
|
|
31
|
+
font-size: 1.875rem;
|
|
32
|
+
line-height: 2.25rem;
|
|
33
|
+
color: #0F172A;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
li.folder.root {
|
|
37
|
+
padding-bottom: 1.5rem;
|
|
38
|
+
padding-top: 3rem;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
li.folder.root:first-child {
|
|
42
|
+
padding-top: 0 !important;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
li.folder.nested {
|
|
46
|
+
padding-top: 1.5rem;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
li.folder.nested > strong {
|
|
50
|
+
font-size: 1.25rem;
|
|
51
|
+
line-height: 1.75rem;
|
|
52
|
+
font-weight: 600;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
li > strong > span {
|
|
56
|
+
color: #94A3B8;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* File styling */
|
|
60
|
+
li > a {
|
|
61
|
+
color: #4f46e5;
|
|
62
|
+
text-decoration: none;
|
|
63
|
+
font-size: 1.25rem;
|
|
64
|
+
line-height: 1.75rem;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
li > a:hover {
|
|
68
|
+
text-decoration: underline;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Indentation based on depth */
|
|
72
|
+
li {
|
|
73
|
+
padding-left: 1.5rem;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
li.folder.nested {
|
|
77
|
+
padding-top: 2.25rem;
|
|
78
|
+
padding-bottom: 0.625rem;
|
|
79
|
+
border-left: 1px solid #64748B;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
li.folder.nested > strong {
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
display: block;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
li.folder.root {
|
|
88
|
+
padding-top: 3rem;
|
|
89
|
+
border: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
li.file {
|
|
93
|
+
border-left: 1px solid #64748B;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
li.file.nested {
|
|
97
|
+
line-height: 2.25rem;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
li.file.nested.collapsed {
|
|
101
|
+
display: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
li.file.nested.collapsed + .folder.nested {
|
|
105
|
+
padding-top: 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
li.file.nested a {
|
|
110
|
+
padding-bottom: 0.75rem;
|
|
111
|
+
margin-left: -1.5rem;
|
|
112
|
+
padding-left: 1.5rem;
|
|
113
|
+
border-left: 1px solid #cbd5e1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
li.file.nested:last-child a {
|
|
117
|
+
padding-bottom: 0;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.insignia {
|
|
121
|
+
width: 64rem;
|
|
122
|
+
position: fixed;
|
|
123
|
+
z-index: -1;
|
|
124
|
+
right: -3rem;
|
|
125
|
+
bottom: 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@media (max-width: 425px) {
|
|
129
|
+
.insignia {
|
|
130
|
+
width: 100%;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
</style>
|
|
7
134
|
</head>
|
|
8
135
|
<body>
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
136
|
+
<ul>
|
|
137
|
+
<each loop="item in paths">
|
|
138
|
+
<if condition="item.type === 'folder'">
|
|
139
|
+
<li
|
|
140
|
+
style="padding-left: calc(1.5rem * {{ item.depth }});"
|
|
141
|
+
class="folder {{ item.depth > 0 ? 'nested' : 'root' }}"
|
|
142
|
+
>
|
|
143
|
+
<strong>{{{ item.name }}}</strong>
|
|
144
|
+
</li>
|
|
145
|
+
</if>
|
|
146
|
+
<if condition="item.type === 'file'">
|
|
147
|
+
<li
|
|
148
|
+
style="padding-left: calc(1.5rem * {{ item.depth }});"
|
|
149
|
+
class="file {{ item.depth > 1 ? 'nested' : '' }}"
|
|
150
|
+
>
|
|
151
|
+
<a href="{{ item.href }}">
|
|
152
|
+
{{ item.name }}
|
|
153
|
+
</a>
|
|
154
|
+
</li>
|
|
155
|
+
</if>
|
|
156
|
+
</each>
|
|
157
|
+
</ul>
|
|
158
|
+
|
|
159
|
+
<svg fill="none" stroke="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 993 483" class="insignia"><mask id="a" style="mask-type:alpha;" maskUnits="userSpaceOnUse" x="0" y="0" width="993" height="483"><path fill="#D9D9D9" d="M0 0h993v483H0z"></path></mask><g mask="url(#a)" stroke="#e2e8f0" stroke-miterlimit="10"><path d="M954.124 81.816c0-45.163-39.678-81.774-88.624-81.774-48.945 0-88.624 36.611-88.624 81.774v436.13c0 45.163 39.679 81.775 88.624 81.775 48.946 0 88.624-36.612 88.624-81.775V81.816ZM583.379 81.816c0-45.163-39.678-81.774-88.624-81.774-48.945 0-88.624 36.611-88.624 81.774v436.13c0 45.163 39.679 81.775 88.624 81.775 48.946 0 88.624-36.612 88.624-81.775V81.816Z"></path><path d="M935.39 132.185c30.161-35.57 23.362-86.965-15.187-114.795S825.954-4.165 795.794 31.404L425.713 467.848c-30.161 35.57-23.361 86.965 15.187 114.795 38.549 27.829 94.249 21.555 124.41-14.014l370.08-436.444ZM564.288 132.196c30.161-35.569 23.362-86.964-15.187-114.794S454.852-4.154 424.692 31.416L54.611 467.86c-30.16 35.569-23.361 86.965 15.187 114.794 38.549 27.83 94.249 21.556 124.41-14.013l370.08-436.445Z"></path></g></svg>
|
|
160
|
+
<script>
|
|
161
|
+
document.querySelectorAll('.folder.nested').forEach(folder => {
|
|
162
|
+
folder.addEventListener('click', function() {
|
|
163
|
+
let nextElement = this.nextElementSibling;
|
|
164
|
+
while (nextElement && nextElement.classList.contains('file') && nextElement.classList.contains('nested')) {
|
|
165
|
+
nextElement.classList.toggle('collapsed');
|
|
166
|
+
nextElement = nextElement.nextElementSibling;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
</script>
|
|
23
171
|
</body>
|
|
24
172
|
</html>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import posthtml from 'posthtml'
|
|
2
2
|
import { defu as merge } from 'defu'
|
|
3
|
-
import posthtmlConfig from '../posthtml/defaultConfig.js'
|
|
4
3
|
import addAttributesPlugin from 'posthtml-extra-attributes'
|
|
5
4
|
|
|
6
5
|
export default function posthtmlPlugin(attributes = {}) {
|
|
@@ -11,7 +10,7 @@ export default function posthtmlPlugin(attributes = {}) {
|
|
|
11
10
|
role: 'none'
|
|
12
11
|
},
|
|
13
12
|
img: {
|
|
14
|
-
alt:
|
|
13
|
+
alt: true,
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
|
|
@@ -25,6 +24,6 @@ export async function addAttributes(html = '', attributes = {}, posthtmlOptions
|
|
|
25
24
|
return posthtml([
|
|
26
25
|
posthtmlPlugin(attributes)
|
|
27
26
|
])
|
|
28
|
-
.process(html,
|
|
27
|
+
.process(html, posthtmlOptions)
|
|
29
28
|
.then(result => result.html)
|
|
30
29
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import posthtml from 'posthtml'
|
|
2
2
|
import get from 'lodash-es/get.js'
|
|
3
|
-
import { defu as merge } from 'defu'
|
|
4
3
|
import keys from 'lodash-es/keys.js'
|
|
5
4
|
import forEach from 'lodash-es/forEach.js'
|
|
6
5
|
import parseAttrs from 'posthtml-attrs-parser'
|
|
7
6
|
import intersection from 'lodash-es/intersection.js'
|
|
8
|
-
import posthtmlConfig from '../posthtml/defaultConfig.js'
|
|
9
7
|
|
|
10
8
|
const posthtmlPlugin = (attributes = []) => tree => {
|
|
11
9
|
if (!Array.isArray(attributes)) {
|
|
@@ -87,6 +85,6 @@ export async function attributeToStyle(html = '', attributes = [], posthtmlOptio
|
|
|
87
85
|
return posthtml([
|
|
88
86
|
posthtmlPlugin(attributes)
|
|
89
87
|
])
|
|
90
|
-
.process(html,
|
|
88
|
+
.process(html, posthtmlOptions)
|
|
91
89
|
.then(result => result.html)
|
|
92
90
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import posthtml from 'posthtml'
|
|
2
2
|
import isUrl from 'is-url-superb'
|
|
3
3
|
import get from 'lodash-es/get.js'
|
|
4
|
-
import { defu as merge } from 'defu'
|
|
5
4
|
import baseUrl from 'posthtml-base-url'
|
|
6
5
|
import { render } from 'posthtml-render'
|
|
7
6
|
import isEmpty from 'lodash-es/isEmpty.js'
|
|
8
7
|
import isObject from 'lodash-es/isObject.js'
|
|
9
8
|
import { parser as parse } from 'posthtml-parser'
|
|
10
|
-
import
|
|
9
|
+
import { getPosthtmlOptions } from '../posthtml/defaultConfig.js'
|
|
10
|
+
|
|
11
|
+
const posthtmlOptions = getPosthtmlOptions()
|
|
11
12
|
|
|
12
13
|
const posthtmlPlugin = url => tree => {
|
|
13
14
|
// Handle `baseURL` as a string
|
|
@@ -19,7 +20,7 @@ const posthtmlPlugin = url => tree => {
|
|
|
19
20
|
allTags: true,
|
|
20
21
|
styleTag: true,
|
|
21
22
|
inlineCss: true
|
|
22
|
-
})(parse(html,
|
|
23
|
+
})(parse(html, posthtmlOptions))
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
// Handle `baseURL` as an object
|
|
@@ -31,7 +32,6 @@ const posthtmlPlugin = url => tree => {
|
|
|
31
32
|
allTags,
|
|
32
33
|
tags,
|
|
33
34
|
url: baseURL,
|
|
34
|
-
...posthtmlOptions
|
|
35
35
|
} = url
|
|
36
36
|
|
|
37
37
|
return baseUrl({
|
|
@@ -40,7 +40,7 @@ const posthtmlPlugin = url => tree => {
|
|
|
40
40
|
allTags,
|
|
41
41
|
tags,
|
|
42
42
|
url: baseURL,
|
|
43
|
-
})(parse(html,
|
|
43
|
+
})(parse(html, posthtmlOptions))
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
return tree
|
|
@@ -52,7 +52,7 @@ export async function addBaseUrl(html = '', options = {}, posthtmlOptions = {})
|
|
|
52
52
|
return posthtml([
|
|
53
53
|
posthtmlPlugin(options)
|
|
54
54
|
])
|
|
55
|
-
.process(html,
|
|
55
|
+
.process(html, getPosthtmlOptions())
|
|
56
56
|
.then(result => result.html)
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import posthtml from 'posthtml'
|
|
2
2
|
import { defu as merge } from 'defu'
|
|
3
3
|
import posthtmlContent from 'posthtml-content'
|
|
4
|
-
import posthtmlConfig from '../../posthtml/defaultConfig.js'
|
|
5
4
|
import { filters as defaultFilters } from './defaultFilters.js'
|
|
6
5
|
|
|
7
6
|
export default function posthtmlPlugin(filters = {}) {
|
|
@@ -14,6 +13,6 @@ export async function filters(html = '', filters = {}, posthtmlOptions = {}) {
|
|
|
14
13
|
return posthtml([
|
|
15
14
|
posthtmlPlugin(filters)
|
|
16
15
|
])
|
|
17
|
-
.process(html,
|
|
16
|
+
.process(html, posthtmlOptions)
|
|
18
17
|
.then(result => result.html)
|
|
19
18
|
}
|
|
@@ -2,7 +2,8 @@ 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
|
|
5
|
+
import core from './core.js'
|
|
6
|
+
import purge from './purge.js'
|
|
6
7
|
import sixHex from './sixHex.js'
|
|
7
8
|
import minify from './minify.js'
|
|
8
9
|
import baseUrl from './baseUrl.js'
|
|
@@ -21,41 +22,36 @@ import replaceStrings from './replaceStrings.js'
|
|
|
21
22
|
import attributeToStyle from './attributeToStyle.js'
|
|
22
23
|
import removeAttributes from './removeAttributes.js'
|
|
23
24
|
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
import defaultPosthtmlConfig from '../posthtml/defaultConfig.js'
|
|
25
|
+
import { getPosthtmlOptions } 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
|
|
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<{
|
|
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 = []
|
|
40
39
|
|
|
41
|
-
const posthtmlConfig =
|
|
42
|
-
get(config, 'posthtml.options', {}),
|
|
43
|
-
defaultPosthtmlConfig
|
|
44
|
-
)
|
|
40
|
+
const posthtmlConfig = getPosthtmlOptions(get(config, 'posthtml.options', {}))
|
|
45
41
|
|
|
46
42
|
/**
|
|
47
43
|
* 1. Core transformers
|
|
48
44
|
*
|
|
49
|
-
* Transformers that are always enabled
|
|
45
|
+
* Transformers that are always enabled.
|
|
50
46
|
*
|
|
51
47
|
*/
|
|
52
|
-
posthtmlPlugins.push(
|
|
48
|
+
posthtmlPlugins.push(core(config))
|
|
53
49
|
|
|
54
50
|
/**
|
|
55
51
|
* 2. Safe class names
|
|
56
52
|
*
|
|
57
53
|
* Rewrite Tailwind CSS class names to email-safe alternatives,
|
|
58
|
-
* unless explicitly disabled
|
|
54
|
+
* unless explicitly disabled.
|
|
59
55
|
*/
|
|
60
56
|
if (get(config, 'css.safe') !== false) {
|
|
61
57
|
posthtmlPlugins.push(
|
|
@@ -66,7 +62,6 @@ export async function run(html = '', config = {}) {
|
|
|
66
62
|
/**
|
|
67
63
|
* 3. Filters
|
|
68
64
|
*
|
|
69
|
-
* Apply filters to HTML.
|
|
70
65
|
* Filters are always applied, unless explicitly disabled.
|
|
71
66
|
*/
|
|
72
67
|
if (get(config, 'filters') !== false) {
|
|
@@ -78,7 +73,7 @@ export async function run(html = '', config = {}) {
|
|
|
78
73
|
/**
|
|
79
74
|
* 4. Markdown
|
|
80
75
|
*
|
|
81
|
-
* Convert Markdown to HTML with
|
|
76
|
+
* Convert Markdown to HTML with markdown-it, unless explicitly disabled.
|
|
82
77
|
*/
|
|
83
78
|
if (get(config, 'markdown') !== false) {
|
|
84
79
|
posthtmlPlugins.push(
|
|
@@ -88,7 +83,9 @@ export async function run(html = '', config = {}) {
|
|
|
88
83
|
|
|
89
84
|
/**
|
|
90
85
|
* 5. Prevent widow words
|
|
91
|
-
*
|
|
86
|
+
*
|
|
87
|
+
* Enabled by default, will prevent widow words in elements
|
|
88
|
+
* wrapped with a `prevent-widows` attribute.
|
|
92
89
|
*/
|
|
93
90
|
if (get(config, 'widowWords') !== false) {
|
|
94
91
|
posthtmlPlugins.push(
|
|
@@ -110,7 +107,7 @@ export async function run(html = '', config = {}) {
|
|
|
110
107
|
/**
|
|
111
108
|
* 7. Inline CSS
|
|
112
109
|
*
|
|
113
|
-
* Inline CSS into HTML
|
|
110
|
+
* Inline CSS into HTML.
|
|
114
111
|
*/
|
|
115
112
|
if (get(config, 'css.inline')) {
|
|
116
113
|
posthtmlPlugins.push(inlineCSS(
|
|
@@ -124,16 +121,7 @@ export async function run(html = '', config = {}) {
|
|
|
124
121
|
}
|
|
125
122
|
|
|
126
123
|
/**
|
|
127
|
-
* 8.
|
|
128
|
-
*
|
|
129
|
-
* Remove unused CSS, uglify classes etc.
|
|
130
|
-
*/
|
|
131
|
-
if (get(config, 'css.purge')) {
|
|
132
|
-
posthtmlPlugins.push(comb(config.css.purge))
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* 9. Remove attributes
|
|
124
|
+
* 8. Remove attributes
|
|
137
125
|
*
|
|
138
126
|
* Remove attributes from HTML tags
|
|
139
127
|
* If `undefined`, removes empty `style` and `class` attributes
|
|
@@ -148,9 +136,9 @@ export async function run(html = '', config = {}) {
|
|
|
148
136
|
}
|
|
149
137
|
|
|
150
138
|
/**
|
|
151
|
-
*
|
|
139
|
+
* 9. Shorthand CSS
|
|
152
140
|
*
|
|
153
|
-
* Convert longhand CSS properties to shorthand in `style` attributes
|
|
141
|
+
* Convert longhand CSS properties to shorthand in `style` attributes.
|
|
154
142
|
*/
|
|
155
143
|
if (get(config, 'css.shorthand')) {
|
|
156
144
|
posthtmlPlugins.push(
|
|
@@ -159,9 +147,9 @@ export async function run(html = '', config = {}) {
|
|
|
159
147
|
}
|
|
160
148
|
|
|
161
149
|
/**
|
|
162
|
-
*
|
|
150
|
+
* 10. Add attributes
|
|
163
151
|
*
|
|
164
|
-
* Add attributes to HTML tags
|
|
152
|
+
* Add attributes to HTML tags.
|
|
165
153
|
*/
|
|
166
154
|
if (get(config, 'attributes.add') !== false) {
|
|
167
155
|
posthtmlPlugins.push(
|
|
@@ -170,35 +158,21 @@ export async function run(html = '', config = {}) {
|
|
|
170
158
|
}
|
|
171
159
|
|
|
172
160
|
/**
|
|
173
|
-
*
|
|
161
|
+
* 11. Base URL
|
|
174
162
|
*
|
|
175
|
-
* Add a base URL to relative paths
|
|
163
|
+
* Add a base URL to relative paths.
|
|
176
164
|
*/
|
|
177
|
-
|
|
165
|
+
const baseConfig = get(config, 'baseURL', get(config, 'baseUrl'))
|
|
166
|
+
if (baseConfig) {
|
|
178
167
|
posthtmlPlugins.push(
|
|
179
|
-
baseUrl(
|
|
168
|
+
baseUrl(baseConfig)
|
|
180
169
|
)
|
|
181
|
-
} else {
|
|
182
|
-
/**
|
|
183
|
-
* Set baseURL to `build.static.destination` if it's not already set
|
|
184
|
-
*/
|
|
185
|
-
const destination = get(config, 'build.static.destination', '')
|
|
186
|
-
if (destination && !config._dev) {
|
|
187
|
-
posthtmlPlugins.push(
|
|
188
|
-
baseUrl({
|
|
189
|
-
url: destination,
|
|
190
|
-
allTags: true,
|
|
191
|
-
styleTag: true,
|
|
192
|
-
inlineCss: true,
|
|
193
|
-
})
|
|
194
|
-
)
|
|
195
|
-
}
|
|
196
170
|
}
|
|
197
171
|
|
|
198
172
|
/**
|
|
199
|
-
*
|
|
173
|
+
* 12. URL parameters
|
|
200
174
|
*
|
|
201
|
-
* Add parameters to URLs
|
|
175
|
+
* Add parameters to URLs.
|
|
202
176
|
*/
|
|
203
177
|
if (get(config, 'urlParameters')) {
|
|
204
178
|
posthtmlPlugins.push(
|
|
@@ -207,10 +181,9 @@ export async function run(html = '', config = {}) {
|
|
|
207
181
|
}
|
|
208
182
|
|
|
209
183
|
/**
|
|
210
|
-
*
|
|
184
|
+
* 13. Six-digit HEX
|
|
211
185
|
*
|
|
212
|
-
*
|
|
213
|
-
* Always runs, unless explicitly disabled
|
|
186
|
+
* Enabled by default, converts three-digit HEX colors to six-digit.
|
|
214
187
|
*/
|
|
215
188
|
if (get(config, 'css.sixHex') !== false) {
|
|
216
189
|
posthtmlPlugins.push(
|
|
@@ -219,9 +192,9 @@ export async function run(html = '', config = {}) {
|
|
|
219
192
|
}
|
|
220
193
|
|
|
221
194
|
/**
|
|
222
|
-
*
|
|
195
|
+
* 14. PostHTML MSO
|
|
223
196
|
*
|
|
224
|
-
*
|
|
197
|
+
* Enabled by default, simplifies writing MSO conditionals for Outlook.
|
|
225
198
|
*/
|
|
226
199
|
if (get(config, 'outlook') !== false) {
|
|
227
200
|
posthtmlPlugins.push(
|
|
@@ -230,42 +203,51 @@ export async function run(html = '', config = {}) {
|
|
|
230
203
|
}
|
|
231
204
|
|
|
232
205
|
/**
|
|
233
|
-
*
|
|
206
|
+
* 15. Purge CSS
|
|
234
207
|
*
|
|
235
|
-
*
|
|
208
|
+
* Remove unused CSS, uglify classes etc.
|
|
236
209
|
*/
|
|
237
|
-
if (get(config, '
|
|
238
|
-
posthtmlPlugins.push(
|
|
239
|
-
prettify(get(config, 'prettify', {}))
|
|
240
|
-
)
|
|
210
|
+
if (get(config, 'css.purge')) {
|
|
211
|
+
posthtmlPlugins.push(purge(config.css.purge))
|
|
241
212
|
}
|
|
242
213
|
|
|
243
214
|
/**
|
|
244
|
-
*
|
|
215
|
+
* 16. <template> tags
|
|
245
216
|
*
|
|
246
|
-
*
|
|
217
|
+
* Replace <template> tags with their content.
|
|
247
218
|
*/
|
|
248
|
-
|
|
219
|
+
posthtmlPlugins.push(templateTag())
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* 17. Replace strings
|
|
223
|
+
*
|
|
224
|
+
* Replace strings through regular expressions.
|
|
225
|
+
*/
|
|
226
|
+
if (get(config, 'replaceStrings')) {
|
|
249
227
|
posthtmlPlugins.push(
|
|
250
|
-
|
|
228
|
+
replaceStrings(get(config, 'replaceStrings', {}))
|
|
251
229
|
)
|
|
252
230
|
}
|
|
253
231
|
|
|
254
232
|
/**
|
|
255
|
-
* 18.
|
|
233
|
+
* 18. Prettify
|
|
256
234
|
*
|
|
257
|
-
*
|
|
235
|
+
* Pretty-print HTML using js-beautify.
|
|
258
236
|
*/
|
|
259
|
-
|
|
237
|
+
if (get(config, 'prettify')) {
|
|
238
|
+
posthtmlPlugins.push(
|
|
239
|
+
prettify(get(config, 'prettify', {}))
|
|
240
|
+
)
|
|
241
|
+
}
|
|
260
242
|
|
|
261
243
|
/**
|
|
262
|
-
* 19.
|
|
244
|
+
* 19. Minify
|
|
263
245
|
*
|
|
264
|
-
*
|
|
246
|
+
* Minify HTML using html-crush.
|
|
265
247
|
*/
|
|
266
|
-
if (get(config, '
|
|
248
|
+
if (get(config, 'minify')) {
|
|
267
249
|
posthtmlPlugins.push(
|
|
268
|
-
|
|
250
|
+
minify(get(config, 'minify', {}))
|
|
269
251
|
)
|
|
270
252
|
}
|
|
271
253
|
|
|
@@ -275,23 +257,3 @@ export async function run(html = '', config = {}) {
|
|
|
275
257
|
html: result.html,
|
|
276
258
|
}))
|
|
277
259
|
}
|
|
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
|
-
}
|