methanol 0.0.22 → 0.0.24

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "methanol",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "Static site generator powered by rEFui and MDX",
5
5
  "main": "./index.js",
6
6
  "type": "module",
@@ -148,7 +148,7 @@ const rewriteInlineScripts = async (html, routePath) => {
148
148
  await writeFile(fsPath, content)
149
149
  const publicPath = `/.methanol/inline/${filename}`
150
150
  const srcAttr = `src="${joinBasePrefix(basePrefix, publicPath)}"`
151
- const replacement = `<script type="module" ${srcAttr}></script>`
151
+ const replacement = `<script type="module" crossorigin ${srcAttr}></script>`
152
152
  patches.push({ start: entry.start, end: entry.end, text: replacement })
153
153
  }
154
154
 
@@ -382,6 +382,9 @@ export const rewriteHtmlByPlan = (
382
382
  const publicPath = resolved?.resolvedPath
383
383
  if (!publicPath) continue
384
384
  const attrs = { ...(entry.attrs || {}) }
385
+ if (!attrs.crossorigin) {
386
+ attrs.crossorigin = ''
387
+ }
385
388
  if (commonScripts.has(publicPath)) {
386
389
  if (!commonEntry?.file) {
387
390
  continue
@@ -45,74 +45,66 @@ const toSignal = (i) => {
45
45
  return sig
46
46
  }
47
47
 
48
- const filterVisible = (items) => {
49
- if (!Array.isArray(items)) return []
50
- return items.filter(({ value: item }) => {
51
- if (!item.hidden) {
52
- return true
53
- }
54
-
55
- const _currentPath = currentPath.value
56
- return _currentPath.startsWith(item.routePath)
57
- })
58
- }
59
-
60
48
  const NavTree = ({ nodes, depth }) => {
61
- const filtered = signal(nodes, filterVisible)
62
49
  return (
63
- <For entries={filtered}>
50
+ <For entries={nodes}>
64
51
  {({ item }) => {
65
52
  const node = read(item)
66
53
  const { routeHref: href, routePath, type, name, isRoot } = node
67
- const { title } = extract(item, 'title')
54
+ const { title, hidden } = extract(item, 'title', 'hidden')
68
55
 
69
56
  const isActive = matchCurrentPath(routePath)
70
-
57
+ let show = isActive
71
58
  if (type === 'directory') {
72
- const label = title.or(name)
73
- const { children } = extract(item, 'children')
74
-
75
- const isOpen = $(() => {
76
- if (depth < 1) {
77
- return true
78
- }
59
+ show = $(() => {
79
60
  const _active = isActive.value
80
61
  const _currentPath = currentPath.value
81
62
  return _active || _currentPath.startsWith(routePath)
82
63
  })
83
-
84
- const header = href ? (
85
- <a class={isActive.choose('nav-dir-link active', 'nav-dir-link')} href={href}>
86
- {label}
87
- </a>
88
- ) : (
89
- <span class="nav-dir-label">{label}</span>
90
- )
91
-
92
- return (
93
- <li class={isActive.choose('is-active', null)}>
94
- <details class="sidebar-collapsible" open={isOpen.choose(true, null)}>
95
- <summary class="sb-dir-header">{header}</summary>
96
- <If condition={() => children.value.length}>
97
- {() => (
98
- <ul data-depth={depth + 1}>
99
- <NavTree nodes={children} depth={depth + 1} />
100
- </ul>
101
- )}
102
- </If>
103
- </details>
104
- </li>
105
- )
106
- } else {
107
- const label = title.or(node.isIndex ? 'Home' : name)
108
- return (
109
- <li>
110
- <a class={isActive.choose('active', null)} href={href}>
111
- {label}
112
- </a>
113
- </li>
114
- )
115
64
  }
65
+
66
+ return (
67
+ <If condition={hidden.inverseOr(show)}>
68
+ {() => {
69
+ if (type === 'directory') {
70
+ const label = title.or(name)
71
+ const { children } = extract(item, 'children')
72
+
73
+ const header = href ? (
74
+ <a class={isActive.choose('nav-dir-link active', 'nav-dir-link')} href={href}>
75
+ {label}
76
+ </a>
77
+ ) : (
78
+ <span class="nav-dir-label">{label}</span>
79
+ )
80
+
81
+ return (
82
+ <li class={isActive.choose('is-active', null)}>
83
+ <details class="sidebar-collapsible" open={depth < 1 || show.choose(true, null)}>
84
+ <summary class="sb-dir-header">{header}</summary>
85
+ <If condition={() => children.value.length}>
86
+ {() => (
87
+ <ul data-depth={depth + 1}>
88
+ <NavTree nodes={children} depth={depth + 1} />
89
+ </ul>
90
+ )}
91
+ </If>
92
+ </details>
93
+ </li>
94
+ )
95
+ } else {
96
+ const label = title.or(node.isIndex ? 'Home' : name)
97
+ return (
98
+ <li>
99
+ <a class={isActive.choose('active', null)} href={href}>
100
+ {label}
101
+ </a>
102
+ </li>
103
+ )
104
+ }
105
+ }}
106
+ </If>
107
+ )
116
108
  }}
117
109
  </For>
118
110
  )