@yysng/astro-boilerplate 1.1.28 → 1.1.30

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.28",
3
+ "version": "1.1.30",
4
4
  "description": "Astro + Sanity Boilerplate with AEO Layers 1–5",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,8 +19,5 @@
19
19
  "@portabletext/to-html": "^4.0.1",
20
20
  "astro": "^5.0.0",
21
21
  "sanity": "^4.0.0"
22
- },
23
- "dependencies": {
24
- "@yysng/astro-boilerplate": "^1.1.26"
25
22
  }
26
23
  }
@@ -2,10 +2,9 @@ let contentRoot = null;
2
2
 
3
3
  export function setContentRoot(path) {
4
4
  contentRoot = path;
5
+ globalThis.__CONTENT_ROOT__ = path;
5
6
  }
6
7
 
7
8
  export function getContentRoot() {
8
- // When running on edge, we no longer require filesystem root.
9
- // Loader will use import.meta.glob instead.
10
9
  return contentRoot;
11
10
  }
@@ -5,13 +5,13 @@ export async function loadContent(key, env = {}) {
5
5
  const entry = CONTENT_REGISTRY[key];
6
6
  if (!entry) throw new Error(`Unknown content key: ${key}`);
7
7
 
8
- // Edge path — ONLY KV
8
+ // Cloudflare runtime
9
9
  if (env?.CONTENT_KV) {
10
10
  const stored = await env.CONTENT_KV.get(entry.file, "json");
11
- if (!stored) throw new Error(`Missing KV content: ${entry.file}`);
12
- return stored;
11
+ if (stored) return stored;
12
+ throw new Error(`KV missing content for key "${key}"`);
13
13
  }
14
14
 
15
- // Local dev path — filesystem only
15
+ // Local dev
16
16
  return await readLocal(entry.file);
17
17
  }
@@ -1,10 +1,12 @@
1
- let storage;
1
+ const isEdge = typeof process === "undefined";
2
2
 
3
- if (typeof process !== "undefined" && process.versions?.node) {
4
- storage = await import("./storage.node.js");
3
+ let impl;
4
+
5
+ if (isEdge) {
6
+ impl = await import("./storage.edge.js");
5
7
  } else {
6
- storage = await import("./storage.edge.js");
8
+ impl = await import("./storage.node.js");
7
9
  }
8
10
 
9
- export const readLocal = storage.readLocal;
10
- export const writeLocal = storage.writeLocal;
11
+ export const readLocal = impl.readLocal;
12
+ export const writeLocal = impl.writeLocal;