mosaic 1.0.13 → 1.0.14

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 +5 -24
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mosaic",
3
3
  "type": "module",
4
- "version": "1.0.13",
4
+ "version": "1.0.14",
5
5
  "description": "",
6
6
  "main": "src/index.js",
7
7
  "scripts": {
package/src/index.js CHANGED
@@ -1,17 +1,15 @@
1
- import express from "express"
1
+ import { customElementIncludes } from "customelementincludes"
2
2
  import fs from "fs-extra"
3
+ import express from "express"
4
+ import { globby } from "globby"
3
5
  import hljs from "highlight.js"
4
6
  import MarkdownIt from "markdown-it"
5
- import { globby } from "globby"
7
+
6
8
  // import postcss from "postcss"
7
9
  // import prefixer from "postcss-prefix-selector"
8
-
9
- import { listCustomElements } from "./customElements.js"
10
10
  import { decapitate } from "./head.js"
11
11
  import { document } from "./document.js"
12
12
 
13
- const componentsGlob = process.env.components || `components/**/*.js`
14
-
15
13
  let md = new MarkdownIt({
16
14
  html: true,
17
15
  highlight: function (str, language) {
@@ -42,7 +40,6 @@ let md = new MarkdownIt({
42
40
  if (req.originalUrl.includes(".")) return next()
43
41
 
44
42
  const route = req.originalUrl.split("?")[0]
45
- const fp = `./pages${route === "/" ? "/index" : route}.md`
46
43
 
47
44
  const [filepath] = await globby([
48
45
  `./pages${route === "/" ? "/index" : route}.(md|html)`,
@@ -55,29 +52,13 @@ let md = new MarkdownIt({
55
52
  const head = result.head
56
53
  const main =
57
54
  path.extname(filepath) === ".md" ? md.render(result.body) : result.body
58
- const customElements = listCustomElements(main)
59
-
60
- if (customElements) {
61
- await globby([componentsGlob]).then((paths) =>
62
- paths
63
- .filter((p) => {
64
- let [dir, file] = p.split("/").slice(-2)
65
- return customElements.find(
66
- (name) => dir === name || file.split(".")[0] === name
67
- )
68
- })
69
- .forEach((path) => {
70
- main += `<script type="module" src="/${path}"></script>`
71
- })
72
- )
73
- }
74
55
 
75
56
  const html = document({
76
57
  head,
77
58
  main,
78
59
  })
79
60
 
80
- res.send(html)
61
+ res.send(await customElementIncludes(html))
81
62
  })
82
63
 
83
64
  app.listen(port, () => {