@brightsideoy/kama 0.1.0-alpha.99 → 1.0.0-alpha.3

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.
Files changed (116) hide show
  1. package/README.md +169 -0
  2. package/bin/cli.js +775 -251
  3. package/content/definitions/blocks/button.yaml +24 -0
  4. package/content/definitions/blocks/header.yaml +13 -0
  5. package/content/definitions/blocks/header_image.yaml +21 -0
  6. package/content/definitions/blocks/hero.yaml +28 -0
  7. package/content/definitions/blocks/html.yaml +13 -0
  8. package/content/definitions/blocks/image_card.yaml +56 -0
  9. package/content/definitions/blocks/single_image.yaml +27 -0
  10. package/content/definitions/blocks/text.yaml +15 -0
  11. package/content/definitions/channels/ecommerce.yaml +28 -0
  12. package/content/definitions/channels/website.yaml +41 -0
  13. package/{defaults → content}/definitions/field-sets/access.yaml +3 -5
  14. package/content/definitions/field-sets/channel-base.yaml +57 -0
  15. package/{defaults/definitions/field-sets/page-meta.yaml → content/definitions/field-sets/channel-seo.yaml} +3 -11
  16. package/content/definitions/field-sets/content-block.yaml +41 -0
  17. package/content/definitions/field-sets/page-base.yaml +44 -0
  18. package/content/definitions/field-sets/page-seo.yaml +34 -0
  19. package/{defaults → content}/definitions/field-sets/page-social.yaml +6 -8
  20. package/content/definitions/field-sets/schema-type.yaml +43 -0
  21. package/content/definitions/field-sets/tree-base.yaml +31 -0
  22. package/content/definitions/node-layouts/content.yml +12 -0
  23. package/{defaults → content}/definitions/node-layouts/landing-page.yml +8 -3
  24. package/{defaults → content}/definitions/node-layouts/single-column.yml +10 -5
  25. package/{defaults → content}/definitions/node-layouts/two-column.yml +14 -6
  26. package/content/definitions/nodes/address.yaml +40 -0
  27. package/content/definitions/nodes/article.yaml +49 -0
  28. package/content/definitions/nodes/event.yaml +55 -0
  29. package/content/definitions/nodes/external-link.yaml +29 -0
  30. package/content/definitions/nodes/page-skeleton.yaml +48 -0
  31. package/{defaults → content}/definitions/nodes/page.yaml +9 -20
  32. package/content/definitions/nodes/person.yaml +37 -0
  33. package/content/definitions/nodes/product.yaml +89 -0
  34. package/content/definitions/taxonomies/categories.yaml +15 -0
  35. package/content/definitions/taxonomies/tags.yaml +12 -0
  36. package/content/definitions/trees/navigation.yaml +24 -0
  37. package/definitions/editor/default.ts +1 -0
  38. package/dist/assets/index-C3LzwJjY.css +1 -0
  39. package/dist/assets/index-DhguVxzs.js +164 -0
  40. package/dist/dist-cK3xGnBZ.js +26457 -0
  41. package/dist/index.html +4 -2
  42. package/dist/index.js +24028 -7125
  43. package/dist/schema-compiler.js +48 -0
  44. package/documentation/SCHEMAS.md +182 -0
  45. package/package.json +20 -24
  46. package/schema.sql +55 -23
  47. package/templates/astro-starter/astro.config.mjs +27 -0
  48. package/templates/astro-starter/package.json.template +20 -0
  49. package/templates/astro-starter/public/robots.txt +23 -0
  50. package/templates/astro-starter/src/components/blocks/BlockRenderer.astro +134 -0
  51. package/templates/astro-starter/src/components/blocks/ColumnLayout.astro +67 -0
  52. package/templates/astro-starter/src/components/blocks/HeaderImage.astro +132 -0
  53. package/templates/astro-starter/src/components/blocks/Hero.astro +218 -0
  54. package/templates/astro-starter/src/components/blocks/HtmlBlock.astro +25 -0
  55. package/templates/astro-starter/src/components/blocks/ImageBlock.astro +92 -0
  56. package/templates/astro-starter/src/components/blocks/TextBlock.astro +15 -0
  57. package/templates/astro-starter/src/components/global/Breadcrumb.astro +108 -0
  58. package/templates/astro-starter/src/components/global/Footer.astro +50 -0
  59. package/templates/astro-starter/src/components/global/Header.astro +171 -0
  60. package/templates/astro-starter/src/components/global/MetaHead.astro +266 -0
  61. package/templates/astro-starter/src/components/global/NavigationMenu.astro +413 -0
  62. package/templates/astro-starter/src/components/ui/KamaImage.astro +172 -0
  63. package/templates/astro-starter/src/layouts/SkeletonLayout.astro +56 -0
  64. package/templates/astro-starter/src/layouts/StandardLayout.astro +62 -0
  65. package/templates/astro-starter/src/lib/cms.ts +217 -0
  66. package/templates/astro-starter/src/lib/media/kama-image-service.ts +56 -0
  67. package/templates/astro-starter/src/lib/media/media-proxy.ts +129 -0
  68. package/templates/astro-starter/src/lib/media/media-url.ts +98 -0
  69. package/templates/astro-starter/src/middleware.ts +435 -0
  70. package/templates/astro-starter/src/pages/404.astro +46 -0
  71. package/templates/astro-starter/src/pages/[...slug].astro +243 -0
  72. package/templates/astro-starter/src/pages/llms-full.txt.ts +171 -0
  73. package/templates/astro-starter/src/pages/llms.txt.ts +113 -0
  74. package/templates/astro-starter/src/pages/media/[...path].ts +14 -0
  75. package/templates/astro-starter/src/pages/partials/footer.astro +69 -0
  76. package/templates/astro-starter/src/pages/partials/nav.astro +141 -0
  77. package/templates/astro-starter/src/styles/standard-theme.css +157 -0
  78. package/templates/astro-starter/src/utils/tiptap.ts +113 -0
  79. package/templates/astro-starter/tsconfig.json +0 -0
  80. package/templates/kama-worker/index.js +19 -0
  81. package/templates/kama-worker/server.js +104 -0
  82. package/wrangler.json +22 -0
  83. package/defaults/definitions/blocks/button.yaml +0 -15
  84. package/defaults/definitions/blocks/header.yaml +0 -15
  85. package/defaults/definitions/blocks/header_image.yaml +0 -22
  86. package/defaults/definitions/blocks/hero.yaml +0 -27
  87. package/defaults/definitions/blocks/image_card.yaml +0 -57
  88. package/defaults/definitions/blocks/single_image.yaml +0 -28
  89. package/defaults/definitions/blocks/text.yaml +0 -16
  90. package/defaults/definitions/channels/ecommerce.yaml +0 -24
  91. package/defaults/definitions/channels/website.yaml +0 -32
  92. package/defaults/definitions/field-sets/channel-base.yaml +0 -31
  93. package/defaults/definitions/field-sets/content-block.yaml +0 -46
  94. package/defaults/definitions/field-sets/page-base.yaml +0 -49
  95. package/defaults/definitions/field-sets/tree-base.yaml +0 -31
  96. package/defaults/definitions/node-layouts/three-column.yml +0 -41
  97. package/defaults/definitions/nodes/address.yaml +0 -32
  98. package/defaults/definitions/nodes/article.yaml +0 -43
  99. package/defaults/definitions/nodes/event.yaml +0 -49
  100. package/defaults/definitions/nodes/external-link.yaml +0 -26
  101. package/defaults/definitions/nodes/person.yaml +0 -37
  102. package/defaults/definitions/nodes/product.yaml +0 -86
  103. package/defaults/definitions/trees/navigation.yaml +0 -29
  104. package/defaults/definitions/trees/social-links.yaml +0 -9
  105. package/definitions/_page.yaml +0 -52
  106. package/dist/assets/index-D6qQsWOj.js +0 -1392
  107. package/dist/assets/index-TdW5F0pX.css +0 -1
  108. package/dist/media/kama/2026/08/17a098c92bc54ea4b4441e531a34575b.jpg +0 -0
  109. package/dist/media/kama/2026/08/3e9ae457dd23461680cc699f42d07cf0.jpg +0 -0
  110. package/dist/media/kama/2026/08/8e5b3a2fd194459f9b962f8e12928bf0.jpg +0 -0
  111. package/dist/media/kama/2026/08/8ea5c21026cd4944bdf78c99fe2544a9.jpg +0 -0
  112. package/scripts/bundle-definitions.js +0 -176
  113. /package/{defaults → content}/definitions/block-layouts/three-column.yaml +0 -0
  114. /package/{defaults → content}/definitions/block-layouts/two-column.yaml +0 -0
  115. /package/{defaults → content}/definitions/field-sets/comments.yaml +0 -0
  116. /package/{defaults → content}/definitions/field-sets/visibility.yaml +0 -0
@@ -0,0 +1,413 @@
1
+ ---
2
+ // src/components/global/NavigationMenu.astro
3
+ import type { TreeNode } from "@/lib/cms";
4
+
5
+ export interface Props {
6
+ tree?: TreeNode[];
7
+ }
8
+
9
+ const { tree = [] } = Astro.props;
10
+
11
+ const currentPath = Astro.url.pathname.replace(/\/$/, "") || "/";
12
+
13
+ // 🎯 FIX: Identify the root node in the tree structure
14
+ const rootNode =
15
+ tree.find(
16
+ item =>
17
+ item.path === "/" ||
18
+ item.path === "" ||
19
+ item.slug === "index" ||
20
+ (item as any).isRoot === true ||
21
+ (item as any).isRootNode === 1,
22
+ ) || tree[0];
23
+
24
+ // 🎯 FIX: If rootNode has children, display those children as top-level menu items.
25
+ // If not, filter out the root node by ID AND path.
26
+ const topLevelNavItems =
27
+ rootNode?.children && rootNode.children.length > 0
28
+ ? rootNode.children
29
+ : tree.filter(
30
+ item =>
31
+ item.id !== rootNode?.id &&
32
+ item.slug !== rootNode?.slug &&
33
+ item.path !== "/" &&
34
+ item.path !== "",
35
+ );
36
+
37
+ const isPathActive = (itemPath?: string) => {
38
+ const normItem = (itemPath || "").replace(/\/$/, "") || "/";
39
+ if (normItem === "/") return currentPath === "/";
40
+ return currentPath === normItem || currentPath.startsWith(`${normItem}/`);
41
+ };
42
+
43
+ const isExactActive = (itemPath?: string) => {
44
+ return currentPath === ((itemPath || "").replace(/\/$/, "") || "/");
45
+ };
46
+ ---
47
+
48
+ <!-- 2-LINE HAMBURGER TOGGLE BUTTON -->
49
+ <button
50
+ type="button"
51
+ class="mobile-toggle"
52
+ id="menu-toggle"
53
+ aria-label="Toggle Navigation Menu"
54
+ aria-expanded="false"
55
+ >
56
+ <span class="line line-1"></span>
57
+ <span class="line line-2"></span>
58
+ </button>
59
+
60
+ <!-- NAVIGATION BLOCK & FULLSCREEN CONTAINER -->
61
+ <nav class="nav-block" id="nav-overlay">
62
+ <ul class="nav-list">
63
+ {
64
+ topLevelNavItems.map(item => {
65
+ const hasChildren = item.children && item.children.length > 0;
66
+ const isParentActive = isPathActive(item.path);
67
+
68
+ if (hasChildren) {
69
+ return (
70
+ <li class="nav-item">
71
+ <details class="nav-details">
72
+ <summary
73
+ class:list={[
74
+ "nav-button",
75
+ "dropdown-summary",
76
+ { active: isParentActive },
77
+ ]}
78
+ >
79
+ <span>{item.title}</span>
80
+ <span class="indicator">▼</span>
81
+ </summary>
82
+ <div class="submenu-container">
83
+ <ul class="dropdown-panel">
84
+ <li>
85
+ <a
86
+ href={item.path}
87
+ class:list={[
88
+ "dropdown-item",
89
+ "overview-item",
90
+ { active: isExactActive(item.path) },
91
+ ]}
92
+ >
93
+ {item.title} Overview
94
+ </a>
95
+ </li>
96
+ {item.children?.map(child => (
97
+ <li>
98
+ <a
99
+ href={child.path}
100
+ class:list={[
101
+ "dropdown-item",
102
+ { active: isExactActive(child.path) },
103
+ ]}
104
+ >
105
+ {child.title}
106
+ </a>
107
+ </li>
108
+ ))}
109
+ </ul>
110
+ </div>
111
+ </details>
112
+ </li>
113
+ );
114
+ }
115
+
116
+ return (
117
+ <li class="nav-item">
118
+ <a
119
+ href={item.path}
120
+ class:list={["nav-button", { active: isExactActive(item.path) }]}
121
+ >
122
+ {item.title}
123
+ </a>
124
+ </li>
125
+ );
126
+ })
127
+ }
128
+ </ul>
129
+ </nav>
130
+
131
+ <script is:inline>
132
+ const initMobileMenu = () => {
133
+ const toggleBtn = document.getElementById("menu-toggle");
134
+ const navOverlay = document.getElementById("nav-overlay");
135
+
136
+ if (!toggleBtn || !navOverlay) return;
137
+
138
+ // Remove old listeners by replacing the nodes (prevents duplicate bindings)
139
+ const newToggleBtn = toggleBtn.cloneNode(true);
140
+ toggleBtn.parentNode.replaceChild(newToggleBtn, toggleBtn);
141
+
142
+ const closeMenu = () => {
143
+ newToggleBtn.setAttribute("aria-expanded", "false");
144
+ newToggleBtn.classList.remove("is-open");
145
+ navOverlay.classList.remove("is-open");
146
+ document.body.classList.remove("menu-lock-scroll");
147
+ };
148
+
149
+ newToggleBtn.addEventListener("click", e => {
150
+ e.stopPropagation();
151
+ const isOpen = newToggleBtn.getAttribute("aria-expanded") === "true";
152
+ newToggleBtn.setAttribute("aria-expanded", (!isOpen).toString());
153
+ newToggleBtn.classList.toggle("is-open");
154
+ navOverlay.classList.toggle("is-open");
155
+ document.body.classList.toggle("menu-lock-scroll");
156
+ });
157
+
158
+ // Close menu when clicking nav links
159
+ const navLinks = navOverlay.querySelectorAll("a");
160
+ navLinks.forEach(link => {
161
+ link.addEventListener("click", () => {
162
+ closeMenu();
163
+ });
164
+ });
165
+
166
+ // Close details dropdowns when clicking outside
167
+ document.addEventListener("click", event => {
168
+ const allDetails = document.querySelectorAll("details.nav-details");
169
+ allDetails.forEach(details => {
170
+ if (details.hasAttribute("open") && !details.contains(event.target)) {
171
+ details.removeAttribute("open");
172
+ }
173
+ });
174
+ });
175
+
176
+ window.addEventListener("pageshow", closeMenu);
177
+ };
178
+
179
+ // Run on first load
180
+ if (document.readyState === "loading") {
181
+ document.addEventListener("DOMContentLoaded", initMobileMenu);
182
+ } else {
183
+ initMobileMenu();
184
+ }
185
+
186
+ // Run on every Astro View Transition page navigation
187
+ document.addEventListener("astro:page-load", initMobileMenu);
188
+ </script>
189
+
190
+ <style>
191
+ .mobile-toggle {
192
+ display: flex;
193
+ flex-direction: column;
194
+ justify-content: center;
195
+ align-items: center;
196
+ gap: 6px;
197
+ width: 44px;
198
+ height: 44px;
199
+ background: transparent;
200
+ border: none;
201
+ cursor: pointer;
202
+ padding: 0;
203
+ z-index: 1001;
204
+ }
205
+ .mobile-toggle .line {
206
+ width: 22px;
207
+ height: 2px;
208
+ background-color: #0f172a;
209
+ transition:
210
+ transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
211
+ opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
212
+ transform-origin: center;
213
+ }
214
+ .mobile-toggle.is-open .line-1 {
215
+ transform: translateY(4px) rotate(45deg);
216
+ }
217
+ .mobile-toggle.is-open .line-2 {
218
+ transform: translateY(-4px) rotate(-45deg);
219
+ }
220
+ .nav-block {
221
+ position: fixed;
222
+ top: 0;
223
+ left: 0;
224
+ width: 100vw;
225
+ height: 100vh;
226
+ background-color: #ffffff;
227
+ padding: 80px 24px 40px 24px;
228
+ box-sizing: border-box;
229
+ display: flex;
230
+ flex-direction: column;
231
+ overflow-y: auto;
232
+ opacity: 0;
233
+ visibility: hidden;
234
+ pointer-events: none;
235
+ transition:
236
+ opacity 0.3s ease,
237
+ visibility 0.3s ease;
238
+ z-index: 1000;
239
+ }
240
+ .nav-block.is-open {
241
+ opacity: 1;
242
+ visibility: visible;
243
+ pointer-events: auto;
244
+ }
245
+
246
+ .nav-list {
247
+ display: flex;
248
+ flex-direction: column;
249
+ gap: 8px;
250
+ list-style: none;
251
+ margin: 0;
252
+ padding: 0;
253
+ width: 100%;
254
+ }
255
+ .nav-item {
256
+ position: relative;
257
+ width: 100%;
258
+ }
259
+ .nav-button {
260
+ display: flex;
261
+ align-items: center;
262
+ justify-content: space-between;
263
+ width: 100%;
264
+ height: 52px;
265
+ padding: 0 16px;
266
+ font-size: 18px;
267
+ font-weight: 500;
268
+ color: #334155;
269
+ text-decoration: none;
270
+ background: transparent;
271
+ border: none;
272
+ border-radius: 4px;
273
+ cursor: pointer;
274
+ box-sizing: border-box;
275
+ }
276
+ .nav-button:hover {
277
+ color: #0f172a;
278
+ background: #f8fafc;
279
+ }
280
+ .nav-button.active {
281
+ color: #0c4a6e;
282
+ font-weight: 600;
283
+ }
284
+ .dropdown-summary {
285
+ list-style: none;
286
+ user-select: none;
287
+ }
288
+ .dropdown-summary::-webkit-details-marker {
289
+ display: none;
290
+ }
291
+ .indicator {
292
+ font-size: 11px;
293
+ color: #64748b;
294
+ transition: transform 0.2s ease;
295
+ }
296
+ details[open] .indicator {
297
+ transform: rotate(180deg);
298
+ }
299
+ details.nav-details {
300
+ border-radius: 6px;
301
+ transition: background-color 0.2s ease;
302
+ }
303
+ details[open].nav-details {
304
+ background: #f8fafc;
305
+ padding-bottom: 8px;
306
+ }
307
+ .submenu-container {
308
+ position: relative;
309
+ margin-left: 24px;
310
+ padding-left: 16px;
311
+ border-left: 2px solid #cbd5e1;
312
+ }
313
+ .dropdown-panel {
314
+ list-style: none;
315
+ margin: 4px 0 0 0;
316
+ padding: 0;
317
+ display: flex;
318
+ flex-direction: column;
319
+ gap: 4px;
320
+ }
321
+ .dropdown-item {
322
+ display: block;
323
+ padding: 10px 12px;
324
+ font-size: 16px;
325
+ font-weight: 400;
326
+ color: #475569;
327
+ text-decoration: none;
328
+ border-radius: 4px;
329
+ transition:
330
+ background 0.15s ease,
331
+ color 0.15s ease;
332
+ }
333
+ .overview-item {
334
+ font-weight: 500;
335
+ color: #334155;
336
+ }
337
+ .dropdown-item:hover {
338
+ background: #e2e8f0;
339
+ color: #0f172a;
340
+ }
341
+ .dropdown-item.active {
342
+ font-weight: 600;
343
+ color: #0c4a6e;
344
+ background: #e0f2fe;
345
+ }
346
+ body.menu-lock-scroll {
347
+ overflow: hidden !important;
348
+ }
349
+
350
+ @media (min-width: 768px) {
351
+ .mobile-toggle {
352
+ display: none;
353
+ }
354
+ .nav-block {
355
+ position: static;
356
+ width: 100%;
357
+ height: auto;
358
+ background: transparent;
359
+ padding: 0;
360
+ opacity: 1;
361
+ visibility: visible;
362
+ pointer-events: auto;
363
+ overflow-y: visible;
364
+ display: block;
365
+ }
366
+ .nav-list {
367
+ flex-direction: row;
368
+ gap: 4px;
369
+ justify-content: flex-end;
370
+ }
371
+ .nav-item {
372
+ width: auto;
373
+ }
374
+ .nav-button {
375
+ display: inline-flex;
376
+ justify-content: flex-start;
377
+ gap: 6px;
378
+ height: 40px;
379
+ padding: 0 16px;
380
+ font-size: 14px;
381
+ border-radius: 4px;
382
+ margin-top: 4px;
383
+ }
384
+ details[open].nav-details {
385
+ background: transparent;
386
+ padding-bottom: 0;
387
+ }
388
+ .submenu-container {
389
+ margin-left: 0;
390
+ padding-left: 0;
391
+ border-left: none;
392
+ }
393
+ .dropdown-panel {
394
+ position: absolute;
395
+ top: 100%;
396
+ left: 0;
397
+ min-width: 220px;
398
+ background: #ffffff;
399
+ border: 1px solid #e2e8f0;
400
+ margin: 0;
401
+ gap: 0;
402
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
403
+ border-radius: 4px;
404
+ padding: 4px;
405
+ }
406
+ .dropdown-item {
407
+ font-size: 14px;
408
+ padding: 8px 16px;
409
+ border-radius: 4px;
410
+ border-bottom: none;
411
+ }
412
+ }
413
+ </style>
@@ -0,0 +1,172 @@
1
+ ---
2
+ // src/components/ui/KamaImage.astro
3
+
4
+ import {
5
+ buildAgnosticImageUrl,
6
+ isSvgImage,
7
+ getImageUri,
8
+ } from "@/lib/media/media-url";
9
+
10
+ interface Props {
11
+ image: any;
12
+ sizes?: string;
13
+ desktopWidths?: number[];
14
+ idealWidth?: number;
15
+ class?: string;
16
+ loading?: "lazy" | "eager";
17
+ fetchpriority?: "auto" | "high" | "low";
18
+ }
19
+
20
+ const {
21
+ image = {},
22
+ sizes = "100vw",
23
+ desktopWidths = [768, 1352],
24
+ idealWidth = 1352,
25
+ class: className = "",
26
+ loading = "lazy",
27
+ fetchpriority = "auto",
28
+ } = Astro.props;
29
+
30
+ // Unpack array wrappers if passed
31
+ const targetImage = Array.isArray(image) ? image[0] : image;
32
+
33
+ // 🎯 FIX 1: Support string paths in addition to object payloads
34
+ const isValidImage = Boolean(
35
+ targetImage &&
36
+ (typeof targetImage === "string" ||
37
+ targetImage.url ||
38
+ targetImage.path ||
39
+ targetImage.variants),
40
+ );
41
+
42
+ // Detect if this asset is a vector SVG
43
+ const isSvg =
44
+ isSvgImage(targetImage?.mimeType || "") ||
45
+ isSvgImage(targetImage?.filename || "") ||
46
+ isSvgImage(targetImage?.url || targetImage?.path || "") ||
47
+ (typeof targetImage === "string" && isSvgImage(targetImage));
48
+
49
+ const variants = targetImage?.variants || {};
50
+
51
+ // Resolve base paths using getImageUri to ensure CSP compliance & relativity
52
+ const rawMobileUrl = getImageUri(variants.mobile?.url);
53
+ const rawTabletUrl = getImageUri(variants.tablet?.url);
54
+ const rawDesktopUrl = getImageUri(
55
+ variants.standard?.url ||
56
+ targetImage?.url ||
57
+ targetImage?.path ||
58
+ targetImage,
59
+ );
60
+
61
+ const mobileW = Number(variants.mobile?.cropCoordinates?.width || 768);
62
+ const mobileH = Number(variants.mobile?.cropCoordinates?.height || 576);
63
+
64
+ const tabletW = Number(variants.tablet?.cropCoordinates?.width || 1024);
65
+ const tabletH = Number(variants.tablet?.cropCoordinates?.height || 512);
66
+
67
+ // 🎯 FIX 2: Omit explicit width/height attributes on SVGs if intrinsic dimensions are missing/0
68
+ const rawWidth = Number(
69
+ variants.standard?.cropCoordinates?.width || targetImage?.width,
70
+ );
71
+ const rawHeight = Number(
72
+ variants.standard?.cropCoordinates?.height || targetImage?.height,
73
+ );
74
+
75
+ const baseWidth =
76
+ rawWidth && !isNaN(rawWidth) && rawWidth > 0 ? rawWidth : idealWidth;
77
+ const baseHeight =
78
+ rawHeight && !isNaN(rawHeight) && rawHeight > 0
79
+ ? rawHeight
80
+ : Math.round(idealWidth * 0.5);
81
+
82
+ function buildAgnosticSrcset(
83
+ url: string,
84
+ targetWidths: number[],
85
+ quality = 75,
86
+ ): string {
87
+ if (!url) return "";
88
+ return targetWidths
89
+ .map(width => `${buildAgnosticImageUrl(url, width, quality)} ${width}w`)
90
+ .join(", ");
91
+ }
92
+
93
+ // Generate srcsets only for raster images
94
+ const mobileSrcset =
95
+ !isSvg && rawMobileUrl ? buildAgnosticSrcset(rawMobileUrl, [400, 768]) : null;
96
+
97
+ const tabletSrcset =
98
+ !isSvg && rawTabletUrl
99
+ ? buildAgnosticSrcset(rawTabletUrl, [768, 1024])
100
+ : null;
101
+
102
+ const desktopSrcset =
103
+ !isSvg && rawDesktopUrl
104
+ ? buildAgnosticSrcset(rawDesktopUrl, desktopWidths)
105
+ : null;
106
+
107
+ const fallbackUrl =
108
+ getImageUri(rawDesktopUrl, {
109
+ width: isSvg ? undefined : baseWidth,
110
+ quality: 75,
111
+ }) || "";
112
+ ---
113
+
114
+ {
115
+ isValidImage &&
116
+ (isSvg ? (
117
+ /* 🎯 Clean single <img> for SVG Vectors */
118
+ <img
119
+ src={fallbackUrl}
120
+ alt={targetImage.alt || targetImage.filename || ""}
121
+ width={rawWidth > 0 ? rawWidth : undefined}
122
+ height={rawHeight > 0 ? rawHeight : undefined}
123
+ loading={loading}
124
+ fetchpriority={fetchpriority}
125
+ decoding={loading === "eager" ? "sync" : "async"}
126
+ class={className}
127
+ />
128
+ ) : (
129
+ /* 🎯 Responsive <picture> for Raster Images (.png, .jpg, .webp) */
130
+ <picture>
131
+ {Boolean(mobileSrcset) && (
132
+ <source
133
+ media="(max-width: 767px)"
134
+ srcset={mobileSrcset as string}
135
+ sizes="(max-width: 767px) calc(100vw - 48px), 768px"
136
+ width={mobileW}
137
+ height={mobileH}
138
+ />
139
+ )}
140
+
141
+ {Boolean(tabletSrcset) && (
142
+ <source
143
+ media="(min-width: 768px) and (max-width: 1024px)"
144
+ srcset={tabletSrcset as string}
145
+ sizes="(max-width: 1024px) calc(100vw - 48px), 1024px"
146
+ width={tabletW}
147
+ height={tabletH}
148
+ />
149
+ )}
150
+
151
+ {Boolean(desktopSrcset) && (
152
+ <source
153
+ srcset={desktopSrcset as string}
154
+ sizes={sizes}
155
+ width={baseWidth}
156
+ height={baseHeight}
157
+ />
158
+ )}
159
+
160
+ <img
161
+ src={fallbackUrl}
162
+ alt={targetImage.alt || targetImage.filename || ""}
163
+ width={baseWidth}
164
+ height={baseHeight}
165
+ loading={loading}
166
+ fetchpriority={fetchpriority}
167
+ decoding={loading === "eager" ? "sync" : "async"}
168
+ class={className}
169
+ />
170
+ </picture>
171
+ ))
172
+ }
@@ -0,0 +1,56 @@
1
+ ---
2
+ // src/layouts/SkeletonLayout.astro
3
+
4
+ import MetaHead from "@/components/global/MetaHead.astro";
5
+
6
+ interface Props {
7
+ node: Record<string, any>;
8
+ content: Record<string, any>;
9
+ normalizedSlug: string;
10
+ isHomePage: boolean;
11
+ // 🎯 1. Added language to Props
12
+ language?: string;
13
+ }
14
+
15
+ // 🎯 2. Destructure language
16
+ const {
17
+ node = {},
18
+ content = {},
19
+ normalizedSlug,
20
+ isHomePage,
21
+ language,
22
+ } = Astro.props;
23
+
24
+ const customCss = node.css || "";
25
+ const customJsHeader = node.jsHeader || "";
26
+ const customJsFooter = node.jsFooter || "";
27
+
28
+ // Now this works without crashing!
29
+ const pageLang = language || node?.language || "en";
30
+ ---
31
+
32
+ <!doctype html>
33
+ <html lang={pageLang}>
34
+ <head>
35
+ <MetaHead
36
+ node={node}
37
+ content={content}
38
+ normalizedSlug={normalizedSlug}
39
+ isHomePage={isHomePage}
40
+ />
41
+
42
+ <!-- 🎯 3. Added is:inline so Astro actually renders your database CSS -->
43
+ {customCss && <style is:inline set:html={customCss} />}
44
+
45
+ <!-- 🎯 4. Added is:inline so Astro executes your header JS -->
46
+ {customJsHeader && <script is:inline set:html={customJsHeader} />}
47
+ </head>
48
+
49
+ <body>
50
+ <!-- Renders your Blocks (like the HTML Block) natively -->
51
+ <slot />
52
+
53
+ <!-- 🎯 5. Added is:inline to footer JS -->
54
+ {customJsFooter && <script is:inline set:html={customJsFooter} />}
55
+ </body>
56
+ </html>
@@ -0,0 +1,62 @@
1
+ ---
2
+ // src/layouts/StandardLayout.astro
3
+
4
+ import "@/styles/standard-theme.css";
5
+ import Header from "@/components/global/Header.astro";
6
+ import Footer from "@/components/global/Footer.astro";
7
+ import MetaHead from "@/components/global/MetaHead.astro";
8
+ import type { TreeNode, ContentBlock } from "@/lib/cms";
9
+
10
+ interface Props {
11
+ node: Record<string, any>;
12
+ content: Record<string, ContentBlock[]>;
13
+ normalizedSlug: string;
14
+ isHomePage: boolean;
15
+ hasSidebar?: boolean;
16
+ headerBlocks?: ContentBlock[];
17
+ tree?: TreeNode[];
18
+ language?: string;
19
+ }
20
+
21
+ const {
22
+ node = {},
23
+ content = {},
24
+ normalizedSlug,
25
+ isHomePage,
26
+ headerBlocks = [],
27
+ tree,
28
+ language,
29
+ } = Astro.props;
30
+
31
+ // 🎯 Language Cascade
32
+ const pageLang = language || node?.language || undefined;
33
+
34
+ // 🎯 Extract the footer blocks the backend already thoughtfully provided
35
+ const footerBlocks = content?.footer || [];
36
+ ---
37
+
38
+ <!doctype html>
39
+ <html lang={pageLang}>
40
+ <head>
41
+ <MetaHead
42
+ node={node}
43
+ content={content}
44
+ normalizedSlug={normalizedSlug}
45
+ isHomePage={isHomePage}
46
+ headerBlocks={headerBlocks}
47
+ resolvedLanguage={pageLang}
48
+ />
49
+ </head>
50
+ <body>
51
+ <Header node={node} tree={tree} />
52
+
53
+ <main class="content-block">
54
+ <div class="content-container">
55
+ <slot />
56
+ </div>
57
+ </main>
58
+
59
+ <!-- 🎯 Pass the blocks and content map directly -->
60
+ <Footer blocks={footerBlocks} contentMap={content} />
61
+ </body>
62
+ </html>