@yysng/astro-boilerplate 1.1.15 → 1.1.16
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 +1 -1
- package/src/content-system/loader.js +9 -14
package/package.json
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
import { CONTENT_REGISTRY } from "./registry.js";
|
|
2
2
|
import { readLocal } from "./storage.js";
|
|
3
|
-
|
|
4
|
-
// Edge-safe bundled content (used when no filesystem)
|
|
5
|
-
const edgeContent = import.meta.glob("/src/content/*.json", { eager: true });
|
|
3
|
+
import { getContentRoot } from "./config.js";
|
|
6
4
|
|
|
7
5
|
export async function loadContent(key, env = {}) {
|
|
8
6
|
const entry = CONTENT_REGISTRY[key];
|
|
9
7
|
if (!entry) throw new Error(`Unknown content key: ${key}`);
|
|
10
8
|
|
|
11
|
-
//
|
|
12
|
-
if (env.CONTENT_KV) {
|
|
9
|
+
// 🧠 Production: Cloudflare KV
|
|
10
|
+
if (env && env.CONTENT_KV) {
|
|
13
11
|
const stored = await env.CONTENT_KV.get(entry.file, "json");
|
|
14
12
|
if (stored) return stored;
|
|
13
|
+
throw new Error(`Missing content in KV: ${entry.file}`);
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
throw new Error(`Edge content not found: ${entry.file}`);
|
|
22
|
-
}
|
|
23
|
-
return mod.default;
|
|
16
|
+
// 🧪 Local dev: filesystem
|
|
17
|
+
const root = getContentRoot();
|
|
18
|
+
if (!root) {
|
|
19
|
+
throw new Error("Content root not configured in local environment");
|
|
24
20
|
}
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
return await readLocal(env.CONTENT_ROOT, entry.file);
|
|
22
|
+
return await readLocal(root, entry.file);
|
|
28
23
|
}
|