@maizzle/framework 5.0.0-beta.4 → 5.0.0-beta.6
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.
|
|
3
|
+
"version": "5.0.0-beta.6",
|
|
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",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"ws": "^8.17.0"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@biomejs/biome": "
|
|
95
|
+
"@biomejs/biome": "1.8.3",
|
|
96
96
|
"@types/js-beautify": "^1.14.3",
|
|
97
97
|
"@types/markdown-it": "^14.1.1",
|
|
98
98
|
"@vitest/coverage-v8": "^2.0.1",
|
package/src/posthtml/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import components from 'posthtml-component'
|
|
|
7
7
|
import posthtmlPostcss from 'posthtml-postcss'
|
|
8
8
|
import defaultPosthtmlConfig from './defaultConfig.js'
|
|
9
9
|
import expandLinkTag from './plugins/expandLinkTag.js'
|
|
10
|
+
import envAttributes from './plugins/envAttributes.js'
|
|
10
11
|
|
|
11
12
|
// PostCSS
|
|
12
13
|
import tailwindcss from 'tailwindcss'
|
|
@@ -50,6 +51,7 @@ export async function process(html = '', config = {}) {
|
|
|
50
51
|
|
|
51
52
|
return posthtml([
|
|
52
53
|
...get(config, 'posthtml.plugins.before', []),
|
|
54
|
+
envAttributes(config.env),
|
|
53
55
|
expandLinkTag,
|
|
54
56
|
postcssPlugin,
|
|
55
57
|
components(
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const plugin = (env => tree => {
|
|
2
|
+
const process = node => {
|
|
3
|
+
// Return the original node if no environment is set
|
|
4
|
+
if (!env) {
|
|
5
|
+
return node
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (node.attrs) {
|
|
9
|
+
for (const attr in node.attrs) {
|
|
10
|
+
const suffix = `-${env}`
|
|
11
|
+
|
|
12
|
+
// Find attributes on this node that have this suffix
|
|
13
|
+
if (attr.endsWith(suffix)) {
|
|
14
|
+
const key = attr.slice(0, -suffix.length)
|
|
15
|
+
const value = node.attrs[attr]
|
|
16
|
+
|
|
17
|
+
// Change the attribute without the suffix to have the value of the suffixed attribute
|
|
18
|
+
node.attrs[key] = value
|
|
19
|
+
|
|
20
|
+
// Remove the attribute with the suffix
|
|
21
|
+
node.attrs[attr] = false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return node
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return tree.walk(process)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
export default plugin
|
package/src/transformers/core.js
CHANGED
|
@@ -11,6 +11,18 @@ const posthtmlPlugin = (config = {}) => tree => {
|
|
|
11
11
|
node.content = ['']
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Custom attributes to prevent inlining CSS from <style> tags
|
|
16
|
+
*/
|
|
17
|
+
if (
|
|
18
|
+
node.tag === 'style'
|
|
19
|
+
&& (node.attrs?.['no-inline'] || node.attrs?.embed)
|
|
20
|
+
) {
|
|
21
|
+
node.attrs['no-inline'] = false
|
|
22
|
+
node.attrs.embed = false
|
|
23
|
+
node.attrs['data-embed'] = true
|
|
24
|
+
}
|
|
25
|
+
|
|
14
26
|
return node
|
|
15
27
|
}
|
|
16
28
|
|