@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
@@ -1,56 +0,0 @@
1
- import type { ReactElement } from 'react';
2
- import type { Metadata } from 'next';
3
- import { notFound } from 'next/navigation';
4
- import { fetchPageData } from '@/lib/data-fetching';
5
- import { renderPage } from '@digitalygo/diggocms-sdk-core/server';
6
- import { componentsRegistry } from '@/lib/diggo-config';
7
-
8
- export const dynamic = 'force-dynamic';
9
-
10
- interface CatchAllPageProps {
11
- params: Promise<{ slug: string[] }>;
12
- }
13
-
14
- export async function generateMetadata({
15
- params,
16
- }: CatchAllPageProps): Promise<Metadata> {
17
- const { slug: slugParam } = await params;
18
- const slug = (Array.isArray(slugParam) ? slugParam : []).join('/') || 'home';
19
- const { page } = await fetchPageData(slug);
20
-
21
- return {
22
- title: page?.title,
23
- };
24
- }
25
-
26
- export default async function CatchAllPage({
27
- params,
28
- }: CatchAllPageProps): Promise<ReactElement> {
29
- const { slug: slugParam } = await params;
30
- const slug = (Array.isArray(slugParam) ? slugParam : []).join('/') || 'home';
31
-
32
- const { page, error } = await fetchPageData(slug);
33
-
34
- if (!page) {
35
- notFound();
36
- }
37
-
38
- return (
39
- <main style={{ maxWidth: '1200px', margin: '0 auto', padding: '2rem' }}>
40
- {error && (
41
- <div
42
- style={{
43
- background: '#fef3c7',
44
- border: '1px solid #fbbf24',
45
- padding: '1rem',
46
- marginBottom: '1.5rem',
47
- borderRadius: '0.375rem',
48
- }}
49
- >
50
- <strong>Warning:</strong> {error}
51
- </div>
52
- )}
53
- {renderPage(page, componentsRegistry)}
54
- </main>
55
- );
56
- }
@@ -1,22 +0,0 @@
1
- import type { ReactElement } from 'react';
2
- import { DiggoProvider } from '@/components/DiggoProvider';
3
- import './globals.css';
4
-
5
- export const metadata = {
6
- title: 'My DiggoCMS App',
7
- description: 'Built with DiggoCMS SDK',
8
- };
9
-
10
- export default function RootLayout({
11
- children,
12
- }: {
13
- children: React.ReactNode;
14
- }): ReactElement {
15
- return (
16
- <html lang="en">
17
- <body>
18
- <DiggoProvider>{children}</DiggoProvider>
19
- </body>
20
- </html>
21
- );
22
- }
@@ -1,6 +0,0 @@
1
- import type { ReactElement } from 'react';
2
- import { redirect } from 'next/navigation';
3
-
4
- export default function HomePage(): ReactElement {
5
- redirect('/home');
6
- }
@@ -1,115 +0,0 @@
1
- import type { ReactElement } from 'react';
2
- import type { Metadata } from 'next';
3
- import Link from 'next/link';
4
- import { notFound } from 'next/navigation';
5
- import { fetchPageData, fetchMenuData } from '@/lib/data-fetching';
6
- import {
7
- componentsRegistry,
8
- navigationRegistry,
9
- isMockMode,
10
- hasBaseUrl,
11
- } from '@/lib/diggo-config';
12
- import { renderPage, renderMenu } from '@digitalygo/diggocms-sdk-core/server';
13
-
14
- export const dynamic = 'force-dynamic';
15
-
16
- interface CatchAllPageProps {
17
- params: Promise<{ slug: string[] }>;
18
- }
19
-
20
- export async function generateMetadata({
21
- params,
22
- }: CatchAllPageProps): Promise<Metadata> {
23
- const { slug: slugParam } = await params;
24
- const slug = (Array.isArray(slugParam) ? slugParam : []).join('/') || 'home';
25
- const { page } = await fetchPageData(slug);
26
-
27
- return {
28
- title: page?.title,
29
- };
30
- }
31
-
32
- export default async function CatchAllPage({
33
- params,
34
- }: CatchAllPageProps): Promise<ReactElement> {
35
- const { slug: slugParam } = await params;
36
- const slug = (Array.isArray(slugParam) ? slugParam : []).join('/') || 'home';
37
-
38
- const [{ page, error, usingMock }, { menu }] = await Promise.all([
39
- fetchPageData(slug),
40
- fetchMenuData('main'),
41
- ]);
42
-
43
- const showMockIndicator = usingMock || isMockMode();
44
- const showError = error && !page;
45
-
46
- if (!page) {
47
- if (!hasBaseUrl() && !isMockMode()) {
48
- return (
49
- <div className="container">
50
- <header className="header">
51
- <div className="header-content container">
52
- <div className="logo">My DiggoCMS App</div>
53
- </div>
54
- </header>
55
- <main className="main container">
56
- <div className="error-banner">
57
- <strong>Error:</strong> BASE_URL is not configured and MOCK mode
58
- is disabled.
59
- </div>
60
- <p>
61
- Please configure your environment variables. Copy{' '}
62
- <code>.env.local.example</code> to <code>.env.local</code> and set
63
- either:
64
- </p>
65
- <ul style={{ marginLeft: '1.5rem', marginTop: '0.5rem' }}>
66
- <li>
67
- <code>MOCK=1</code> to use local fixtures
68
- </li>
69
- <li>
70
- <code>BASE_URL</code> to your CMS API endpoint
71
- </li>
72
- </ul>
73
- </main>
74
- </div>
75
- );
76
- }
77
-
78
- notFound();
79
- }
80
-
81
- return (
82
- <div>
83
- <header className="header">
84
- <div className="header-content container">
85
- <Link href="/" className="logo">
86
- My DiggoCMS App
87
- </Link>
88
- {menu && renderMenu(menu, navigationRegistry)}
89
- </div>
90
- </header>
91
-
92
- <main className="main container">
93
- {showError && !showMockIndicator && (
94
- <div className="error-banner">
95
- <strong>Warning:</strong> {error}
96
- </div>
97
- )}
98
-
99
- {showMockIndicator && (
100
- <div className="mock-badge">
101
- Mock Mode
102
- </div>
103
- )}
104
-
105
- {renderPage(page, componentsRegistry)}
106
- </main>
107
-
108
- <footer className="footer">
109
- <div className="container">
110
- <p>My DiggoCMS App &copy; {new Date().getFullYear()}</p>
111
- </div>
112
- </footer>
113
- </div>
114
- );
115
- }
@@ -1,187 +0,0 @@
1
- * {
2
- margin: 0;
3
- padding: 0;
4
- box-sizing: border-box;
5
- }
6
-
7
- body {
8
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
9
- line-height: 1.6;
10
- color: #333;
11
- }
12
-
13
- .container {
14
- max-width: 1200px;
15
- margin: 0 auto;
16
- padding: 0 1rem;
17
- }
18
-
19
- /* Header Styles */
20
- .header {
21
- background: #fff;
22
- border-bottom: 1px solid #e5e7eb;
23
- padding: 1rem 0;
24
- margin-bottom: 2rem;
25
- }
26
-
27
- .header-content {
28
- display: flex;
29
- justify-content: space-between;
30
- align-items: center;
31
- flex-wrap: wrap;
32
- gap: 1rem;
33
- }
34
-
35
- .logo {
36
- font-size: 1.5rem;
37
- font-weight: 700;
38
- color: #3b82f6;
39
- text-decoration: none;
40
- }
41
-
42
- /* Main Content */
43
- .main {
44
- min-height: calc(100vh - 200px);
45
- padding-bottom: 3rem;
46
- }
47
-
48
- /* Footer Styles */
49
- .footer {
50
- background: #f9fafb;
51
- border-top: 1px solid #e5e7eb;
52
- padding: 2rem 0;
53
- text-align: center;
54
- color: #6b7280;
55
- }
56
-
57
- /* Error Banner */
58
- .error-banner {
59
- background: #fef3c7;
60
- border: 1px solid #fbbf24;
61
- border-radius: 0.375rem;
62
- padding: 1rem;
63
- margin-bottom: 1.5rem;
64
- color: #92400e;
65
- }
66
-
67
- /* Mock Badge */
68
- .mock-badge {
69
- display: inline-block;
70
- background: #dbeafe;
71
- color: #1e40af;
72
- padding: 0.25rem 0.75rem;
73
- border-radius: 9999px;
74
- font-size: 0.75rem;
75
- font-weight: 500;
76
- margin-bottom: 1rem;
77
- }
78
-
79
- /* Component Styles */
80
- .diggo-title {
81
- font-size: 2.5rem;
82
- font-weight: 700;
83
- color: #111827;
84
- margin-bottom: 1rem;
85
- line-height: 1.2;
86
- }
87
-
88
- .diggo-subtitle {
89
- font-size: 1.5rem;
90
- font-weight: 600;
91
- color: #374151;
92
- margin-bottom: 1rem;
93
- margin-top: 2rem;
94
- line-height: 1.3;
95
- }
96
-
97
- .diggo-image {
98
- max-width: 100%;
99
- height: auto;
100
- border-radius: 0.5rem;
101
- margin: 1rem 0;
102
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
103
- }
104
-
105
- .diggo-richtext {
106
- margin: 1rem 0;
107
- }
108
-
109
- .diggo-richtext p {
110
- margin-bottom: 1rem;
111
- }
112
-
113
- .diggo-card {
114
- background: #fff;
115
- border: 1px solid #e5e7eb;
116
- border-radius: 0.5rem;
117
- padding: 1.5rem;
118
- margin: 1.5rem 0;
119
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
120
- }
121
-
122
- .diggo-card .diggo-title {
123
- font-size: 1.25rem;
124
- margin-bottom: 0.5rem;
125
- }
126
-
127
- .diggo-card .diggo-subtitle {
128
- font-size: 1rem;
129
- color: #6b7280;
130
- margin-top: 0;
131
- margin-bottom: 1rem;
132
- }
133
-
134
- /* Navigation Styles */
135
- .menu {
136
- display: flex;
137
- }
138
-
139
- .menu-list {
140
- display: flex;
141
- list-style: none;
142
- gap: 1.5rem;
143
- flex-wrap: wrap;
144
- }
145
-
146
- .menu-item {
147
- position: relative;
148
- }
149
-
150
- .menu-link {
151
- color: #374151;
152
- text-decoration: none;
153
- font-weight: 500;
154
- padding: 0.5rem 0;
155
- transition: color 0.2s;
156
- }
157
-
158
- .menu-link:hover {
159
- color: #3b82f6;
160
- }
161
-
162
- .menu-link[aria-current='page'] {
163
- color: #3b82f6;
164
- border-bottom: 2px solid #3b82f6;
165
- }
166
-
167
- .menu-item ul {
168
- display: none;
169
- position: absolute;
170
- top: 100%;
171
- left: 0;
172
- background: #fff;
173
- border: 1px solid #e5e7eb;
174
- border-radius: 0.375rem;
175
- padding: 0.5rem 0;
176
- min-width: 150px;
177
- list-style: none;
178
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
179
- }
180
-
181
- .menu-item:hover > ul {
182
- display: block;
183
- }
184
-
185
- .menu-item ul li {
186
- padding: 0.25rem 1rem;
187
- }
@@ -1,25 +0,0 @@
1
- import type { ReactElement } from 'react';
2
- import { DiggoProvider } from '@/components/DiggoProvider';
3
- import './globals.css';
4
-
5
- export const metadata = {
6
- title: {
7
- template: '%s | My DiggoCMS App',
8
- default: 'My DiggoCMS App',
9
- },
10
- description: 'Built with DiggoCMS SDK',
11
- };
12
-
13
- export default function RootLayout({
14
- children,
15
- }: {
16
- children: React.ReactNode;
17
- }): ReactElement {
18
- return (
19
- <html lang="en">
20
- <body>
21
- <DiggoProvider>{children}</DiggoProvider>
22
- </body>
23
- </html>
24
- );
25
- }
@@ -1,6 +0,0 @@
1
- import type { ReactElement } from 'react';
2
- import { redirect } from 'next/navigation';
3
-
4
- export default function HomePage(): ReactElement {
5
- redirect('/home');
6
- }
@@ -1,15 +0,0 @@
1
- import type { RichtextProps } from '@digitalygo/diggocms-sdk-core';
2
- import type { ReactElement } from 'react';
3
-
4
- export function ExtendedRichtext({ content }: RichtextProps): ReactElement | null {
5
- if (!content) {
6
- return null;
7
- }
8
-
9
- return (
10
- <div
11
- className="diggo-richtext"
12
- dangerouslySetInnerHTML={{ __html: content }}
13
- />
14
- );
15
- }
@@ -1,10 +0,0 @@
1
- import type { SubtitleProps } from '@digitalygo/diggocms-sdk-core';
2
- import type { ReactElement } from 'react';
3
-
4
- export function ExtendedSubtitle({ content }: SubtitleProps): ReactElement | null {
5
- if (!content) {
6
- return null;
7
- }
8
-
9
- return <h2 className="diggo-subtitle">{content}</h2>;
10
- }