@flyo/nitro-astro 1.0.3 → 1.0.4

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,11 +1,12 @@
1
1
  {
2
2
  "name": "@flyo/nitro-astro",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Astro Framework",
5
5
  "main": "./dist/nitro-astro.js",
6
6
  "module": "./dist/nitro-astro.mjs",
7
7
  "files": [
8
- "dist"
8
+ "dist",
9
+ "src/components"
9
10
  ],
10
11
  "author": "Basil Suter <git@nadar.io>",
11
12
  "license": "MIT",
@@ -24,6 +25,6 @@
24
25
  "url": "https://github.com/flyocloud/nitro-astro"
25
26
  },
26
27
  "dependencies": {
27
- "@flyo/nitro-js": "^1.0.5"
28
+ "@flyo/nitro-js": "^1.0.6"
28
29
  }
29
30
  }
@@ -0,0 +1,11 @@
1
+ ---
2
+ interface Props {
3
+ block: object
4
+ }
5
+
6
+ const { block } = Astro.props
7
+ ---
8
+
9
+ <div style="margin: 20px 0; padding: 10px; border-radius: 5px; background-color: #DC143C; color: white;">
10
+ Can't find <strong>{block.component}</strong> in the Projects component folder.
11
+ </div>
@@ -0,0 +1,2 @@
1
+ import FallbackComponent from "./FallbackComponent.astro"
2
+ export default FallbackComponent
@@ -0,0 +1,29 @@
1
+ ---
2
+ import * as components from 'virtual:flyo-components'
3
+ import type { AstroComponentFactory } from "astro/dist/runtime/server"
4
+ import camelcase from "camelcase"
5
+
6
+ interface Props {
7
+ block: object;
8
+ [prop: string]: unknown;
9
+ }
10
+
11
+ const { block, ...props } = Astro.props;
12
+
13
+ /* @vite-ignore */
14
+ let Component: AstroComponentFactory | null = null
15
+
16
+ const key : string = camelcase(block.component)
17
+ const componentFound : boolean = key in components
18
+
19
+ if (componentFound) {
20
+ Component = components[key]
21
+ } else {
22
+ Component = components.fallback
23
+ }
24
+
25
+ ---
26
+
27
+ <div onclick={`openBlockInFlyo('${block.uid}')`}>
28
+ {Component && <Component block={block} {...props} />}
29
+ </div>
@@ -0,0 +1,2 @@
1
+ import FlyoNitroBlock from "./FlyoNitroBlock.astro";
2
+ export default FlyoNitroBlock;
@@ -0,0 +1,14 @@
1
+ ---
2
+ import FlyoNitroBlock from './FlyoNitroBlock.astro';
3
+
4
+ interface Props {
5
+ page: object;
6
+ }
7
+
8
+ const { page } = Astro.props
9
+
10
+ ---
11
+
12
+ {page.json.map((block: object) => (
13
+ <FlyoNitroBlock block={block} />
14
+ ))}
@@ -0,0 +1,2 @@
1
+ import FlyoNitroPage from "./FlyoNitroPage.astro";
2
+ export default FlyoNitroPage;