@edgedev/create-edge-site 1.0.10 → 1.0.12
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/nuxt.config.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { defineNuxtConfig } from 'nuxt/config'
|
|
2
2
|
|
|
3
3
|
export default defineNuxtConfig({
|
|
4
|
+
ssr: true,
|
|
4
5
|
nitro: {
|
|
5
|
-
preset: '
|
|
6
|
+
preset: 'cloudflare-pages',
|
|
7
|
+
prerender: {
|
|
8
|
+
crawlLinks: true,
|
|
9
|
+
routes: ['/'], // Starting point for the crawler
|
|
10
|
+
},
|
|
6
11
|
},
|
|
7
12
|
compatibilityDate: '2024-11-01',
|
|
8
13
|
app: {
|
package/package.json
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edgedev/create-edge-site",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Create Edge Starter Site",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-edge-site": "./bin/cli.js"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"preview": "nuxt preview",
|
|
9
|
+
"generate:images": "node scripts/generateImageManifest.mjs",
|
|
10
|
+
"build": "npm run generate:images && nuxt build",
|
|
11
|
+
"dev": "npm run generate:images && rm -rf .nuxt && nuxt dev --host --port=3000",
|
|
12
|
+
"generate": "npm run generate:images && nuxt generate",
|
|
13
|
+
"preview": "npm run generate:images && nuxt build && npx wrangler pages dev dist",
|
|
15
14
|
"postinstall": "nuxt prepare"
|
|
16
15
|
},
|
|
17
16
|
"dependencies": {
|
|
@@ -31,6 +30,7 @@
|
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
32
|
"@antfu/eslint-config": "^4.11.0",
|
|
34
|
-
"eslint": "^9"
|
|
33
|
+
"eslint": "^9",
|
|
34
|
+
"wrangler": "^4.14.4"
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import fs from 'node:fs/promises'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
const rootFolder = 'public/images'
|
|
5
|
+
const output = {}
|
|
6
|
+
|
|
7
|
+
async function scanFolder(dirPath) {
|
|
8
|
+
const entries = await fs.readdir(dirPath, { withFileTypes: true })
|
|
9
|
+
|
|
10
|
+
const folders = entries.filter(entry => entry.isDirectory())
|
|
11
|
+
const files = entries
|
|
12
|
+
.filter(entry => entry.isFile() && !entry.name.startsWith('.'))
|
|
13
|
+
.map(entry => entry.name)
|
|
14
|
+
|
|
15
|
+
// If only files, return array directly
|
|
16
|
+
if (folders.length === 0)
|
|
17
|
+
return files
|
|
18
|
+
|
|
19
|
+
// If contains folders (and maybe files), build object
|
|
20
|
+
const result = {}
|
|
21
|
+
|
|
22
|
+
if (files.length > 0) {
|
|
23
|
+
result[''] = files
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
for (const folder of folders) {
|
|
27
|
+
const fullPath = path.join(dirPath, folder.name)
|
|
28
|
+
result[folder.name] = await scanFolder(fullPath)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return result
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const baseFolders = await fs.readdir(rootFolder, { withFileTypes: true })
|
|
36
|
+
|
|
37
|
+
for (const base of baseFolders) {
|
|
38
|
+
if (!base.isDirectory())
|
|
39
|
+
continue
|
|
40
|
+
|
|
41
|
+
const basePath = path.join(rootFolder, base.name)
|
|
42
|
+
const scanResult = await scanFolder(basePath)
|
|
43
|
+
output[base.name] = scanResult
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const outputPath = path.join(rootFolder, 'image-manifest.json')
|
|
47
|
+
await fs.writeFile(outputPath, JSON.stringify(output, null, 2))
|
|
48
|
+
console.log(`✅ Image manifest written to ${outputPath}`)
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
console.error(`❌ Error generating image manifest`, err)
|
|
52
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export default defineEventHandler(async (event) => {
|
|
2
|
+
const rawParam = event.context.params?.path;
|
|
3
|
+
const pathSegments = Array.isArray(rawParam)
|
|
4
|
+
? rawParam
|
|
5
|
+
: typeof rawParam === 'string'
|
|
6
|
+
? rawParam.split('/')
|
|
7
|
+
: [];
|
|
8
|
+
|
|
9
|
+
const requestedPath = pathSegments.join('/');
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
const manifestModule = await import('~/public/images/image-manifest.json');
|
|
13
|
+
const manifest = manifestModule.default;
|
|
14
|
+
|
|
15
|
+
if (!manifest || typeof manifest !== 'object') {
|
|
16
|
+
return sendError(event, createError({
|
|
17
|
+
statusCode: 500,
|
|
18
|
+
statusMessage: 'Invalid or missing image manifest',
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (pathSegments.length === 0) {
|
|
23
|
+
return { images: manifest };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let current: unknown = manifest;
|
|
27
|
+
|
|
28
|
+
for (const segment of pathSegments) {
|
|
29
|
+
if (
|
|
30
|
+
!current ||
|
|
31
|
+
typeof current !== 'object' ||
|
|
32
|
+
Array.isArray(current) ||
|
|
33
|
+
!(segment in current)
|
|
34
|
+
) {
|
|
35
|
+
return sendError(event, createError({
|
|
36
|
+
statusCode: 404,
|
|
37
|
+
statusMessage: `No images found at path: ${requestedPath}`,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
current = (current as Record<string, unknown>)[segment];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return { images: current };
|
|
45
|
+
} catch (err) {
|
|
46
|
+
return sendError(event, createError({
|
|
47
|
+
statusCode: 500,
|
|
48
|
+
statusMessage: 'Failed to load image manifest',
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default defineEventHandler(async (event) => {
|
|
2
|
+
try {
|
|
3
|
+
const manifestModule = await import('~/public/images/image-manifest.json');
|
|
4
|
+
const manifest = manifestModule.default;
|
|
5
|
+
|
|
6
|
+
return { images: manifest };
|
|
7
|
+
} catch (err) {
|
|
8
|
+
return sendError(event, createError({
|
|
9
|
+
statusCode: 500,
|
|
10
|
+
statusMessage: 'Failed to load image manifest',
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
});
|
package/server/tsconfig.json
DELETED