@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.
- package/README.md +72 -178
- package/dist/commands/commands.test.js +53 -13
- package/dist/commands/commands.test.js.map +1 -1
- package/dist/commands/init.js +71 -27
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/workflows.test.js +70 -2
- package/dist/commands/workflows.test.js.map +1 -1
- package/dist/config/mdsite-config.js +19 -2
- package/dist/config/mdsite-config.js.map +1 -1
- package/dist/config/mdsite-config.test.js +15 -0
- package/dist/config/mdsite-config.test.js.map +1 -1
- package/dist/index.js +1 -1
- package/mdsite-nuxt/app/components/content/ProsePre.vue +4 -0
- package/mdsite-nuxt/app/composables/useAppTheme.ts +4 -0
- package/mdsite-nuxt/nuxt.config.ts +2 -2
- package/mdsite-nuxt/scripts/generate-favicons.test.ts +55 -1
- package/mdsite-nuxt/scripts/generate-favicons.ts +25 -12
- package/mdsite-nuxt/scripts/renderer-hooks.test.ts +48 -5
- package/mdsite-nuxt/scripts/renderer-hooks.ts +12 -8
- package/mdsite-nuxt/utils/mdsite-config.ts +22 -2
- package/package.json +6 -6
|
@@ -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
|
|
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(
|
|
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(
|
|
90
|
+
await generateFaviconAssets(config)
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
async function generateFaviconAssets(
|
|
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(
|
|
99
|
-
console.log(`ā
Favicons ready for ${
|
|
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
|
-
|
|
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:
|
|
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.
|
|
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.
|
|
27
|
-
"release:version": "node scripts/release-version.
|
|
28
|
-
"uninstall-alias": "node scripts/mdsite-dev-alias.
|
|
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
|
|
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": {
|