Open gajus opened 7 years ago
Nice tool your created. I would advise to do the inlining in the end in node with cheerio, which you already depend on..
const rootOuterHTML = (await DOM.getOuterHTML({
nodeId: rootDocument.root.nodeId
})).outerHTML;
await end();
$ = cheerio.load(rootOuterHTML)
$("head").append("<style>....")
return $.html()
you will have the cost of one additional html parsing, but the code will be much cleaner..
or even easier a quick and dirty string replace..
return rootOuterHTML.replace("</head>","<style>...</head>")
See notes:
https://github.com/gajus/usus/blob/3edef93496971e329024aa1856babcd4cc15f453/src/usus.js#L27-L40