methanol 0.0.2 → 0.0.3

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.2",
3
+ "version": "0.0.3",
4
4
  "description": "Static site generator powered by rEFui and MDX",
5
5
  "main": "./index.js",
6
6
  "type": "module",
package/src/config.js CHANGED
@@ -308,8 +308,12 @@ export const applyConfig = async (config, mode) => {
308
308
  state.PAGEFIND_BUILD = resolvePagefindBuild(config)
309
309
  state.USER_PRE_BUILD_HOOKS = normalizeHooks(config.preBuild)
310
310
  state.USER_POST_BUILD_HOOKS = normalizeHooks(config.postBuild)
311
+ state.USER_PRE_BUNDLE_HOOKS = normalizeHooks(config.preBundle)
312
+ state.USER_POST_BUNDLE_HOOKS = normalizeHooks(config.postBundle)
311
313
  state.THEME_PRE_BUILD_HOOKS = normalizeHooks(state.USER_THEME?.preBuild)
312
314
  state.THEME_POST_BUILD_HOOKS = normalizeHooks(state.USER_THEME?.postBuild)
315
+ state.THEME_PRE_BUNDLE_HOOKS = normalizeHooks(state.USER_THEME?.preBundle)
316
+ state.THEME_POST_BUNDLE_HOOKS = normalizeHooks(state.USER_THEME?.postBundle)
313
317
  const starryNight = resolveStarryNightConfig(config.starryNight)
314
318
  const cliCodeHighlighting = cli.CLI_CODE_HIGHLIGHTING
315
319
  if (cliCodeHighlighting != null) {
package/src/main.js CHANGED
@@ -106,11 +106,7 @@ const main = async () => {
106
106
  await runHooks(state.USER_PRE_BUILD_HOOKS)
107
107
  await runHooks(state.THEME_PRE_BUILD_HOOKS)
108
108
  const { entry, htmlCache, pagesContext } = await buildHtmlEntries()
109
- await runViteBuild(entry, htmlCache)
110
- if (state.PAGEFIND_ENABLED) {
111
- await runPagefind()
112
- }
113
- const postBuildContext = pagesContext
109
+ const buildContext = pagesContext
114
110
  ? {
115
111
  pagesContext,
116
112
  pages: pagesContext.pages,
@@ -119,8 +115,16 @@ const main = async () => {
119
115
  site: pagesContext.site
120
116
  }
121
117
  : null
122
- await runHooks(state.THEME_POST_BUILD_HOOKS, postBuildContext)
123
- await runHooks(state.USER_POST_BUILD_HOOKS, postBuildContext)
118
+ await runHooks(state.USER_PRE_BUNDLE_HOOKS, buildContext)
119
+ await runHooks(state.THEME_PRE_BUNDLE_HOOKS, buildContext)
120
+ await runViteBuild(entry, htmlCache)
121
+ await runHooks(state.THEME_POST_BUNDLE_HOOKS, buildContext)
122
+ await runHooks(state.USER_POST_BUNDLE_HOOKS, buildContext)
123
+ if (state.PAGEFIND_ENABLED) {
124
+ await runPagefind()
125
+ }
126
+ await runHooks(state.THEME_POST_BUILD_HOOKS, buildContext)
127
+ await runHooks(state.USER_POST_BUILD_HOOKS, buildContext)
124
128
  return
125
129
  }
126
130
  cli.showHelp()
package/src/pages.js CHANGED
@@ -111,7 +111,13 @@ export const routePathFromFile = (filePath, pagesDir = state.PAGES_DIR) => {
111
111
 
112
112
  const parseFrontmatter = (raw) => {
113
113
  const parsed = matter(raw)
114
- const data = parsed.data || {}
114
+ const data = { ...(parsed.data || {}) }
115
+ if (data.excerpt == null && data.description != null) {
116
+ data.excerpt = data.description
117
+ }
118
+ if (data.description == null && data.excerpt != null) {
119
+ data.description = data.excerpt
120
+ }
115
121
  const content = parsed.content ?? ''
116
122
  return {
117
123
  data,
@@ -18,12 +18,7 @@
18
18
  * under the License.
19
19
  */
20
20
 
21
- import { fileURLToPath } from 'node:url'
22
- import { dirname, resolve } from 'node:path'
23
21
  import { register } from 'node:module'
24
22
 
25
- const __filename = fileURLToPath(import.meta.url)
26
- const __dirname = dirname(__filename)
27
- const loaderPath = resolve(__dirname, '../src/node-loader.js')
28
-
29
- register(loaderPath, import.meta.url)
23
+ const loaderUrl = new URL('./node-loader.js', import.meta.url)
24
+ register(loaderUrl.href, import.meta.url)
package/src/state.js CHANGED
@@ -169,8 +169,12 @@ export const state = {
169
169
  PAGEFIND_BUILD: null,
170
170
  USER_PRE_BUILD_HOOKS: [],
171
171
  USER_POST_BUILD_HOOKS: [],
172
+ USER_PRE_BUNDLE_HOOKS: [],
173
+ USER_POST_BUNDLE_HOOKS: [],
172
174
  THEME_PRE_BUILD_HOOKS: [],
173
175
  THEME_POST_BUILD_HOOKS: [],
176
+ THEME_PRE_BUNDLE_HOOKS: [],
177
+ THEME_POST_BUNDLE_HOOKS: [],
174
178
  STARRY_NIGHT_ENABLED: false,
175
179
  STARRY_NIGHT_OPTIONS: null,
176
180
  CURRENT_MODE: 'production',