boxwood 0.61.4 → 0.61.5

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.
Files changed (2) hide show
  1. package/index.js +14 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -13,12 +13,21 @@ async function compile(path) {
13
13
  if (node.name === 'head') {
14
14
  nodes.head = node
15
15
  }
16
+ if (node.name === 'body') {
17
+ nodes.body = node
18
+ }
16
19
  if (node.name === 'style') {
17
- styles.push(node.children)
20
+ const css = node.children
21
+ if (!styles.includes(css)) {
22
+ styles.push(css)
23
+ }
18
24
  node.ignore = true
19
25
  }
20
26
  if (node.name === 'script') {
21
- scripts.push(node.children)
27
+ const js = node.children
28
+ if (!scripts.includes(js)) {
29
+ scripts.push(js)
30
+ }
22
31
  node.ignore = true
23
32
  }
24
33
  if (Array.isArray(node)) {
@@ -35,8 +44,10 @@ async function compile(path) {
35
44
  children: styles.join(''),
36
45
  })
37
46
  }
47
+ }
48
+ if (nodes.body) {
38
49
  if (scripts.length > 0) {
39
- nodes.head.children.push({
50
+ nodes.body.children.push({
40
51
  name: 'script',
41
52
  children: scripts.join(''),
42
53
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boxwood",
3
- "version": "0.61.4",
3
+ "version": "0.61.5",
4
4
  "description": "Compile HTML templates into JS",
5
5
  "main": "index.js",
6
6
  "scripts": {