methanol 0.0.9 → 0.0.10
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/README.md +3 -0
- package/index.js +7 -2
- package/package.json +8 -3
- package/src/build-system.js +43 -7
- package/src/client/sw.js +751 -0
- package/src/{assets.js → client/virtual-module/assets.js} +7 -3
- package/src/{virtual-module → client/virtual-module}/inject.js +1 -0
- package/src/{virtual-module → client/virtual-module}/loader.js +5 -5
- package/src/{virtual-module → client/virtual-module}/pagefind-loader.js +1 -1
- package/src/client/virtual-module/pwa-inject.js +25 -0
- package/src/components.js +5 -5
- package/src/config.js +22 -3
- package/src/dev-server.js +62 -66
- package/src/logger.js +9 -5
- package/src/main.js +5 -1
- package/src/mdx.js +21 -37
- package/src/pages.js +61 -51
- package/src/public-assets.js +1 -1
- package/src/{rewind.js → reframe.js} +1 -1
- package/src/rehype-plugins/link-resolve.js +2 -2
- package/src/stage-logger.js +3 -2
- package/src/state.js +16 -3
- package/src/utils.js +23 -1
- package/src/vite-plugins.js +17 -4
- package/themes/default/components/ThemeSearchBox.client.jsx +120 -11
- package/themes/default/index.js +2 -2
- package/themes/default/pages/404.mdx +4 -0
- package/themes/default/pages/index.mdx +7 -9
- package/themes/default/pages/offline.mdx +11 -0
- package/themes/default/sources/style.css +59 -169
- package/themes/default/src/nav-tree.jsx +112 -0
- package/themes/default/{page.jsx → src/page.jsx} +10 -55
- /package/themes/default/{heading.jsx → src/heading.jsx} +0 -0
|
@@ -18,68 +18,22 @@
|
|
|
18
18
|
* under the License.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import { HTMLRenderer as R } from 'methanol'
|
|
22
|
-
import { renderToc } from '
|
|
21
|
+
import { HTMLRenderer as R, DOCTYPE_HTML } from 'methanol'
|
|
22
|
+
import { renderToc } from '../components/ThemeToCContainer.static.jsx'
|
|
23
|
+
import { renderNavTree } from './nav-tree.jsx'
|
|
23
24
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const renderPageTree = (nodes = [], currentRoute, depth = 0) => {
|
|
27
|
-
const items = []
|
|
28
|
-
let hasActive = false
|
|
29
|
-
for (const node of nodes) {
|
|
30
|
-
const nodeRoute = node.routeHref || ''
|
|
31
|
-
if (node.type === 'directory') {
|
|
32
|
-
const label = node.title || node.name
|
|
33
|
-
const isActive = nodeRoute === currentRoute
|
|
34
|
-
const href = node.routeHref
|
|
35
|
-
const childResult = renderPageTree(node.children || [], currentRoute, depth + 1)
|
|
36
|
-
const isOpen = depth < 1 || isActive || childResult.hasActive
|
|
37
|
-
if (isOpen) hasActive = true
|
|
38
|
-
const header = href ? (
|
|
39
|
-
<a class={isActive ? 'nav-dir-link active' : 'nav-dir-link'} href={href}>
|
|
40
|
-
{label}
|
|
41
|
-
</a>
|
|
42
|
-
) : (
|
|
43
|
-
<span class="nav-dir-label">{label}</span>
|
|
44
|
-
)
|
|
45
|
-
items.push(
|
|
46
|
-
<li class={isActive ? 'is-active' : null}>
|
|
47
|
-
<details class="sidebar-collapsible" open={isOpen ? true : null}>
|
|
48
|
-
<summary class="sb-dir-header">{header}</summary>
|
|
49
|
-
{childResult.items.length ? <ul data-depth={depth + 1}>{childResult.items}</ul> : null}
|
|
50
|
-
</details>
|
|
51
|
-
</li>
|
|
52
|
-
)
|
|
53
|
-
continue
|
|
54
|
-
}
|
|
55
|
-
const label = node.title || (node.isIndex ? 'Home' : node.name)
|
|
56
|
-
const isActive = nodeRoute === currentRoute
|
|
57
|
-
if (isActive) hasActive = true
|
|
58
|
-
const href = node.routeHref
|
|
59
|
-
items.push(
|
|
60
|
-
<li>
|
|
61
|
-
<a class={isActive ? 'active' : null} href={href}>
|
|
62
|
-
{label}
|
|
63
|
-
</a>
|
|
64
|
-
</li>
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
return { items, hasActive }
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const PAGE_TEMPLATE = ({ PageContent, ExtraHead, components, ctx }) => {
|
|
25
|
+
const PAGE_TEMPLATE = async ({ PageContent, ExtraHead, components, ctx }) => {
|
|
71
26
|
const page = ctx.page
|
|
72
27
|
const pagesByRoute = ctx.pagesByRoute
|
|
73
28
|
const pages = ctx.pages || []
|
|
74
29
|
const pagesTree = ctx.pagesTree || []
|
|
75
30
|
const siteName = ctx.site.name || 'Methanol Site'
|
|
76
31
|
const title = page.title || siteName
|
|
77
|
-
const
|
|
78
|
-
|
|
32
|
+
const baseHref =
|
|
33
|
+
page.routeHref === '/404' || page.routeHref === '/offline' ? ctx.site.base || '/' : null
|
|
79
34
|
const toc = page.toc?.length ? renderToc(page.toc) : null
|
|
80
35
|
const hasToc = Boolean(toc)
|
|
81
36
|
const layoutClass = hasToc ? 'layout-container' : 'layout-container no-toc'
|
|
82
|
-
const tree = renderPageTree(pagesTree, currentRoute, 0)
|
|
83
37
|
const { ThemeSearchBox, ThemeColorSwitch, ThemeAccentSwitch, ThemeToCContainer } = components
|
|
84
38
|
const rootPage = pagesByRoute.get('/') || pages.find((entry) => entry.routeHref === '/')
|
|
85
39
|
const pageFrontmatter = page.frontmatter || {}
|
|
@@ -146,9 +100,10 @@ const PAGE_TEMPLATE = ({ PageContent, ExtraHead, components, ctx }) => {
|
|
|
146
100
|
</div>
|
|
147
101
|
</div>
|
|
148
102
|
) : null
|
|
103
|
+
|
|
149
104
|
return (
|
|
150
105
|
<>
|
|
151
|
-
{
|
|
106
|
+
{DOCTYPE_HTML}
|
|
152
107
|
<html lang={htmlLang}>
|
|
153
108
|
<head>
|
|
154
109
|
<meta charset="UTF-8" />
|
|
@@ -244,7 +199,7 @@ const PAGE_TEMPLATE = ({ PageContent, ExtraHead, components, ctx }) => {
|
|
|
244
199
|
{pagefindEnabled ? <ThemeSearchBox options={pagefindOptions} /> : null}
|
|
245
200
|
</div>
|
|
246
201
|
<nav>
|
|
247
|
-
<ul data-depth="0">{
|
|
202
|
+
<ul data-depth="0">{renderNavTree(pagesTree, page.routePath)}</ul>
|
|
248
203
|
</nav>
|
|
249
204
|
<div class="sidebar-footer">
|
|
250
205
|
{languageSelector}
|
|
@@ -294,7 +249,7 @@ const PAGE_TEMPLATE = ({ PageContent, ExtraHead, components, ctx }) => {
|
|
|
294
249
|
<span style="margin: 0 0.5rem; opacity: 0.5;">•</span>
|
|
295
250
|
</>
|
|
296
251
|
) : null}
|
|
297
|
-
Updated: {page.updatedAt || '-'}
|
|
252
|
+
Updated: {page.stats.updatedAt || '-'}
|
|
298
253
|
</div>
|
|
299
254
|
<div class="page-meta-item">
|
|
300
255
|
Powered by{' '}
|
|
File without changes
|