@live-change/email-service 0.3.33 → 0.3.35
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 +4 -3
- package/render.js +17 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/email-service",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.35",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
"@live-change/framework": "0.7.34",
|
|
25
25
|
"got": "^11.8.3",
|
|
26
26
|
"html-to-text": "8.1.0",
|
|
27
|
-
"inline-css": "
|
|
27
|
+
"inline-css": "4.0.2",
|
|
28
28
|
"jsdom": "^18.1.1",
|
|
29
|
+
"juice": "9.1.0",
|
|
29
30
|
"nodemailer": "^6.7.2"
|
|
30
31
|
},
|
|
31
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "8518b8a0add99b33811a2ea87ca7781d308b2fd8"
|
|
32
33
|
}
|
package/render.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const got = require('got')
|
|
2
2
|
const inlineCss = require('inline-css')
|
|
3
|
+
const juice = require('juice')
|
|
3
4
|
const { JSDOM } = require("jsdom")
|
|
4
5
|
const { convert: htmlToText } = require('html-to-text')
|
|
5
6
|
const path = require('path')
|
|
@@ -53,7 +54,22 @@ async function renderEmail(data) {
|
|
|
53
54
|
const response = await got(url)
|
|
54
55
|
let body = response.body
|
|
55
56
|
console.log("BASE URL", baseUrl)
|
|
56
|
-
body = await inlineCss(body, { url })
|
|
57
|
+
//body = await inlineCss(body, { url })
|
|
58
|
+
const juiceOptions = {
|
|
59
|
+
webResources: {
|
|
60
|
+
scripts: false,
|
|
61
|
+
links: true,
|
|
62
|
+
images: false,
|
|
63
|
+
relativeTo: url
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/*body = await juice(body, juiceOptions)*/
|
|
67
|
+
body = await new Promise((resolve, reject) => {
|
|
68
|
+
juice.juiceResources(body, juiceOptions, (err, html) => {
|
|
69
|
+
if(err) reject(err)
|
|
70
|
+
else resolve(html)
|
|
71
|
+
})
|
|
72
|
+
})
|
|
57
73
|
console.log("HTML", body)
|
|
58
74
|
const dom = new JSDOM(body)
|
|
59
75
|
const headers = JSON.parse(dom.window.document.querySelector('[data-headers]').textContent)
|