@life-and-dev/mdsite 0.2.3 → 0.3.1

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.
@@ -5,7 +5,7 @@ import YAML from 'yaml'
5
5
  import { buildContentData } from './generate-indices.js'
6
6
  import { generateFavicons, generateWebManifest } from './generate-favicons.js'
7
7
  import { startWatcher, syncContent } from './sync-content.js'
8
- import { loadMdsiteConfigSync, resolveMdsiteConfigPath } from '../utils/mdsite-config.js'
8
+ import { loadMdsiteConfigSync, resolveMdsiteConfigPath, type MdsiteConfig } from '../utils/mdsite-config.js'
9
9
 
10
10
  export interface RendererRuntime {
11
11
  config: ReturnType<typeof loadMdsiteConfigSync>['config']
@@ -69,7 +69,7 @@ export async function runSetupHooks(mode: 'setup' | 'build' | 'generate' | 'dev'
69
69
  if (!options.cached) {
70
70
  await fs.promises.rm(path.join(rootDir, '.data'), { recursive: true, force: true })
71
71
  }
72
-
72
+ await generateDevManifestAssets(runtime.config)
73
73
  process.env.MDSITE_RENDERER_ORCHESTRATED = '1'
74
74
  await startWatcher()
75
75
  return runtime
@@ -78,28 +78,32 @@ export async function runSetupHooks(mode: 'setup' | 'build' | 'generate' | 'dev'
78
78
  await syncContent()
79
79
  console.log(`\nšŸ”Ø Generating navigation and search index...`)
80
80
  await buildContentData()
81
- await generateFaviconAssets(runtime.config.site.name)
81
+ await generateFaviconAssets(runtime.config)
82
82
  process.env.MDSITE_RENDERER_ORCHESTRATED = '1'
83
83
 
84
84
  return runtime
85
85
  }
86
86
 
87
- export async function runBuildFallbackHooks(siteName: string): Promise<void> {
87
+ export async function runBuildFallbackHooks(config: MdsiteConfig): Promise<void> {
88
88
  console.log(`\nšŸ”Ø Generating navigation and search index...`)
89
89
  await buildContentData()
90
- await generateFaviconAssets(siteName)
90
+ await generateFaviconAssets(config)
91
91
  }
92
92
 
93
- async function generateFaviconAssets(siteName: string): Promise<void> {
93
+ async function generateFaviconAssets(config: MdsiteConfig): Promise<void> {
94
94
  console.log(`\nšŸŽØ Generating favicons for build...`)
95
95
  const success = await generateFavicons()
96
96
 
97
97
  if (success) {
98
- await generateWebManifest(siteName)
99
- console.log(`āœ… Favicons ready for ${siteName}\n`)
98
+ await generateWebManifest({ name: config.site.name, themes: config.themes })
99
+ console.log(`āœ… Favicons ready for ${config.site.name}\n`)
100
100
  }
101
101
  }
102
102
 
103
+ async function generateDevManifestAssets(config: MdsiteConfig): Promise<void> {
104
+ await generateWebManifest({ name: config.site.name, themes: config.themes })
105
+ }
106
+
103
107
  function ensureLegacyCompatibilityConfig(rootDir: string): string | undefined {
104
108
  const legacyConfigPath = path.join(rootDir, 'content.config.yml')
105
109
 
@@ -164,7 +164,8 @@ export function resolveContentDir(options: {
164
164
 
165
165
  if (resolvedConfigPath) {
166
166
  const configDir = path.dirname(resolvedConfigPath);
167
- return typeof rawConfig.content?.path === 'string' ? path.resolve(configDir, rawConfig.content.path) : configDir;
167
+ const contentPath = resolveContentConfigPath(rawConfig.content);
168
+ return contentPath ? path.resolve(configDir, contentPath) : configDir;
168
169
  }
169
170
 
170
171
  if (options.searchFrom) {
@@ -174,6 +175,24 @@ export function resolveContentDir(options: {
174
175
  return process.cwd();
175
176
  }
176
177
 
178
+ /**
179
+ * Extract the content path from either the shorthand string form
180
+ * (`content: docs`) or the explicit object form (`content:\n path: docs`).
181
+ * Returns undefined when no usable path is configured.
182
+ */
183
+ function resolveContentConfigPath(rawContent: unknown): string | undefined {
184
+ if (typeof rawContent === 'string') {
185
+ const trimmed = rawContent.trim();
186
+ return trimmed.length > 0 ? trimmed : undefined;
187
+ }
188
+
189
+ if (rawContent && typeof rawContent === 'object' && typeof (rawContent as { path?: unknown }).path === 'string') {
190
+ return (rawContent as { path: string }).path;
191
+ }
192
+
193
+ return undefined;
194
+ }
195
+
177
196
  function createDefaultMdsiteConfig(siteName: string): MdsiteConfig {
178
197
  return {
179
198
  favicon: '',
@@ -204,6 +223,7 @@ function createDefaultMdsiteConfig(siteName: string): MdsiteConfig {
204
223
 
205
224
  function normalizeMdsiteConfig(rawConfig: Record<string, any>, contentDir: string): MdsiteConfig {
206
225
  const fallbackConfig = createDefaultMdsiteConfig(path.basename(contentDir) || 'Site');
226
+ const contentPath = resolveContentConfigPath(rawConfig.content);
207
227
 
208
228
  return {
209
229
  favicon: typeof rawConfig.favicon === 'string' ? rawConfig.favicon : fallbackConfig.favicon,
@@ -211,7 +231,7 @@ function normalizeMdsiteConfig(rawConfig: Record<string, any>, contentDir: strin
211
231
  bibleTooltips: rawConfig.features?.bibleTooltips ?? fallbackConfig.features.bibleTooltips,
212
232
  sourceEdit: rawConfig.features?.sourceEdit ?? fallbackConfig.features.sourceEdit
213
233
  },
214
- content: typeof rawConfig.content?.path === 'string' ? { path: rawConfig.content.path } : fallbackConfig.content,
234
+ content: contentPath ? { path: contentPath } : fallbackConfig.content,
215
235
  menu: Array.isArray(rawConfig.menu) ? rawConfig.menu : fallbackConfig.menu,
216
236
  server: {
217
237
  output: typeof rawConfig.server?.output === 'string' ? rawConfig.server.output : fallbackConfig.server.output,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@life-and-dev/mdsite",
3
- "version": "0.2.3",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Local-first CLI that orchestrates mdsite-nuxt",
@@ -23,12 +23,12 @@
23
23
  },
24
24
  "scripts": {
25
25
  "build": "tsc -p tsconfig.json",
26
- "install-alias": "node scripts/mdsite-dev-alias.js install",
27
- "release:version": "node scripts/release-version.mjs",
28
- "uninstall-alias": "node scripts/mdsite-dev-alias.js uninstall",
29
- "typecheck": "tsc -p tsconfig.json --noEmit",
26
+ "install-alias": "node scripts/mdsite-dev-alias.ts install",
27
+ "release:version": "node scripts/release-version.ts",
28
+ "uninstall-alias": "node scripts/mdsite-dev-alias.ts uninstall",
29
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.scripts.json",
30
30
  "test": "vitest run",
31
- "verify:package": "node --experimental-strip-types scripts/verify-package-artifacts.ts",
31
+ "verify:package": "node scripts/verify-package-artifacts.ts",
32
32
  "prepublishOnly": "npm test && npm run typecheck && npm run build && npm run verify:package"
33
33
  },
34
34
  "dependencies": {