@digitalygo/create-diggocms-app 0.1.0 → 0.1.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.
Files changed (65) hide show
  1. package/README.md +94 -23
  2. package/bin/cli.js +58 -94
  3. package/package.json +5 -2
  4. package/templates/full/README.md +66 -25
  5. package/templates/full/components/ExtendedCard.tsx +17 -5
  6. package/templates/full/components/ExtendedGallery.tsx +43 -0
  7. package/templates/full/components/ExtendedText.tsx +16 -0
  8. package/templates/full/components/ExtendedVideo.tsx +27 -0
  9. package/templates/full/components/server-components.ts +3 -3
  10. package/templates/full/lib/diggo-config.ts +9 -6
  11. package/templates/full/package.json +3 -0
  12. package/templates/full/pages/[...slug].tsx +82 -0
  13. package/templates/full/pages/_app.tsx +11 -0
  14. package/templates/full/pages/index.tsx +14 -0
  15. package/templates/full/postcss.config.js +6 -0
  16. package/templates/full/styles/globals.css +81 -0
  17. package/templates/full/tailwind.config.ts +14 -0
  18. package/templates/full/tsconfig.json +2 -1
  19. package/templates/minimal/README.md +39 -9
  20. package/templates/minimal/lib/data-fetching.ts +0 -2
  21. package/templates/minimal/lib/diggo-config.ts +0 -3
  22. package/templates/minimal/package.json +3 -0
  23. package/templates/minimal/pages/[...slug].tsx +73 -0
  24. package/templates/minimal/pages/_app.tsx +11 -0
  25. package/templates/minimal/pages/index.tsx +14 -0
  26. package/templates/minimal/postcss.config.js +6 -0
  27. package/templates/minimal/{app → styles}/globals.css +4 -0
  28. package/templates/minimal/tailwind.config.ts +14 -0
  29. package/templates/minimal/tsconfig.json +2 -1
  30. package/templates/with-mock/README.md +64 -36
  31. package/templates/with-mock/components/ExtendedCard.tsx +17 -5
  32. package/templates/with-mock/components/ExtendedGallery.tsx +43 -0
  33. package/templates/with-mock/components/ExtendedText.tsx +16 -0
  34. package/templates/with-mock/components/ExtendedVideo.tsx +27 -0
  35. package/templates/with-mock/components/server-components.ts +3 -3
  36. package/templates/with-mock/fixtures/collection.json +59 -18
  37. package/templates/with-mock/fixtures/pages/chi-siamo.json +9 -8
  38. package/templates/with-mock/fixtures/pages/contatti.json +10 -7
  39. package/templates/with-mock/fixtures/pages/home.json +71 -22
  40. package/templates/with-mock/lib/data-fetching.ts +1 -1
  41. package/templates/with-mock/lib/diggo-config.ts +9 -6
  42. package/templates/with-mock/package.json +7 -2
  43. package/templates/with-mock/pages/[...slug].tsx +103 -0
  44. package/templates/with-mock/pages/_app.tsx +11 -0
  45. package/templates/with-mock/pages/index.tsx +14 -0
  46. package/templates/with-mock/postcss.config.js +6 -0
  47. package/templates/with-mock/scripts/mock-server.ts +0 -6
  48. package/templates/with-mock/styles/globals.css +86 -0
  49. package/templates/with-mock/tailwind.config.ts +14 -0
  50. package/templates/with-mock/tsconfig.json +2 -1
  51. package/templates/full/app/[...slug]/page.tsx +0 -115
  52. package/templates/full/app/globals.css +0 -187
  53. package/templates/full/app/layout.tsx +0 -25
  54. package/templates/full/app/page.tsx +0 -6
  55. package/templates/full/components/ExtendedRichtext.tsx +0 -15
  56. package/templates/full/components/ExtendedSubtitle.tsx +0 -10
  57. package/templates/minimal/app/[...slug]/page.tsx +0 -56
  58. package/templates/minimal/app/layout.tsx +0 -22
  59. package/templates/minimal/app/page.tsx +0 -6
  60. package/templates/with-mock/app/[...slug]/page.tsx +0 -115
  61. package/templates/with-mock/app/globals.css +0 -187
  62. package/templates/with-mock/app/layout.tsx +0 -25
  63. package/templates/with-mock/app/page.tsx +0 -6
  64. package/templates/with-mock/components/ExtendedRichtext.tsx +0 -15
  65. package/templates/with-mock/components/ExtendedSubtitle.tsx +0 -10
@@ -14,10 +14,11 @@
14
14
  "jsx": "preserve",
15
15
  "incremental": true,
16
16
  "plugins": [{ "name": "next" }],
17
+ "baseUrl": ".",
17
18
  "paths": {
18
19
  "@/*": ["./*"]
19
20
  }
20
21
  },
21
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
22
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
22
23
  "exclude": ["node_modules"]
23
24
  }
@@ -1,32 +1,31 @@
1
1
  # My DiggoCMS App
2
2
 
3
- A complete DiggoCMS application with mock API server for development.
3
+ A complete DiggoCMS application with mock API server for development, built with Next.js Pages Router.
4
4
 
5
5
  ## Features
6
6
 
7
- - Dynamic routing with `[...slug]` pattern
8
- - Extended components (Title, Subtitle, Image, Richtext, Card)
9
- - Navigation with dropdown support
10
- - Built-in mock API server
11
- - Sample fixtures included
12
- - Mock mode for development
13
- - Error handling and loading states
7
+ - Next.js 16 with Pages Router
8
+ - Static Site Generation (SSG) with `getStaticProps`/`getStaticPaths`
9
+ - Tailwind CSS for styling
10
+ - Hot reload via `next dev`
11
+ - Extended components for all supported types: title, image, text, video, gallery, and card
12
+ - Navigation components with dropdown support
13
+ - Built-in mock API server (runs with tsx, works with any package manager)
14
+ - Sample fixtures aligned with SDK payload model
15
+ - Mock mode indicator during development
14
16
 
15
17
  ## Quick Start
16
18
 
17
19
  1. Copy `.env.local.example` to `.env.local`:
20
+
18
21
  ```bash
19
22
  cp .env.local.example .env.local
20
23
  ```
21
24
 
22
- 2. Install dependencies:
23
- ```bash
24
- bun install
25
- # or
26
- npm install
27
- ```
25
+ 2. Install dependencies using your chosen package manager.
28
26
 
29
27
  3. Start the mock API and dev server:
28
+
30
29
  ```bash
31
30
  bun run dev:mock
32
31
  # or run separately:
@@ -34,25 +33,29 @@ A complete DiggoCMS application with mock API server for development.
34
33
  bun run dev # Terminal 2
35
34
  ```
36
35
 
36
+ With npm, yarn, or pnpm, use: `npm run dev:mock`, `yarn dev:mock`, or `pnpm run dev:mock`.
37
+
37
38
  4. Open [http://localhost:3000](http://localhost:3000) in your browser.
38
39
 
39
40
  ## Available Pages
40
41
 
41
42
  The mock API includes these sample pages:
42
43
 
43
- - `/` - Home page
44
- - `/chi-siamo` - About page
45
- - `/contatti` - Contact page
44
+ - `/` or `/home` - Home page with title, text, image, video, gallery, and card payloads
45
+ - `/chi-siamo` - About page with title, text, and image payloads
46
+ - `/contatti` - Contact page with title, text, and card payloads
46
47
 
47
48
  ## Scripts
48
49
 
49
50
  | Script | Description |
50
51
  |--------|-------------|
51
- | `bun run dev` | Start Next.js dev server only |
52
- | `bun run build` | Build for production |
53
- | `bun run start` | Start production server |
54
- | `bun run mock:api` | Start mock API server only |
55
- | `bun run dev:mock` | Start mock API and dev server together |
52
+ | `dev` | Start Next.js dev server only |
53
+ | `build` | Build for production |
54
+ | `start` | Start production server |
55
+ | `lint` | Run ESLint |
56
+ | `typecheck` | Run TypeScript check |
57
+ | `mock:api` | Start mock API server only |
58
+ | `dev:mock` | Start mock API and dev server together |
56
59
 
57
60
  ## Mock API Endpoints
58
61
 
@@ -65,29 +68,29 @@ The mock server provides these endpoints:
65
68
 
66
69
  ## Project Structure
67
70
 
68
- ```
69
- app/ # Next.js app router
70
- ├── [...slug]/ # Dynamic catch-all route
71
- ├── layout.tsx # Root layout with DiggoProvider
72
- ├── page.tsx # Home redirect
73
- └── globals.css # Global styles
74
-
71
+ ```text
75
72
  components/ # React components
76
73
  ├── DiggoProvider.tsx
77
74
  ├── server-components.ts
78
75
  ├── ExtendedTitle.tsx
79
- ├── ExtendedSubtitle.tsx
80
76
  ├── ExtendedImage.tsx
81
- ├── ExtendedRichtext.tsx
77
+ ├── ExtendedText.tsx
78
+ ├── ExtendedVideo.tsx
79
+ ├── ExtendedGallery.tsx
82
80
  ├── ExtendedCard.tsx
83
81
  ├── ExtendedMenuItem.tsx
84
82
  └── ExtendedMenuContainer.tsx
85
83
 
86
84
  lib/ # Utility functions
87
- ├── diggo-config.ts
88
- └── data-fetching.ts
85
+ ├── diggo-config.ts # SDK configuration
86
+ └── data-fetching.ts # Data fetching helpers
87
+
88
+ pages/ # Next.js pages (Pages Router)
89
+ ├── _app.tsx # App wrapper with DiggoProvider
90
+ ├── index.tsx # Home redirect
91
+ └── [...slug].tsx # Dynamic catch-all route
89
92
 
90
- fixtures/ # Mock data
93
+ fixtures/ # Mock data (optional, CLI-configurable)
91
94
  ├── pages/
92
95
  │ ├── index.json # Pages list
93
96
  │ ├── home.json # Home page
@@ -98,6 +101,10 @@ fixtures/ # Mock data
98
101
 
99
102
  scripts/
100
103
  └── mock-server.ts # Mock API server
104
+
105
+ public/ # Static assets
106
+ styles/ # Global styles
107
+ └── globals.css # Tailwind + component styles
101
108
  ```
102
109
 
103
110
  ## Switching to Real API
@@ -105,24 +112,45 @@ scripts/
105
112
  To use a real CMS API instead of mock data:
106
113
 
107
114
  1. Update `.env.local`:
115
+
108
116
  ```env
109
117
  BASE_URL=https://your-cms-api.com
110
118
  MOCK=0
111
119
  ```
112
120
 
113
121
  2. Restart the dev server:
122
+
114
123
  ```bash
115
124
  bun run dev
116
125
  ```
117
126
 
127
+ Or use npm, yarn, or pnpm: `npm run dev`, `yarn dev`, `pnpm run dev`.
128
+
129
+ ## CLI Options
130
+
131
+ When creating a project with `create-diggocms-app`, you can choose:
132
+
133
+ - **Template**: `minimal`, `full`, or `with-mock`
134
+ - **Package manager**: `bun` (default), `npm`, `yarn`, or `pnpm`
135
+ - **Fixtures** (with-mock only): Include or exclude sample fixtures
136
+
137
+ ## SSG Configuration
138
+
139
+ Pages are automatically pre-generated at build time from the fixtures when using mock mode. For production with a real API, update `getStaticPaths` in `pages/[...slug].tsx` to fetch from your CMS.
140
+
118
141
  ## Customization
119
142
 
120
143
  1. **Edit fixtures** - Modify files in `fixtures/` to change content
121
144
  2. **Add components** - Create new components in `components/` and register in `lib/diggo-config.ts`
122
- 3. **Update styles** - Edit `app/globals.css` or component styles
145
+ 3. **Update styles** - Edit `styles/globals.css` or component styles
123
146
  4. **Extend mock API** - Add new routes in `scripts/mock-server.ts`
124
147
 
148
+ ## Fixture Notes
149
+
150
+ Page fixtures intentionally use only the current supported component types: `title`, `text`, `image`, `video`, `gallery`, and `card`. Deprecated types like `subtitle` and `richtext` (as standalone components) are excluded from page fixtures. Card components may still use card-specific fields like `richtext` as part of the card data structure.
151
+
125
152
  ## Documentation
126
153
 
127
154
  - [DiggoCMS SDK Documentation](https://github.com/digitalygo/diggocms-sdk)
128
- - [Next.js Documentation](https://nextjs.org/docs)
155
+ - [Next.js Pages Router Documentation](https://nextjs.org/docs/pages)
156
+ - [Tailwind CSS Documentation](https://tailwindcss.com/docs)
@@ -1,15 +1,27 @@
1
1
  import type { CardProps } from '@digitalygo/diggocms-sdk-core';
2
2
  import type { ReactElement } from 'react';
3
3
  import { ExtendedTitle } from './ExtendedTitle';
4
- import { ExtendedSubtitle } from './ExtendedSubtitle';
5
- import { ExtendedRichtext } from './ExtendedRichtext';
4
+ import { ExtendedImage } from './ExtendedImage';
5
+ import { ExtendedText } from './ExtendedText';
6
+
7
+ export function ExtendedCard({ title, image, content, richtext, callToAction }: CardProps): ReactElement | null {
8
+ const body = richtext ?? content;
9
+ const hasCallToAction = Boolean(callToAction?.text && callToAction?.url);
10
+
11
+ if (!title && !image?.src && !body && !hasCallToAction) {
12
+ return null;
13
+ }
6
14
 
7
- export function ExtendedCard({ title, subtitle, content }: CardProps): ReactElement | null {
8
15
  return (
9
16
  <div className="diggo-card">
17
+ {image?.src && <ExtendedImage {...image} />}
10
18
  {title && <ExtendedTitle content={title} />}
11
- {subtitle && <ExtendedSubtitle content={subtitle} />}
12
- {content && <ExtendedRichtext content={content} />}
19
+ {body && <ExtendedText content={body} />}
20
+ {hasCallToAction ? (
21
+ <a href={callToAction?.url ?? '#'} className="diggo-card-link">
22
+ {callToAction?.text}
23
+ </a>
24
+ ) : null}
13
25
  </div>
14
26
  );
15
27
  }
@@ -0,0 +1,43 @@
1
+ import type { GalleryProps, ImageProps, VideoProps } from '@digitalygo/diggocms-sdk-core';
2
+ import type { ReactElement } from 'react';
3
+
4
+ type LegacyGalleryProps = {
5
+ images?: ImageProps[] | null;
6
+ };
7
+
8
+ type ExtendedGalleryProps = GalleryProps & LegacyGalleryProps;
9
+
10
+ export function ExtendedGallery({ items, images }: ExtendedGalleryProps): ReactElement | null {
11
+ const normalizedItems = items ?? images?.map((image, index) => ({ type: 'image' as const, order: index, data: image })) ?? null;
12
+
13
+ if (!normalizedItems || normalizedItems.length === 0) {
14
+ return null;
15
+ }
16
+
17
+ const sortedItems = [...normalizedItems].sort((left, right) => left.order - right.order);
18
+
19
+ return (
20
+ <div className="diggo-gallery">
21
+ {sortedItems.map((item, index) => (
22
+ item.type === 'video' ? (
23
+ <video
24
+ key={`${item.type}-${index}-${(item.data as VideoProps).src ?? 'video'}`}
25
+ className="diggo-gallery-video"
26
+ controls
27
+ poster={(item.data as VideoProps).poster ?? undefined}
28
+ >
29
+ <source src={(item.data as VideoProps).src ?? ''} />
30
+ {(item.data as VideoProps).alt ?? ''}
31
+ </video>
32
+ ) : (
33
+ <img
34
+ key={`${item.type}-${index}-${(item.data as ImageProps).src ?? 'image'}`}
35
+ src={(item.data as ImageProps).src ?? ''}
36
+ alt={(item.data as ImageProps).alt ?? ''}
37
+ className="diggo-gallery-image"
38
+ />
39
+ )
40
+ ))}
41
+ </div>
42
+ );
43
+ }
@@ -0,0 +1,16 @@
1
+ import type { ReactElement } from 'react';
2
+
3
+ type TextProps = {
4
+ content?: string | null;
5
+ text?: string | null;
6
+ };
7
+
8
+ export function ExtendedText({ content, text }: TextProps): ReactElement | null {
9
+ const value = content ?? text;
10
+
11
+ if (!value) {
12
+ return null;
13
+ }
14
+
15
+ return <p className="diggo-text">{value}</p>;
16
+ }
@@ -0,0 +1,27 @@
1
+ import type { VideoProps } from '@digitalygo/diggocms-sdk-core';
2
+ import type { ReactElement } from 'react';
3
+
4
+ type LegacyVideoProps = VideoProps & {
5
+ title?: string | null;
6
+ };
7
+
8
+ export function ExtendedVideo({
9
+ src,
10
+ poster,
11
+ alt,
12
+ title,
13
+ }: LegacyVideoProps): ReactElement | null {
14
+ if (!src) {
15
+ return null;
16
+ }
17
+
18
+ return (
19
+ <figure className="diggo-video-block">
20
+ <video className="diggo-video" controls poster={poster ?? undefined}>
21
+ <source src={src} />
22
+ {alt ?? title ?? ''}
23
+ </video>
24
+ {alt || title ? <figcaption className="diggo-media-caption">{alt ?? title}</figcaption> : null}
25
+ </figure>
26
+ );
27
+ }
@@ -1,8 +1,8 @@
1
- // Re-export components for server-side usage (they're server-safe pure components)
2
1
  export { ExtendedTitle } from './ExtendedTitle';
3
- export { ExtendedSubtitle } from './ExtendedSubtitle';
4
2
  export { ExtendedImage } from './ExtendedImage';
5
- export { ExtendedRichtext } from './ExtendedRichtext';
3
+ export { ExtendedText } from './ExtendedText';
4
+ export { ExtendedVideo } from './ExtendedVideo';
5
+ export { ExtendedGallery } from './ExtendedGallery';
6
6
  export { ExtendedCard } from './ExtendedCard';
7
7
  export { ExtendedMenuItem } from './ExtendedMenuItem';
8
8
  export { ExtendedMenuContainer } from './ExtendedMenuContainer';
@@ -1,28 +1,69 @@
1
1
  {
2
- "type": "posts",
3
2
  "items": [
4
3
  {
5
- "id": "1",
6
- "title": "Getting Started with DiggoCMS",
7
- "excerpt": "Learn how to set up your first DiggoCMS project",
8
- "image": "https://via.placeholder.com/400x200/3b82f6/ffffff?text=Getting+Started"
4
+ "id": "item-1",
5
+ "title": "First Article",
6
+ "slug": "first-article",
7
+ "excerpt": "This is the first article in the collection demonstration.",
8
+ "image": {
9
+ "src": "https://images.unsplash.com/photo-1499750310107-5fef28a66643?w=400&h=200&fit=crop",
10
+ "alt": "Article 1 image"
11
+ },
12
+ "components": [
13
+ {
14
+ "type": "title",
15
+ "data": {
16
+ "content": "Nested Title in Article 1"
17
+ }
18
+ }
19
+ ]
9
20
  },
10
21
  {
11
- "id": "2",
12
- "title": "Building Custom Components",
13
- "excerpt": "Create your own components for the SDK",
14
- "image": "https://via.placeholder.com/400x200/10b981/ffffff?text=Custom+Components"
22
+ "id": "item-2",
23
+ "title": "Second Article",
24
+ "slug": "second-article",
25
+ "excerpt": "This is the second article with null image field.",
26
+ "image": null,
27
+ "components": [
28
+ {
29
+ "type": "text",
30
+ "data": {
31
+ "content": "Component with null image"
32
+ }
33
+ }
34
+ ]
15
35
  },
16
36
  {
17
- "id": "3",
18
- "title": "Working with Mock Data",
19
- "excerpt": "Develop without a backend using our mock API",
20
- "image": "https://via.placeholder.com/400x200/f59e0b/ffffff?text=Mock+Data"
37
+ "id": "item-3",
38
+ "title": null,
39
+ "slug": "third-article",
40
+ "excerpt": "This item has null title but still renders.",
41
+ "image": {
42
+ "src": "https://images.unsplash.com/photo-1519389950473-47ba0277781c?w=400&h=200&fit=crop",
43
+ "alt": "Article 3 image"
44
+ },
45
+ "components": []
46
+ },
47
+ {
48
+ "id": "item-4",
49
+ "title": "Fourth Article",
50
+ "slug": "fourth-article",
51
+ "excerpt": "Full content with all fields present.",
52
+ "image": {
53
+ "src": "https://images.unsplash.com/photo-1558655146-9f40138edfeb?w=400&h=200&fit=crop",
54
+ "alt": "Article 4 image"
55
+ },
56
+ "components": [
57
+ {
58
+ "type": "text",
59
+ "data": {
60
+ "content": "Additional content inside the collection item."
61
+ }
62
+ }
63
+ ]
21
64
  }
22
65
  ],
23
- "pagination": {
24
- "page": 1,
25
- "totalPages": 1,
26
- "totalItems": 3
27
- }
66
+ "total": 4,
67
+ "page": 1,
68
+ "perPage": 10
28
69
  }
@@ -10,27 +10,28 @@
10
10
  }
11
11
  },
12
12
  {
13
- "type": "subtitle",
13
+ "type": "text",
14
14
  "data": {
15
- "content": "About Our Company"
15
+ "content": "Who we are — scopri la nostra storia, i nostri valori e il modo in cui lavoriamo insieme ai clienti."
16
16
  }
17
17
  },
18
18
  {
19
- "type": "richtext",
19
+ "type": "text",
20
20
  "data": {
21
- "content": "<p>We are a team of passionate developers building the next generation of headless CMS tools. DiggoCMS provides a flexible, developer-friendly platform for content management.</p>"
21
+ "content": "Siamo un'azienda italiana con una passione per l'innovazione e la qualità. Dal 2010 realizziamo soluzioni digitali che aiutano le aziende a crescere nel panorama digitale moderno."
22
22
  }
23
23
  },
24
24
  {
25
- "type": "subtitle",
25
+ "type": "text",
26
26
  "data": {
27
- "content": "Our Mission"
27
+ "content": "Il nostro team unisce collaborazione, creatività ed eccellenza. Se stai visualizzando questa pagina, significa che la navigazione verso Chi Siamo funziona correttamente."
28
28
  }
29
29
  },
30
30
  {
31
- "type": "richtext",
31
+ "type": "image",
32
32
  "data": {
33
- "content": "<p>To simplify content management for developers while providing powerful features for content editors.</p>"
33
+ "src": "https://images.unsplash.com/photo-1522071820081-009f0129c71c?w=800&h=400&fit=crop",
34
+ "alt": "Il nostro team"
34
35
  }
35
36
  }
36
37
  ]
@@ -10,23 +10,26 @@
10
10
  }
11
11
  },
12
12
  {
13
- "type": "subtitle",
13
+ "type": "text",
14
14
  "data": {
15
- "content": "Get in Touch"
15
+ "content": "Contacts siamo qui per aiutarti con domande, collaborazioni e richieste di supporto."
16
16
  }
17
17
  },
18
18
  {
19
- "type": "richtext",
19
+ "type": "text",
20
20
  "data": {
21
- "content": "<p>Have questions? We'd love to hear from you.</p><p><strong>Email:</strong> hello@example.com<br><strong>Phone:</strong> +1 234 567 890</p>"
21
+ "content": "Questa sezione raccoglie i recapiti principali per scriverci, chiamarci o venire a trovarci in sede. Se stai visualizzando questa pagina, la navigazione verso Contatti funziona correttamente."
22
22
  }
23
23
  },
24
24
  {
25
25
  "type": "card",
26
26
  "data": {
27
- "title": "Office Location",
28
- "subtitle": "Headquarters",
29
- "content": "<p>123 Developer Street<br>Tech City, TC 12345<br>United States</p>"
27
+ "title": "Informazioni di Contatto",
28
+ "richtext": "Indirizzo: Via Roma 123, 00100 Roma, Italia. Email: info@example.com. Telefono: +39 06 12345678. Orari: lun-ven 9:00-18:00.",
29
+ "callToAction": {
30
+ "text": "Scrivici",
31
+ "url": "mailto:info@example.com"
32
+ }
30
33
  }
31
34
  }
32
35
  ]
@@ -1,61 +1,110 @@
1
1
  {
2
- "id": "home",
2
+ "id": "page-1",
3
3
  "slug": "home",
4
- "title": "Welcome to DiggoCMS",
4
+ "title": "Welcome to DiggoCMS Demo",
5
5
  "components": [
6
6
  {
7
7
  "type": "title",
8
8
  "data": {
9
- "content": "Welcome to DiggoCMS"
9
+ "content": "Benvenuto su DiggoCMS Demo"
10
10
  }
11
11
  },
12
12
  {
13
- "type": "subtitle",
13
+ "type": "text",
14
14
  "data": {
15
- "content": "Your headless CMS powered by React & Next.js"
15
+ "content": "A demonstration of the SDK rendering capabilities built around the current component model."
16
16
  }
17
17
  },
18
18
  {
19
- "type": "richtext",
19
+ "type": "text",
20
20
  "data": {
21
- "content": "<p>This is a sample page rendered from a <strong>mock API</strong>. All content comes from JSON fixtures in the <code>fixtures/</code> directory.</p><p>The DiggoCMS SDK automatically renders components based on the page payload.</p>"
21
+ "content": "This page showcases the DiggoCMS SDK with extended components. All content is rendered from a JSON payload matching the CMS API format."
22
22
  }
23
23
  },
24
24
  {
25
25
  "type": "image",
26
26
  "data": {
27
- "src": "https://via.placeholder.com/800x400/3b82f6/ffffff?text=DiggoCMS+Mock",
28
- "alt": "DiggoCMS Mock Placeholder"
27
+ "src": "https://images.unsplash.com/photo-1460925895917-afdab827c52f?w=800&h=400&fit=crop",
28
+ "alt": "DiggoCMS Demo Placeholder"
29
29
  }
30
30
  },
31
31
  {
32
- "type": "subtitle",
32
+ "type": "text",
33
33
  "data": {
34
- "content": "Features"
34
+ "content": "The SDK now renders plain text, videos, galleries, and richer CMS cards with minimal custom components."
35
35
  }
36
36
  },
37
37
  {
38
- "type": "card",
38
+ "type": "video",
39
39
  "data": {
40
- "title": "Dynamic Routing",
41
- "subtitle": "Built on Next.js App Router",
42
- "content": "<p>Pages are rendered dynamically using the [...slug] catch-all route pattern. Each page is fetched from the CMS API.</p>"
40
+ "src": "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4",
41
+ "poster": "https://images.unsplash.com/photo-1492691527719-9d1e07e534b4?w=800&h=450&fit=crop",
42
+ "alt": "Short sample video"
43
43
  }
44
44
  },
45
45
  {
46
- "type": "card",
46
+ "type": "gallery",
47
47
  "data": {
48
- "title": "Component System",
49
- "subtitle": "Extensible & Type-Safe",
50
- "content": "<p>Components are registered in a type-safe registry. Extend base components or create your own custom ones.</p>"
48
+ "items": [
49
+ {
50
+ "type": "image",
51
+ "order": 2,
52
+ "data": {
53
+ "src": "https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=600&h=400&fit=crop",
54
+ "alt": "Gallery item one"
55
+ }
56
+ },
57
+ {
58
+ "type": "video",
59
+ "order": 1,
60
+ "data": {
61
+ "src": "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4",
62
+ "poster": "https://images.unsplash.com/photo-1518837695005-2083093ee35b?w=600&h=400&fit=crop",
63
+ "alt": "Gallery video item"
64
+ }
65
+ },
66
+ {
67
+ "type": "image",
68
+ "order": 0,
69
+ "data": {
70
+ "src": "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=600&h=400&fit=crop",
71
+ "alt": "Gallery item three"
72
+ }
73
+ }
74
+ ]
51
75
  }
52
76
  },
53
77
  {
54
78
  "type": "card",
55
79
  "data": {
56
- "title": "Mock API",
57
- "subtitle": "Develop Without a Backend",
58
- "content": "<p>The included mock server lets you develop your frontend without needing a real CMS API running.</p>"
80
+ "image": {
81
+ "src": "https://images.unsplash.com/photo-1551434678-e076c223a692?w=640&h=360&fit=crop",
82
+ "alt": "CMS card preview"
83
+ },
84
+ "title": "Feature Card",
85
+ "richtext": "This card demonstrates the updated CMS card shape with an image, body copy, and a call to action.",
86
+ "callToAction": {
87
+ "text": "Explore collection",
88
+ "url": "/collection"
89
+ }
90
+ }
91
+ },
92
+ {
93
+ "type": "text",
94
+ "data": {
95
+ "content": "Null value handling"
96
+ }
97
+ },
98
+ {
99
+ "type": "title",
100
+ "data": {
101
+ "content": null
102
+ }
103
+ },
104
+ {
105
+ "type": "text",
106
+ "data": {
107
+ "content": "The null title above should not render, demonstrating graceful null handling."
59
108
  }
60
109
  }
61
110
  ]
@@ -32,7 +32,7 @@ async function fetchFromMockApi<T>(endpoint: string): Promise<T | null> {
32
32
  }
33
33
  }
34
34
 
35
- async function loadPagesIndex(): Promise<PageIndexItem[]> {
35
+ export async function loadPagesIndex(): Promise<PageIndexItem[]> {
36
36
  const index = await fetchFromMockApi<PageIndexItem[]>('/pages');
37
37
  return index ?? [];
38
38
  }