@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yysng/astro-boilerplate",
3
- "version": "1.1.15",
3
+ "version": "1.1.16",
4
4
  "description": "Astro + Sanity Boilerplate with AEO Layers 1–5",
5
5
  "type": "module",
6
6
  "exports": {
@@ -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
- // 1️⃣ Cloudflare production: KV first
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
- // 2️⃣ Edge runtime fallback (no filesystem available)
18
- if (!env.CONTENT_ROOT) {
19
- const mod = edgeContent[`/src/content/${entry.file}`];
20
- if (!mod || !mod.default) {
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
- // 3️⃣ Local Node development (filesystem)
27
- return await readLocal(env.CONTENT_ROOT, entry.file);
22
+ return await readLocal(root, entry.file);
28
23
  }