create-kide-app 0.0.22 → 0.0.23

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": "create-kide-app",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "description": "Scaffold a new Kide CMS project",
5
5
  "author": "Matti Hernesniemi",
6
6
  "license": "MIT",
@@ -0,0 +1,28 @@
1
+ ---
2
+ const { blocks = [] } = Astro.props as { blocks?: Array<Record<string, unknown>> };
3
+
4
+ // Discover custom block components from src/components/blocks/
5
+ const customComponents = import.meta.glob<{ default: any }>("./blocks/*.astro", { eager: true });
6
+
7
+ const componentMap: Record<string, any> = {};
8
+ for (const [path, mod] of Object.entries(customComponents)) {
9
+ const filename = path.split("/").pop()?.replace(".astro", "") ?? "";
10
+ const typeName = filename.charAt(0).toLowerCase() + filename.slice(1);
11
+ componentMap[typeName] = mod.default;
12
+ }
13
+ ---
14
+
15
+ <div>
16
+ {
17
+ blocks.map((block) => {
18
+ const type = String(block.type ?? "");
19
+ const Component = componentMap[type];
20
+ if (!Component) {
21
+ throw new Error(
22
+ `No block component found for type "${type}". Add src/components/blocks/${type.charAt(0).toUpperCase() + type.slice(1)}.astro`,
23
+ );
24
+ }
25
+ return <Component {...block} />;
26
+ })
27
+ }
28
+ </div>