mosaic 1.0.14 → 1.0.15

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 +16 -9
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.15",
5
5
  "description": "",
6
6
  "main": "src/index.js",
7
7
  "scripts": {
package/src/index.js CHANGED
@@ -45,18 +45,25 @@ let md = new MarkdownIt({
45
45
  `./pages${route === "/" ? "/index" : route}.(md|html)`,
46
46
  ])
47
47
 
48
- if (!file) return next()
48
+ if (!filepath) return next()
49
49
 
50
50
  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
51
 
56
- const html = document({
57
- head,
58
- main,
59
- })
52
+ let html = ""
53
+
54
+ if (contents.includes("<!DOCTYPE")) {
55
+ html = contents
56
+ } else {
57
+ const result = decapitate(contents)
58
+ const head = result.head
59
+ const main =
60
+ path.extname(filepath) === ".md" ? md.render(result.body) : result.body
61
+
62
+ html = document({
63
+ head,
64
+ main,
65
+ })
66
+ }
60
67
 
61
68
  res.send(await customElementIncludes(html))
62
69
  })