@schneiderelli/cms-runtime 0.0.1 → 0.0.2

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.
@@ -1,12 +1,78 @@
1
1
  <script lang="ts">
2
- import { resolveBlockComponent } from '../resolve.js';
3
- import type { Block } from '../types.js';
4
-
5
- let { blocks } = $props<{
6
- blocks: Block[];
7
- }>();
2
+ import type {
3
+ Block,
4
+ TextBlock,
5
+ HeadingBlock,
6
+ ImageBlock,
7
+ MarkdownBlock,
8
+ QuoteBlock,
9
+ DividerBlock,
10
+ FaqBlock,
11
+ HowToBlock
12
+ } from "../types.js";
13
+ import { marked } from "marked";
14
+ let { blocks } = $props<{ blocks: Block[] }>();
8
15
  </script>
9
16
 
17
+ <div class="block-container">
10
18
  {#each blocks as block}
11
- {@render resolveBlockComponent(block)(block)}
19
+ {#if block.type === "heading"}
20
+ <h1 style:margin-bottom="1rem">
21
+ {(block as HeadingBlock).text}
22
+ </h1>
23
+
24
+ {:else if block.type === "text"}
25
+ <p>
26
+ {(block as TextBlock).content}
27
+ </p>
28
+
29
+ {:else if block.type === "image"}
30
+ <img
31
+ src={(block as ImageBlock).src}
32
+ alt={(block as ImageBlock).alt ?? ""}
33
+ style="max-width: 100%; height: auto; margin: 1rem 0;"
34
+ />
35
+
36
+ {:else if block.type === "markdown"}
37
+ <div class="markdown">
38
+ {@html marked((block as MarkdownBlock).content)}
39
+ </div>
40
+
41
+ {:else if block.type === "quote"}
42
+ <blockquote style="margin: 1rem 0; font-style: italic;">
43
+ <p>{(block as QuoteBlock).text}</p>
44
+ {#if (block as QuoteBlock).author}
45
+ <footer>– {(block as QuoteBlock).author}</footer>
46
+ {/if}
47
+ </blockquote>
48
+
49
+ {:else if block.type === "divider"}
50
+ <hr style="margin: 2rem 0;" />
51
+
52
+ {:else if block.type === "faq"}
53
+ <div class="faq-block">
54
+ {#each (block as FaqBlock).items as item}
55
+ <details>
56
+ <summary>{item.question}</summary>
57
+ <div class="markdown">
58
+ {@html marked(item.answer)}
59
+ </div>
60
+ </details>
61
+ {/each}
62
+ </div>
63
+
64
+ {:else if block.type === "howto"}
65
+ <ol class="howto-block">
66
+ {#each (block as HowToBlock).steps as step}
67
+ <li>
68
+ <strong>{step.title}</strong>
69
+ <div class="markdown">
70
+ {@html marked(step.description)}
71
+ </div>
72
+ </li>
73
+ {/each}
74
+ </ol>
75
+
76
+ {/if}
12
77
  {/each}
78
+ </div>
@@ -1,4 +1,4 @@
1
- import type { Block } from '../types.ts';
1
+ import type { Block } from "../types.ts";
2
2
  type $$ComponentProps = {
3
3
  blocks: Block[];
4
4
  };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- export * from "./types";
2
- export * from "./resolve";
3
- export { default as BlockRenderer } from "./components/BlockRenderer.svelte";
1
+ export * from './types';
2
+ export { default as BlockRenderer } from './components/BlockRenderer.svelte';
package/dist/index.js CHANGED
@@ -1,4 +1,2 @@
1
- // Reexport your entry components here
2
- export * from "./types";
3
- export * from "./resolve";
4
- export { default as BlockRenderer } from "./components/BlockRenderer.svelte";
1
+ export * from './types';
2
+ export { default as BlockRenderer } from './components/BlockRenderer.svelte';
package/dist/types.d.ts CHANGED
@@ -12,4 +12,32 @@ export interface ImageBlock {
12
12
  src: string;
13
13
  alt?: string;
14
14
  }
15
- export type Block = TextBlock | HeadingBlock | ImageBlock;
15
+ export interface MarkdownBlock {
16
+ type: "markdown";
17
+ content: string;
18
+ }
19
+ export interface QuoteBlock {
20
+ type: "quote";
21
+ text: string;
22
+ author?: string;
23
+ }
24
+ export interface DividerBlock {
25
+ type: "divider";
26
+ }
27
+ export interface FaqEntry {
28
+ question: string;
29
+ answer: string;
30
+ }
31
+ export interface FaqBlock {
32
+ type: "faq";
33
+ items: FaqEntry[];
34
+ }
35
+ export interface HowToStep {
36
+ title: string;
37
+ description: string;
38
+ }
39
+ export interface HowToBlock {
40
+ type: "howto";
41
+ steps: HowToStep[];
42
+ }
43
+ export type Block = TextBlock | HeadingBlock | ImageBlock | MarkdownBlock | QuoteBlock | DividerBlock | FaqBlock | HowToBlock;
package/dist/types.js CHANGED
@@ -1,4 +1,4 @@
1
- //
2
- // Basic shared types for the runtime system
3
- //
1
+ // ---------------------------------------------
2
+ // ALTE BLOCKS
3
+ // ---------------------------------------------
4
4
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schneiderelli/cms-runtime",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",
@@ -69,5 +69,8 @@
69
69
  },
70
70
  "keywords": [
71
71
  "svelte"
72
- ]
72
+ ],
73
+ "dependencies": {
74
+ "marked": "^17.0.1"
75
+ }
73
76
  }