@yysng/astro-boilerplate 1.1.7 → 1.1.9

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.7",
3
+ "version": "1.1.9",
4
4
  "description": "Astro + Sanity Boilerplate with AEO Layers 1–5",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,13 +1,23 @@
1
- import fs from "fs/promises";
2
- import path from "path";
3
- import { CONTENT_REGISTRY } from "./registry.js";
4
- import { getContentRoot } from "./config.js";
5
-
6
- export async function loadContent(key) {
7
- const entry = CONTENT_REGISTRY[key];
8
- if (!entry) throw new Error(`Unknown content key: ${key}`);
9
-
10
- const filePath = path.join(getContentRoot(), entry.file);
11
- const raw = await fs.readFile(filePath, "utf-8");
12
- return JSON.parse(raw);
13
- }
1
+ // src/content-system/loader.js
2
+
3
+ import hero from "../content/hero.json";
4
+ import cta from "../content/cta.json";
5
+ import about from "../content/about.json";
6
+ import testimonials from "../content/testimonials.json";
7
+
8
+ const CONTENT_CACHE = {
9
+ hero,
10
+ cta,
11
+ about,
12
+ testimonials
13
+ };
14
+
15
+ export function loadContent(key) {
16
+ const data = CONTENT_CACHE[key];
17
+
18
+ if (!data) {
19
+ throw new Error(`Unknown content key: ${key}`);
20
+ }
21
+
22
+ return data;
23
+ }
@@ -1,6 +1,7 @@
1
1
  export const schemas = {
2
2
  hero: {
3
3
  required: ["title", "subtitle"],
4
+ // CTA remains optional by validation logic
4
5
  validate(data) {
5
6
  if (typeof data.title !== "string") {
6
7
  throw new Error("Hero.title must be a string");
@@ -24,5 +25,30 @@ export const schemas = {
24
25
  }
25
26
  }
26
27
  }
28
+ },
29
+
30
+ cta: {
31
+ required: ["heading", "button"],
32
+ validate(data) {
33
+ if (typeof data.heading !== "string") {
34
+ throw new Error("CTA.heading must be a string");
35
+ }
36
+
37
+ if (data.description && typeof data.description !== "string") {
38
+ throw new Error("CTA.description must be a string");
39
+ }
40
+
41
+ if (!data.button || typeof data.button !== "object") {
42
+ throw new Error("CTA.button must be an object");
43
+ }
44
+
45
+ if (typeof data.button.label !== "string") {
46
+ throw new Error("CTA.button.label must be a string");
47
+ }
48
+
49
+ if (typeof data.button.href !== "string") {
50
+ throw new Error("CTA.button.href must be a string");
51
+ }
27
52
  }
53
+ },
28
54
  };