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
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -18,5 +18,10 @@
|
|
|
18
18
|
* under the License.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
import { HTMLRenderer } from './src/renderer.js'
|
|
22
|
+
|
|
23
|
+
export { env } from './src/reframe.js'
|
|
24
|
+
|
|
25
|
+
const DOCTYPE_HTML = HTMLRenderer.rawHTML`<!DOCTYPE html>`
|
|
26
|
+
|
|
27
|
+
export { HTMLRenderer, DOCTYPE_HTML }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "methanol",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Static site generator powered by rEFui and MDX",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -35,13 +35,18 @@
|
|
|
35
35
|
"gray-matter": "^4.0.3",
|
|
36
36
|
"hast-util-is-element": "^3.0.0",
|
|
37
37
|
"json5": "^2.2.3",
|
|
38
|
-
"
|
|
38
|
+
"null-prototype-object": "^1.2.5",
|
|
39
|
+
"refui": "^0.16.3",
|
|
39
40
|
"refurbish": "^0.1.8",
|
|
40
41
|
"rehype-slug": "^6.0.0",
|
|
41
42
|
"rehype-starry-night": "^2.2.0",
|
|
42
43
|
"remark-gfm": "^4.0.1",
|
|
43
44
|
"unist-util-visit": "^5.0.0",
|
|
44
|
-
"vite": "^7.3.
|
|
45
|
+
"vite": "^7.3.1",
|
|
46
|
+
"vite-plugin-pwa": "^1.2.0",
|
|
47
|
+
"workbox-core": "^7.4.0",
|
|
48
|
+
"workbox-routing": "^7.4.0",
|
|
49
|
+
"workbox-strategies": "^7.4.0",
|
|
45
50
|
"yargs": "^18.0.0"
|
|
46
51
|
},
|
|
47
52
|
"repository": {
|
package/src/build-system.js
CHANGED
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
|
|
21
21
|
import { writeFile, mkdir, rm, readFile, readdir, stat } from 'fs/promises'
|
|
22
22
|
import { resolve, dirname, join } from 'path'
|
|
23
|
+
import { fileURLToPath } from 'url'
|
|
23
24
|
import { build as viteBuild, mergeConfig, normalizePath } from 'vite'
|
|
25
|
+
import { VitePWA } from 'vite-plugin-pwa'
|
|
24
26
|
import { state, cli } from './state.js'
|
|
25
27
|
import { resolveUserViteConfig } from './config.js'
|
|
26
28
|
import { buildPagesContext } from './pages.js'
|
|
@@ -30,6 +32,9 @@ import { methanolVirtualHtmlPlugin, methanolResolverPlugin } from './vite-plugin
|
|
|
30
32
|
import { createStageLogger } from './stage-logger.js'
|
|
31
33
|
import { preparePublicAssets } from './public-assets.js'
|
|
32
34
|
|
|
35
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
36
|
+
const __dirname = dirname(__filename)
|
|
37
|
+
|
|
33
38
|
const ensureDir = async (dir) => {
|
|
34
39
|
await mkdir(dir, { recursive: true })
|
|
35
40
|
}
|
|
@@ -102,14 +107,11 @@ export const buildHtmlEntries = async () => {
|
|
|
102
107
|
for (let i = 0; i < pagesContext.pages.length; i++) {
|
|
103
108
|
const page = pagesContext.pages[i]
|
|
104
109
|
if (logEnabled) {
|
|
105
|
-
stageLogger.update(
|
|
106
|
-
renderToken,
|
|
107
|
-
`Rendering pages [${i + 1}/${totalPages}] ${page.filePath}`
|
|
108
|
-
)
|
|
110
|
+
stageLogger.update(renderToken, `Rendering pages [${i + 1}/${totalPages}] ${page.path}`)
|
|
109
111
|
}
|
|
110
112
|
const html = await renderHtml({
|
|
111
113
|
routePath: page.routePath,
|
|
112
|
-
|
|
114
|
+
path: page.path,
|
|
113
115
|
components: mergedComponents,
|
|
114
116
|
pagesContext,
|
|
115
117
|
pageMeta: page
|
|
@@ -176,6 +178,8 @@ export const runViteBuild = async (entry, htmlCache) => {
|
|
|
176
178
|
})
|
|
177
179
|
}
|
|
178
180
|
const copyPublicDirEnabled = state.STATIC_DIR !== false
|
|
181
|
+
const manifestConfig = state.PWA_OPTIONS?.manifest || {}
|
|
182
|
+
const resolvedManifest = { name: state.SITE_NAME, short_name: state.SITE_NAME, ...manifestConfig }
|
|
179
183
|
const baseConfig = {
|
|
180
184
|
configFile: false,
|
|
181
185
|
root: state.PAGES_DIR,
|
|
@@ -198,10 +202,42 @@ export const runViteBuild = async (entry, htmlCache) => {
|
|
|
198
202
|
resolve: {
|
|
199
203
|
dedupe: ['refui', 'methanol']
|
|
200
204
|
},
|
|
201
|
-
plugins: [
|
|
205
|
+
plugins: [
|
|
206
|
+
methanolVirtualHtmlPlugin(htmlCache),
|
|
207
|
+
methanolResolverPlugin(),
|
|
208
|
+
state.PWA_ENABLED
|
|
209
|
+
? VitePWA({
|
|
210
|
+
injectRegister: 'auto',
|
|
211
|
+
registerType: 'autoUpdate',
|
|
212
|
+
strategies: 'injectManifest',
|
|
213
|
+
srcDir: resolve(__dirname, 'client'),
|
|
214
|
+
filename: 'sw.js',
|
|
215
|
+
manifest: resolvedManifest,
|
|
216
|
+
injectManifest: {
|
|
217
|
+
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
|
218
|
+
...(state.PWA_OPTIONS?.injectManifest || {})
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
: null
|
|
222
|
+
]
|
|
202
223
|
}
|
|
203
224
|
const userConfig = await resolveUserViteConfig('build')
|
|
204
225
|
const finalConfig = userConfig ? mergeConfig(baseConfig, userConfig) : baseConfig
|
|
205
|
-
|
|
226
|
+
|
|
227
|
+
const originalLog = console.log
|
|
228
|
+
const originalWarn = console.warn
|
|
229
|
+
if (!cli.CLI_VERBOSE) {
|
|
230
|
+
console.log = () => {}
|
|
231
|
+
console.warn = () => {}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
try {
|
|
235
|
+
await viteBuild(finalConfig)
|
|
236
|
+
} finally {
|
|
237
|
+
if (!cli.CLI_VERBOSE) {
|
|
238
|
+
console.log = originalLog
|
|
239
|
+
console.warn = originalWarn
|
|
240
|
+
}
|
|
241
|
+
}
|
|
206
242
|
stageLogger.end(token)
|
|
207
243
|
}
|