@yysng/astro-boilerplate 1.1.20 โ†’ 1.1.22

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.20",
3
+ "version": "1.1.22",
4
4
  "description": "Astro + Sanity Boilerplate with AEO Layers 1โ€“5",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,24 +1,15 @@
1
1
  import { CONTENT_REGISTRY } from "./registry.js";
2
2
  import { readLocal } from "./storage.js";
3
- import { getContentRoot } from "./config.js";
4
3
 
5
4
  export async function loadContent(key, env = {}) {
6
5
  const entry = CONTENT_REGISTRY[key];
7
6
  if (!entry) throw new Error(`Unknown content key: ${key}`);
8
7
 
9
- // ๐ŸŒ Production: Cloudflare KV only
10
8
  if (env?.CONTENT_KV) {
11
9
  const stored = await env.CONTENT_KV.get(entry.file, "json");
12
10
  if (stored) return stored;
13
-
14
- throw new Error(`KV missing content for key "${key}" (file "${entry.file}")`);
15
- }
16
-
17
- // ๐Ÿงช Local Node only
18
- const root = getContentRoot();
19
- if (!root) {
20
- throw new Error("Content root not configured in local environment");
11
+ throw new Error(`KV missing content for ${entry.file}`);
21
12
  }
22
13
 
23
- return await readLocal(root, entry.file);
14
+ return await readLocal(entry.file);
24
15
  }
@@ -2,28 +2,18 @@ import fs from "fs/promises";
2
2
  import path from "path";
3
3
  import { getContentRoot } from "./config.js";
4
4
 
5
- /**
6
- * Local filesystem read (Node only)
7
- */
8
5
  export async function readLocal(file) {
9
6
  const root = getContentRoot();
10
- if (!root) {
11
- throw new Error("Content root not configured");
12
- }
7
+ if (!root) throw new Error("Content root not configured");
13
8
 
14
9
  const filePath = path.join(root, file);
15
10
  const raw = await fs.readFile(filePath, "utf-8");
16
11
  return JSON.parse(raw);
17
12
  }
18
13
 
19
- /**
20
- * Local filesystem write (Node only)
21
- */
22
14
  export async function writeLocal(file, data) {
23
15
  const root = getContentRoot();
24
- if (!root) {
25
- throw new Error("Content root not configured");
26
- }
16
+ if (!root) throw new Error("Content root not configured");
27
17
 
28
18
  const filePath = path.join(root, file);
29
19
  await fs.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
@@ -5,7 +5,6 @@ import { CONTENT_REGISTRY } from "./registry.js";
5
5
 
6
6
  function mergeDefined(existing, incoming) {
7
7
  const result = { ...existing };
8
-
9
8
  for (const key of Object.keys(incoming)) {
10
9
  const value = incoming[key];
11
10
  if (value === undefined) continue;
@@ -16,7 +15,6 @@ function mergeDefined(existing, incoming) {
16
15
  result[key] = value;
17
16
  }
18
17
  }
19
-
20
18
  return result;
21
19
  }
22
20
 
@@ -25,19 +23,16 @@ export async function updateContent(key, incoming, env = {}) {
25
23
  if (!schema) throw new Error(`No schema for ${key}`);
26
24
 
27
25
  const entry = CONTENT_REGISTRY[key];
28
-
29
26
  const existing = await loadContent(key, env);
30
27
  const merged = mergeDefined(existing, incoming);
31
28
 
32
29
  schema.validate(merged);
33
30
 
34
- // ๐ŸŒ Production: Cloudflare KV
35
31
  if (env?.CONTENT_KV) {
36
32
  await env.CONTENT_KV.put(entry.file, JSON.stringify(merged));
37
33
  return merged;
38
34
  }
39
35
 
40
- // ๐Ÿ–ฅ๏ธ Local development
41
36
  await writeLocal(entry.file, merged);
42
37
  return merged;
43
38
  }