@maizzle/framework 5.0.0-beta.22 → 5.0.0-beta.24
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 +8 -8
- package/src/commands/build.js +6 -3
- package/src/generators/plaintext.js +19 -15
- package/src/generators/render.js +7 -7
- package/src/posthtml/index.js +2 -2
- package/src/server/index.js +2 -2
- package/src/server/routes/index.js +51 -13
- package/src/server/views/index.html +137 -14
- package/src/transformers/inline.js +7 -2
- package/src/transformers/prettify.js +2 -1
- package/src/transformers/template.js +9 -9
- package/types/build.d.ts +0 -6
- package/types/config.d.ts +9 -4
- package/types/css/inline.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maizzle/framework",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.24",
|
|
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",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"html-emails"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@csstools/css-calc": "^
|
|
51
|
+
"@csstools/css-calc": "^2.0.1",
|
|
52
52
|
"@maizzle/cli": "next",
|
|
53
|
-
"cheerio": "1.0.0
|
|
53
|
+
"cheerio": "^1.0.0",
|
|
54
54
|
"chokidar": "^3.6.0",
|
|
55
55
|
"cli-table3": "^0.6.5",
|
|
56
56
|
"color-shorthand-hex-to-six-digit": "^5.0.16",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"html-crush": "^6.0.18",
|
|
63
63
|
"is-url-superb": "^6.1.0",
|
|
64
64
|
"istextorbinary": "^9.5.0",
|
|
65
|
-
"juice": "^
|
|
65
|
+
"juice": "^11.0.0",
|
|
66
66
|
"lodash-es": "^4.17.21",
|
|
67
67
|
"morphdom": "^2.7.4",
|
|
68
|
-
"ora": "^8.0
|
|
68
|
+
"ora": "^8.1.0",
|
|
69
69
|
"pathe": "^1.1.2",
|
|
70
70
|
"postcss": "^8.4.39",
|
|
71
|
-
"postcss-custom-properties": "^
|
|
71
|
+
"postcss-custom-properties": "^14.0.1",
|
|
72
72
|
"postcss-import": "^16.1.0",
|
|
73
73
|
"postcss-safe-parser": "^7.0.0",
|
|
74
74
|
"posthtml": "^0.16.6",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"pretty": "^2.0.0",
|
|
91
91
|
"string-remove-widows": "^4.0.22",
|
|
92
92
|
"string-strip-html": "^13.4.8",
|
|
93
|
-
"tailwindcss": "^3.4.
|
|
93
|
+
"tailwindcss": "^3.4.10",
|
|
94
94
|
"ws": "^8.17.0"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
@@ -102,6 +102,6 @@
|
|
|
102
102
|
"vitest": "^2.0.1"
|
|
103
103
|
},
|
|
104
104
|
"engines": {
|
|
105
|
-
"node": ">=18.
|
|
105
|
+
"node": ">=18.20"
|
|
106
106
|
}
|
|
107
107
|
}
|
package/src/commands/build.js
CHANGED
|
@@ -221,12 +221,15 @@ export default async (config = {}) => {
|
|
|
221
221
|
if (Boolean(plaintextConfig) || !isEmpty(plaintextConfig)) {
|
|
222
222
|
const posthtmlOptions = get(rendered.config, 'posthtml.options', {})
|
|
223
223
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
await writePlaintextFile(
|
|
225
|
+
await generatePlaintext(rendered.html, merge(plaintextConfig, posthtmlOptions)),
|
|
226
|
+
rendered.config
|
|
227
|
+
)
|
|
227
228
|
.catch(error => {
|
|
228
229
|
throw new Error(`Error writing plaintext file: ${error}`)
|
|
229
230
|
})
|
|
231
|
+
|
|
232
|
+
rendered.html = await handlePlaintextTags(rendered.html, posthtmlOptions)
|
|
230
233
|
}
|
|
231
234
|
|
|
232
235
|
/**
|
|
@@ -154,17 +154,11 @@ export async function writePlaintextFile(plaintext = '', config = {}) {
|
|
|
154
154
|
const plaintextExtension = get(plaintextConfig, 'output.extension', 'txt')
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
|
-
* If `plaintext: true` (either from Front Matter or from config)
|
|
157
|
+
* If `plaintext: true` (either from Front Matter or from config),
|
|
158
|
+
* output plaintext file in the same location as the HTML file.
|
|
158
159
|
*/
|
|
159
160
|
if (plaintextConfig === true) {
|
|
160
|
-
|
|
161
|
-
if (typeof config.permalink === 'string') {
|
|
162
|
-
// Output plaintext at the `permalink` path
|
|
163
|
-
plaintextOutputPath = config.permalink
|
|
164
|
-
} else {
|
|
165
|
-
// Output plaintext at the same directory as the HTML file
|
|
166
|
-
plaintextOutputPath = get(config, 'build.output.path')
|
|
167
|
-
}
|
|
161
|
+
plaintextOutputPath = get(config, 'build.output.path')
|
|
168
162
|
}
|
|
169
163
|
|
|
170
164
|
/**
|
|
@@ -179,12 +173,22 @@ export async function writePlaintextFile(plaintext = '', config = {}) {
|
|
|
179
173
|
// No need to handle if it's an object, since we already set it to that initially
|
|
180
174
|
|
|
181
175
|
/**
|
|
182
|
-
* If `
|
|
176
|
+
* If the template has a `permalink` key set in the FM, always output plaintext file there
|
|
177
|
+
*/
|
|
178
|
+
if (typeof config.permalink === 'string') {
|
|
179
|
+
plaintextOutputPath = config.permalink
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* If `plaintextOutputPath` is a file path, output file there.
|
|
184
|
+
*
|
|
185
|
+
* The file will be output relative to the project root, and the extension
|
|
186
|
+
* doesn't matter, it will be replaced with `plaintextExtension`.
|
|
183
187
|
*/
|
|
184
188
|
if (path.extname(plaintextOutputPath)) {
|
|
185
189
|
// Ensure the target directory exists
|
|
186
190
|
await lstat(plaintextOutputPath).catch(async () => {
|
|
187
|
-
await mkdir(plaintextOutputPath, { recursive: true })
|
|
191
|
+
await mkdir(path.dirname(plaintextOutputPath), { recursive: true })
|
|
188
192
|
})
|
|
189
193
|
|
|
190
194
|
// Ensure correct extension is used
|
|
@@ -193,19 +197,19 @@ export async function writePlaintextFile(plaintext = '', config = {}) {
|
|
|
193
197
|
path.basename(plaintextOutputPath, path.extname(plaintextOutputPath)) + '.' + plaintextExtension
|
|
194
198
|
)
|
|
195
199
|
|
|
196
|
-
console.log('plaintextOutputPath', plaintextOutputPath);
|
|
197
|
-
|
|
198
200
|
return writeFile(plaintextOutputPath, plaintext)
|
|
199
201
|
}
|
|
200
202
|
|
|
201
203
|
/**
|
|
202
|
-
* If `plaintextOutputPath` is a directory path, output file there
|
|
204
|
+
* If `plaintextOutputPath` is a directory path, output file there using the Template's name.
|
|
205
|
+
*
|
|
206
|
+
* The file will be output relative to the `build.output.path` directory.
|
|
203
207
|
*/
|
|
204
208
|
const templateFileName = get(config, 'build.current.path.name')
|
|
205
209
|
|
|
206
210
|
plaintextOutputPath = path.join(
|
|
207
|
-
path.dirname(plaintextOutputPath),
|
|
208
211
|
get(config, 'build.current.path.dir'),
|
|
212
|
+
plaintextOutputPath,
|
|
209
213
|
templateFileName + '.' + plaintextExtension
|
|
210
214
|
)
|
|
211
215
|
|
package/src/generators/render.js
CHANGED
|
@@ -70,7 +70,9 @@ export async function render(html = '', config = {}) {
|
|
|
70
70
|
})) ?? content
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Compile PostHTML
|
|
75
|
+
*/
|
|
74
76
|
const compiled = await compilePostHTML(content, templateConfig)
|
|
75
77
|
|
|
76
78
|
/**
|
|
@@ -86,11 +88,10 @@ export async function render(html = '', config = {}) {
|
|
|
86
88
|
compiled.html = await templateConfig.afterRender(({
|
|
87
89
|
html: compiled.html,
|
|
88
90
|
matter: matterData,
|
|
89
|
-
config:
|
|
91
|
+
config: compiled.config,
|
|
90
92
|
})) ?? compiled.html
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
// Run Transformers
|
|
94
95
|
/**
|
|
95
96
|
* Run Transformers
|
|
96
97
|
*
|
|
@@ -101,10 +102,9 @@ export async function render(html = '', config = {}) {
|
|
|
101
102
|
* @returns {string} - The transformed HTML
|
|
102
103
|
*/
|
|
103
104
|
if (templateConfig.useTransformers !== false) {
|
|
104
|
-
compiled.html = await useTransformers(compiled.html,
|
|
105
|
+
compiled.html = await useTransformers(compiled.html, compiled.config).then(({ html }) => html)
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
// Run `afterTransformers` event
|
|
108
108
|
/**
|
|
109
109
|
* Run `afterTransformers` event
|
|
110
110
|
*
|
|
@@ -118,12 +118,12 @@ export async function render(html = '', config = {}) {
|
|
|
118
118
|
compiled.html = await templateConfig.afterTransformers(({
|
|
119
119
|
html: compiled.html,
|
|
120
120
|
matter: matterData,
|
|
121
|
-
config:
|
|
121
|
+
config: compiled.config,
|
|
122
122
|
})) ?? compiled.html
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
return {
|
|
126
|
-
config:
|
|
126
|
+
config: compiled.config,
|
|
127
127
|
html: compiled.html,
|
|
128
128
|
}
|
|
129
129
|
}
|
package/src/posthtml/index.js
CHANGED
|
@@ -41,7 +41,7 @@ export async function process(html = '', config = {}) {
|
|
|
41
41
|
const componentsUserOptions = get(config, 'components', {})
|
|
42
42
|
|
|
43
43
|
const expressionsOptions = merge(
|
|
44
|
-
get(config, '
|
|
44
|
+
get(config, 'expressions', get(config, 'posthtml.expressions', {})),
|
|
45
45
|
get(componentsUserOptions, 'expressions', {}),
|
|
46
46
|
)
|
|
47
47
|
|
|
@@ -94,7 +94,7 @@ export async function process(html = '', config = {}) {
|
|
|
94
94
|
])
|
|
95
95
|
.process(html, posthtmlOptions)
|
|
96
96
|
.then(result => ({
|
|
97
|
-
config,
|
|
97
|
+
config: merge(config, { page: config }),
|
|
98
98
|
html: result.html,
|
|
99
99
|
}))
|
|
100
100
|
.catch(error => {
|
package/src/server/index.js
CHANGED
|
@@ -128,7 +128,7 @@ export default async (config = {}) => {
|
|
|
128
128
|
* Initialize WebSocket server
|
|
129
129
|
* Used to send messages between the server and the browser
|
|
130
130
|
*/
|
|
131
|
-
initWebSockets(wss, {
|
|
131
|
+
initWebSockets(wss, { shouldScroll, useHmr })
|
|
132
132
|
|
|
133
133
|
// Register routes
|
|
134
134
|
templatePaths = await getUpdatedRoutes(app, config)
|
|
@@ -140,7 +140,7 @@ export default async (config = {}) => {
|
|
|
140
140
|
* */
|
|
141
141
|
app.request.templatePaths = templatePaths
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
app.request.maizzleConfig = config
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
146
|
* Create route pattern
|
|
@@ -7,27 +7,65 @@ import { fileURLToPath } from 'node:url'
|
|
|
7
7
|
import expressions from 'posthtml-expressions'
|
|
8
8
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
const
|
|
10
|
+
function groupFilesByDirectories(globs, files) {
|
|
11
|
+
const result = {}
|
|
12
|
+
let current = {}
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
globs.forEach(glob => {
|
|
15
|
+
const rootPath = glob.split(/[\*\!\{\}]/)[0].replace(/\/+$/, '')
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
files.forEach(file => {
|
|
18
|
+
if (file.startsWith(rootPath)) {
|
|
19
|
+
const relativePath = file.slice(rootPath.length + 1)
|
|
20
|
+
const parts = relativePath.split('/')
|
|
21
|
+
current = result[rootPath] = result[rootPath] || {}
|
|
22
|
+
|
|
23
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
24
|
+
current = current[parts[i]] = current[parts[i]] || {}
|
|
25
|
+
}
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
const fileName = parts[parts.length - 1]
|
|
28
|
+
current[fileName] = {
|
|
29
|
+
name: fileName,
|
|
30
|
+
href: file,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
25
33
|
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
return result
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function flattenPaths(paths, parentPath = '', currentDepth = 0) {
|
|
40
|
+
const flatArray = []
|
|
41
|
+
|
|
42
|
+
for (const [key, value] of Object.entries(paths)) {
|
|
43
|
+
const fullPath = parentPath ? `${parentPath}/${key}` : key
|
|
44
|
+
|
|
45
|
+
if (value && typeof value === 'object' && !value.name) {
|
|
46
|
+
// If it's a folder, add it with the current depth and recurse into its contents
|
|
47
|
+
flatArray.push({ name: key, path: fullPath, depth: currentDepth, type: 'folder' })
|
|
48
|
+
flatArray.push(...flattenPaths(value, fullPath, currentDepth + 1))
|
|
49
|
+
} else if (value && typeof value === 'object' && value.name) {
|
|
50
|
+
// If it's a file, add it with the current depth
|
|
51
|
+
flatArray.push({ name: value.name, href: value.href, path: fullPath, depth: currentDepth, type: 'file' })
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return flatArray
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
route.get(['/', '/index.html'], async (req, res) => {
|
|
59
|
+
const view = await fs.readFile(path.join(__dirname, '../views', 'index.html'), 'utf8')
|
|
60
|
+
|
|
61
|
+
const content = new Set(req.maizzleConfig.build.content)
|
|
62
|
+
|
|
63
|
+
const groupedByDir = groupFilesByDirectories(content, req.templatePaths)
|
|
26
64
|
|
|
27
65
|
const { html } = await posthtml()
|
|
28
66
|
.use(expressions({
|
|
29
67
|
locals: {
|
|
30
|
-
|
|
68
|
+
paths: flattenPaths(groupedByDir)
|
|
31
69
|
}
|
|
32
70
|
}))
|
|
33
71
|
.process(view)
|
|
@@ -4,21 +4,144 @@
|
|
|
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.root {
|
|
83
|
+
padding-top: 3rem;
|
|
84
|
+
border: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
li.file {
|
|
88
|
+
border-left: 1px solid #64748B;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
li.file.nested {
|
|
92
|
+
line-height: 2.25rem;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
li.file.nested a {
|
|
96
|
+
padding-bottom: 0.75rem;
|
|
97
|
+
margin-left: -1.5rem;
|
|
98
|
+
padding-left: 1.5rem;
|
|
99
|
+
border-left: 1px solid #cbd5e1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
li.file.nested:last-child a {
|
|
103
|
+
padding-bottom: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.insignia {
|
|
107
|
+
width: 64rem;
|
|
108
|
+
position: fixed;
|
|
109
|
+
z-index: -1;
|
|
110
|
+
right: -3rem;
|
|
111
|
+
bottom: 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@media (max-width: 425px) {
|
|
115
|
+
.insignia {
|
|
116
|
+
width: 100%;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
</style>
|
|
7
120
|
</head>
|
|
8
121
|
<body>
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
122
|
+
<ul>
|
|
123
|
+
<each loop="item in paths">
|
|
124
|
+
<if condition="item.type === 'folder'">
|
|
125
|
+
<li
|
|
126
|
+
style="padding-left: calc(1.5rem * {{ item.depth }});"
|
|
127
|
+
class="folder {{ item.depth > 0 ? 'nested' : 'root' }}"
|
|
128
|
+
>
|
|
129
|
+
<strong>{{{ item.name }}}</strong>
|
|
130
|
+
</li>
|
|
131
|
+
</if>
|
|
132
|
+
<if condition="item.type === 'file'">
|
|
133
|
+
<li
|
|
134
|
+
style="padding-left: calc(1.5rem * {{ item.depth }});"
|
|
135
|
+
class="file {{ item.depth > 1 ? 'nested' : '' }}"
|
|
136
|
+
>
|
|
137
|
+
<a href="{{ item.href }}">
|
|
138
|
+
{{ item.name }}
|
|
139
|
+
</a>
|
|
140
|
+
</li>
|
|
141
|
+
</if>
|
|
142
|
+
</each>
|
|
143
|
+
</ul>
|
|
144
|
+
|
|
145
|
+
<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>
|
|
23
146
|
</body>
|
|
24
147
|
</html>
|
|
@@ -2,11 +2,11 @@ import juice from 'juice'
|
|
|
2
2
|
import postcss from 'postcss'
|
|
3
3
|
import get from 'lodash-es/get.js'
|
|
4
4
|
import has from 'lodash-es/has.js'
|
|
5
|
+
import * as cheerio from 'cheerio/slim'
|
|
5
6
|
import remove from 'lodash-es/remove.js'
|
|
6
7
|
import { render } from 'posthtml-render'
|
|
7
8
|
import { calc } from '@csstools/css-calc'
|
|
8
9
|
import isEmpty from 'lodash-es/isEmpty.js'
|
|
9
|
-
import * as cheerio from 'cheerio/lib/slim'
|
|
10
10
|
import safeParser from 'postcss-safe-parser'
|
|
11
11
|
import isObject from 'lodash-es/isObject.js'
|
|
12
12
|
import { parser as parse } from 'posthtml-parser'
|
|
@@ -47,7 +47,12 @@ export async function inline(html = '', options = {}) {
|
|
|
47
47
|
})
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const $ = cheerio.load(html, {
|
|
50
|
+
const $ = cheerio.load(html, {
|
|
51
|
+
xml: {
|
|
52
|
+
decodeEntities: false,
|
|
53
|
+
xmlMode: false,
|
|
54
|
+
}
|
|
55
|
+
})
|
|
51
56
|
|
|
52
57
|
// Add a `data-embed` attribute to style tags that have the embed attribute
|
|
53
58
|
$('style[embed]').each((i, el) => {
|
|
@@ -2,6 +2,7 @@ import pretty from 'pretty'
|
|
|
2
2
|
import posthtml from 'posthtml'
|
|
3
3
|
import { defu as merge } from 'defu'
|
|
4
4
|
import { render } from 'posthtml-render'
|
|
5
|
+
import { parser as parse } from 'posthtml-parser'
|
|
5
6
|
import posthtmlConfig from '../posthtml/defaultConfig.js'
|
|
6
7
|
|
|
7
8
|
const posthtmlPlugin = (options = {}) => tree => {
|
|
@@ -14,7 +15,7 @@ const posthtmlPlugin = (options = {}) => tree => {
|
|
|
14
15
|
|
|
15
16
|
const config = merge(options, defaultConfig)
|
|
16
17
|
|
|
17
|
-
return pretty(render(tree), config)
|
|
18
|
+
return parse(pretty(render(tree), config), posthtmlConfig)
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export default posthtmlPlugin
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
const posthtmlPlugin = (
|
|
1
|
+
const posthtmlPlugin = () => tree => {
|
|
2
2
|
const process = node => {
|
|
3
3
|
// Return the original node if it doesn't have a tag
|
|
4
4
|
if (!node.tag) {
|
|
5
5
|
return node
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
node.attrs
|
|
8
|
+
if (node.tag === 'template') {
|
|
9
|
+
// Preserve <template> tags marked as such
|
|
10
|
+
if ('attrs' in node && 'preserve' in node.attrs) {
|
|
11
|
+
node.attrs.preserve = false
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
return node
|
|
14
|
+
}
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
if (node.tag === 'template') {
|
|
16
|
+
// Remove the <template> tag
|
|
17
17
|
node.tag = false
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -21,6 +21,6 @@ const posthtmlPlugin = (() => tree => {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
return tree.walk(process)
|
|
24
|
-
}
|
|
24
|
+
}
|
|
25
25
|
|
|
26
26
|
export default posthtmlPlugin
|
package/types/build.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { SpinnerName } from 'cli-spinners';
|
|
2
|
-
import type { PostHTMLExpressions } from 'posthtml-expressions';
|
|
3
2
|
|
|
4
3
|
export default interface BuildConfig {
|
|
5
4
|
/**
|
|
@@ -18,11 +17,6 @@ export default interface BuildConfig {
|
|
|
18
17
|
*/
|
|
19
18
|
content?: string[];
|
|
20
19
|
|
|
21
|
-
/**
|
|
22
|
-
Configure [posthtml-expressions](https://github.com/posthtml/posthtml-expressions) options.
|
|
23
|
-
*/
|
|
24
|
-
expressions?: PostHTMLExpressions;
|
|
25
|
-
|
|
26
20
|
/**
|
|
27
21
|
* Define the output path for compiled Templates, and what file extension they should use.
|
|
28
22
|
*
|
package/types/config.d.ts
CHANGED
|
@@ -13,9 +13,9 @@ import type { CoreBeautifyOptions } from 'js-beautify';
|
|
|
13
13
|
import type { BaseURLConfig } from 'posthtml-base-url';
|
|
14
14
|
import type URLParametersConfig from './urlParameters';
|
|
15
15
|
import type { PostHTMLFetchConfig } from 'posthtml-fetch';
|
|
16
|
-
import type { PostHTMLComponents } from 'posthtml-component';
|
|
17
|
-
|
|
18
16
|
import type { Config as TailwindConfig } from 'tailwindcss';
|
|
17
|
+
import type { PostHTMLComponents } from 'posthtml-component';
|
|
18
|
+
import type { PostHTMLExpressions } from 'posthtml-expressions';
|
|
19
19
|
|
|
20
20
|
export default interface Config {
|
|
21
21
|
/**
|
|
@@ -170,6 +170,11 @@ export default interface Config {
|
|
|
170
170
|
tailwind?: TailwindConfig;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
Configure [posthtml-expressions](https://github.com/posthtml/posthtml-expressions) options.
|
|
175
|
+
*/
|
|
176
|
+
expressions?: PostHTMLExpressions;
|
|
177
|
+
|
|
173
178
|
/**
|
|
174
179
|
* Configure the [`<fetch>`](https://maizzle.com/docs/tags#fetch) tag.
|
|
175
180
|
*/
|
|
@@ -370,11 +375,11 @@ export default interface Config {
|
|
|
370
375
|
hmr?: boolean;
|
|
371
376
|
|
|
372
377
|
/**
|
|
373
|
-
* Enable synchronized scrolling across
|
|
378
|
+
* Enable synchronized scrolling across browser tabs.
|
|
374
379
|
*
|
|
375
380
|
* @default false
|
|
376
381
|
*/
|
|
377
|
-
|
|
382
|
+
scrollSync?: boolean;
|
|
378
383
|
|
|
379
384
|
/**
|
|
380
385
|
* Paths to watch for changes.
|
package/types/css/inline.d.ts
CHANGED
|
@@ -85,6 +85,8 @@ export default interface InlineCSSConfig {
|
|
|
85
85
|
* Prefer HTML `width` and `height` attributes over inline CSS.
|
|
86
86
|
* The inline CSS `width` and `height` will be removed.
|
|
87
87
|
*
|
|
88
|
+
* Applies to elements set in `widthElements` and `heightElements`.
|
|
89
|
+
*
|
|
88
90
|
* @example
|
|
89
91
|
* ```
|
|
90
92
|
* export default {
|