@life-and-dev/mdsite 0.1.1 → 0.2.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/README.md +39 -21
- package/dist/commands/commands.test.js +91 -30
- package/dist/commands/commands.test.js.map +1 -1
- package/dist/commands/init.js +54 -4
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/prepare.js +22 -14
- package/dist/commands/prepare.js.map +1 -1
- package/dist/commands/prepare.test.js +33 -39
- package/dist/commands/prepare.test.js.map +1 -1
- package/dist/commands/preview.d.ts +1 -0
- package/dist/commands/preview.js +11 -10
- package/dist/commands/preview.js.map +1 -1
- package/dist/commands/start.d.ts +1 -0
- package/dist/commands/start.js +23 -10
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/stop.js +6 -3
- package/dist/commands/stop.js.map +1 -1
- package/dist/commands/workflows.test.js +76 -19
- package/dist/commands/workflows.test.js.map +1 -1
- package/dist/config/mdsite-config.js +1 -1
- package/dist/config/mdsite-config.js.map +1 -1
- package/dist/config/mdsite-config.test.js +1 -1
- package/dist/config/mdsite-config.test.js.map +1 -1
- package/dist/config/menu.js +0 -1
- package/dist/config/menu.js.map +1 -1
- package/dist/index.js +42 -7
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +40 -0
- package/dist/index.test.js.map +1 -1
- package/dist/process/child-process.test.js +3 -3
- package/dist/process/child-process.test.js.map +1 -1
- package/dist/process/runtime-state.d.ts +6 -5
- package/dist/process/runtime-state.js +13 -17
- package/dist/process/runtime-state.js.map +1 -1
- package/dist/process/runtime-state.test.js +21 -13
- package/dist/process/runtime-state.test.js.map +1 -1
- package/dist/renderer/mdsite-nuxt.d.ts +2 -0
- package/dist/renderer/mdsite-nuxt.js +29 -32
- package/dist/renderer/mdsite-nuxt.js.map +1 -1
- package/dist/renderer/mdsite-nuxt.test.js +37 -48
- package/dist/renderer/mdsite-nuxt.test.js.map +1 -1
- package/mdsite-nuxt/app/composables/useAppTheme.ts +22 -3
- package/mdsite-nuxt/app/config/themes.ts +38 -0
- package/mdsite-nuxt/app/pages/[...slug].vue +4 -2
- package/mdsite-nuxt/app/pages/index.vue +4 -2
- package/mdsite-nuxt/assets/default-favicon.svg +223 -0
- package/mdsite-nuxt/nuxt.config.ts +11 -1
- package/mdsite-nuxt/scripts/generate-favicons.test.ts +123 -0
- package/mdsite-nuxt/scripts/generate-favicons.ts +60 -61
- package/mdsite-nuxt/scripts/renderer-hooks.test.ts +0 -8
- package/mdsite-nuxt/scripts/renderer-hooks.ts +1 -2
- package/mdsite-nuxt/scripts/sync-content.ts +5 -79
- package/package.json +1 -1
|
@@ -18,15 +18,6 @@ const STATIC_FILES = [
|
|
|
18
18
|
'site.webmanifest',
|
|
19
19
|
'robots.txt'
|
|
20
20
|
]
|
|
21
|
-
const LOGO_FILE = 'logo.svg'
|
|
22
|
-
const FAVICON_DIR = 'favicon'
|
|
23
|
-
const FAVICON_FILES = [
|
|
24
|
-
'favicon.svg',
|
|
25
|
-
'favicon.ico',
|
|
26
|
-
'apple-touch-icon.png',
|
|
27
|
-
'icon-192.png',
|
|
28
|
-
'icon-512.png'
|
|
29
|
-
]
|
|
30
21
|
|
|
31
22
|
// Debounce timers for JSON regeneration (5 second delay)
|
|
32
23
|
let navigationDebounceTimer: NodeJS.Timeout | null = null
|
|
@@ -118,45 +109,26 @@ export async function generateJsonFiles() {
|
|
|
118
109
|
}
|
|
119
110
|
|
|
120
111
|
/**
|
|
121
|
-
* Copy all images
|
|
112
|
+
* Copy all images from content to public directory (one-time)
|
|
122
113
|
*/
|
|
123
114
|
export async function copyAllImages() {
|
|
124
115
|
const sourceDir = getSourceDir()
|
|
125
116
|
const targetDir = getTargetDir()
|
|
126
117
|
|
|
127
|
-
console.log(`📦 Copying images
|
|
118
|
+
console.log(`📦 Copying images from: ${sourceDir}`)
|
|
128
119
|
console.log(`📦 Target directory: ${targetDir}`)
|
|
129
120
|
|
|
130
121
|
let copiedCount = 0
|
|
131
122
|
|
|
132
|
-
// Copy images (excluding logo.svg and favicon directory - handled separately)
|
|
133
123
|
for (const ext of IMAGE_EXTS) {
|
|
134
124
|
const files = await getAllFiles(sourceDir, ext)
|
|
135
125
|
|
|
136
126
|
for (const sourcePath of files) {
|
|
137
|
-
|
|
138
|
-
// Skip files in favicon directory - handled separately
|
|
139
|
-
if (sourcePath.includes(`${path.sep}${FAVICON_DIR}${path.sep}`)) {
|
|
140
|
-
continue
|
|
141
|
-
}
|
|
142
|
-
|
|
143
127
|
await copyImage(sourcePath, false)
|
|
144
128
|
copiedCount++
|
|
145
129
|
}
|
|
146
130
|
}
|
|
147
131
|
|
|
148
|
-
// Copy favicon files
|
|
149
|
-
const faviconDir = path.join(sourceDir, FAVICON_DIR)
|
|
150
|
-
if (await fs.pathExists(faviconDir)) {
|
|
151
|
-
for (const faviconFile of FAVICON_FILES) {
|
|
152
|
-
const sourcePath = path.join(faviconDir, faviconFile)
|
|
153
|
-
if (await fs.pathExists(sourcePath)) {
|
|
154
|
-
await copyFaviconFile(sourcePath, false)
|
|
155
|
-
copiedCount++
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
132
|
console.log(`✓ Copied ${copiedCount} file(s)\n`)
|
|
161
133
|
}
|
|
162
134
|
|
|
@@ -221,9 +193,7 @@ export async function startWatcher() {
|
|
|
221
193
|
watcher
|
|
222
194
|
.on('add', (filePath) => {
|
|
223
195
|
const fileName = path.basename(filePath)
|
|
224
|
-
if (fileName
|
|
225
|
-
handleLogoChange(filePath, 'added')
|
|
226
|
-
} else if (fileName.endsWith('.md')) {
|
|
196
|
+
if (fileName.endsWith('.md')) {
|
|
227
197
|
// Markdown file added - regenerate both navigation and search
|
|
228
198
|
console.log(`📝 Markdown added: ${fileName}`)
|
|
229
199
|
regenerateNavigation()
|
|
@@ -234,9 +204,7 @@ export async function startWatcher() {
|
|
|
234
204
|
})
|
|
235
205
|
.on('change', (filePath) => {
|
|
236
206
|
const fileName = path.basename(filePath)
|
|
237
|
-
if (fileName
|
|
238
|
-
handleLogoChange(filePath, 'updated')
|
|
239
|
-
} else if (fileName.endsWith('.md')) {
|
|
207
|
+
if (fileName.endsWith('.md')) {
|
|
240
208
|
// Markdown file changed - regenerate both navigation and search
|
|
241
209
|
console.log(`📝 Markdown updated: ${fileName}`)
|
|
242
210
|
regenerateNavigation()
|
|
@@ -247,9 +215,7 @@ export async function startWatcher() {
|
|
|
247
215
|
})
|
|
248
216
|
.on('unlink', (filePath) => {
|
|
249
217
|
const fileName = path.basename(filePath)
|
|
250
|
-
if (fileName
|
|
251
|
-
console.log(`🗑️ Logo removed: ${fileName}`)
|
|
252
|
-
} else if (fileName.endsWith('.md')) {
|
|
218
|
+
if (fileName.endsWith('.md')) {
|
|
253
219
|
// Markdown file deleted - regenerate both navigation and search
|
|
254
220
|
console.log(`📝 Markdown deleted: ${fileName}`)
|
|
255
221
|
regenerateNavigation()
|
|
@@ -363,46 +329,6 @@ async function isDraftOnlyImage(imagePath: string): Promise<boolean> {
|
|
|
363
329
|
return !hasPublishedVersion && hasDraftVersion
|
|
364
330
|
}
|
|
365
331
|
|
|
366
|
-
/**
|
|
367
|
-
* Copy a single favicon file from content to public
|
|
368
|
-
*/
|
|
369
|
-
async function copyFaviconFile(sourcePath: string, log: boolean = true, action: string = 'copied') {
|
|
370
|
-
try {
|
|
371
|
-
const targetDir = getTargetDir()
|
|
372
|
-
const fileName = path.basename(sourcePath)
|
|
373
|
-
const targetPath = path.join(targetDir, fileName)
|
|
374
|
-
|
|
375
|
-
await fs.ensureDir(targetDir)
|
|
376
|
-
await fs.copy(sourcePath, targetPath)
|
|
377
|
-
|
|
378
|
-
if (log) {
|
|
379
|
-
console.log(`✓ Favicon ${action}: ${fileName}`)
|
|
380
|
-
}
|
|
381
|
-
} catch (error) {
|
|
382
|
-
console.error(`❌ Failed to copy favicon ${sourcePath}:`, error)
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Handle logo.svg changes - regenerate favicons
|
|
388
|
-
*/
|
|
389
|
-
async function handleLogoChange(logoPath: string, action: string) {
|
|
390
|
-
const domain = getContentDomain()
|
|
391
|
-
console.log(`🎨 Logo ${action}, regenerating favicons for ${domain}...`)
|
|
392
|
-
|
|
393
|
-
try {
|
|
394
|
-
const { generateFavicons, copyFaviconsToPublic } = await import('./generate-favicons.js')
|
|
395
|
-
const success = await generateFavicons(domain)
|
|
396
|
-
|
|
397
|
-
if (success) {
|
|
398
|
-
await copyFaviconsToPublic(domain)
|
|
399
|
-
console.log(`✓ Favicons regenerated for ${domain}\n`)
|
|
400
|
-
}
|
|
401
|
-
} catch (error) {
|
|
402
|
-
console.error(`❌ Failed to regenerate favicons:`, error)
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
332
|
/**
|
|
407
333
|
* Get all files with specific extension recursively
|
|
408
334
|
*/
|