@schneiderelli/cms-runtime 0.0.1 → 0.0.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.
@@ -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
@@ -1,15 +1,47 @@
1
- export interface TextBlock {
1
+ export interface BaseBlock {
2
+ id: string;
3
+ type: string;
4
+ }
5
+ export interface TextBlock extends BaseBlock {
2
6
  type: "text";
3
7
  content: string;
4
8
  }
5
- export interface HeadingBlock {
9
+ export interface HeadingBlock extends BaseBlock {
6
10
  type: "heading";
7
11
  level: number;
8
12
  text: string;
9
13
  }
10
- export interface ImageBlock {
14
+ export interface ImageBlock extends BaseBlock {
11
15
  type: "image";
12
16
  src: string;
13
17
  alt?: string;
14
18
  }
15
- export type Block = TextBlock | HeadingBlock | ImageBlock;
19
+ export interface MarkdownBlock extends BaseBlock {
20
+ type: "markdown";
21
+ content: string;
22
+ }
23
+ export interface QuoteBlock extends BaseBlock {
24
+ type: "quote";
25
+ text: string;
26
+ author?: string;
27
+ }
28
+ export interface DividerBlock extends BaseBlock {
29
+ type: "divider";
30
+ }
31
+ export interface FaqEntry extends BaseBlock {
32
+ question: string;
33
+ answer: string;
34
+ }
35
+ export interface FaqBlock extends BaseBlock {
36
+ type: "faq";
37
+ items: FaqEntry[];
38
+ }
39
+ export interface HowToStep extends BaseBlock {
40
+ title: string;
41
+ description: string;
42
+ }
43
+ export interface HowToBlock extends BaseBlock {
44
+ type: "howto";
45
+ steps: HowToStep[];
46
+ }
47
+ export type Block = TextBlock | HeadingBlock | ImageBlock | MarkdownBlock | QuoteBlock | DividerBlock | FaqBlock | HowToBlock;
package/dist/types.js CHANGED
@@ -1,4 +1 @@
1
- //
2
- // Basic shared types for the runtime system
3
- //
4
1
  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.3",
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
  }