mosaic 1.0.14 → 1.0.16

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/package.json +1 -1
  2. package/src/index.js +19 -10
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mosaic",
3
3
  "type": "module",
4
- "version": "1.0.14",
4
+ "version": "1.0.16",
5
5
  "description": "",
6
6
  "main": "src/index.js",
7
7
  "scripts": {
package/src/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env node
2
+
1
3
  import { customElementIncludes } from "customelementincludes"
2
4
  import fs from "fs-extra"
3
5
  import express from "express"
@@ -45,18 +47,25 @@ let md = new MarkdownIt({
45
47
  `./pages${route === "/" ? "/index" : route}.(md|html)`,
46
48
  ])
47
49
 
48
- if (!file) return next()
50
+ if (!filepath) return next()
49
51
 
50
52
  const contents = await fs.readFile(filepath, "utf8")
51
- const result = decapitate(contents)
52
- const head = result.head
53
- const main =
54
- path.extname(filepath) === ".md" ? md.render(result.body) : result.body
55
-
56
- const html = document({
57
- head,
58
- main,
59
- })
53
+
54
+ let html = ""
55
+
56
+ if (contents.includes("<!DOCTYPE")) {
57
+ html = contents
58
+ } else {
59
+ const result = decapitate(contents)
60
+ const head = result.head
61
+ const main =
62
+ path.extname(filepath) === ".md" ? md.render(result.body) : result.body
63
+
64
+ html = document({
65
+ head,
66
+ main,
67
+ })
68
+ }
60
69
 
61
70
  res.send(await customElementIncludes(html))
62
71
  })