@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,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,20 +1,23 @@
1
1
  import type { ComponentRegistry, NavigationRegistry, DiggoConfig } from '@digitalygo/diggocms-sdk-core';
2
2
  import {
3
3
  ExtendedTitle,
4
- ExtendedSubtitle,
5
4
  ExtendedImage,
6
- ExtendedRichtext,
5
+ ExtendedText,
6
+ ExtendedVideo,
7
+ ExtendedGallery,
7
8
  ExtendedCard,
8
9
  ExtendedMenuItem,
9
10
  ExtendedMenuContainer,
10
11
  } from '@/components/server-components';
11
12
 
12
- export const componentsRegistry: ComponentRegistry = {
13
- subtitle: ExtendedSubtitle,
13
+ export const componentsRegistry = {
14
+ title: ExtendedTitle,
14
15
  image: ExtendedImage,
15
- richtext: ExtendedRichtext,
16
+ text: ExtendedText,
17
+ video: ExtendedVideo,
18
+ gallery: ExtendedGallery,
16
19
  card: ExtendedCard,
17
- };
20
+ } as ComponentRegistry;
18
21
 
19
22
  export const navigationRegistry: NavigationRegistry = {
20
23
  MenuItem: ExtendedMenuItem,
@@ -20,6 +20,9 @@
20
20
  "@types/node": "^20.0.0",
21
21
  "@types/react": "^18.3.0",
22
22
  "@types/react-dom": "^18.3.0",
23
+ "autoprefixer": "^10.4.19",
24
+ "postcss": "^8.4.38",
25
+ "tailwindcss": "^3.4.4",
23
26
  "typescript": "^5.5.0"
24
27
  }
25
28
  }
@@ -0,0 +1,82 @@
1
+ import type { GetStaticPaths, GetStaticProps } from 'next';
2
+ import type { PagePayload } from '@digitalygo/diggocms-sdk-core';
3
+ import { useRouter } from 'next/router';
4
+ import Head from 'next/head';
5
+ import { renderPage } from '@digitalygo/diggocms-sdk-core/server';
6
+ import { componentsRegistry } from '@/lib/diggo-config';
7
+ import { fetchPageData, FetchPageResult } from '@/lib/data-fetching';
8
+
9
+ interface CatchAllPageProps {
10
+ page: PagePayload | null;
11
+ error: string | null;
12
+ }
13
+
14
+ export default function CatchAllPage({ page, error }: CatchAllPageProps) {
15
+ const router = useRouter();
16
+
17
+ if (router.isFallback) {
18
+ return (
19
+ <div className="min-h-screen flex items-center justify-center">
20
+ <div className="text-lg text-gray-600">Loading...</div>
21
+ </div>
22
+ );
23
+ }
24
+
25
+ if (!page) {
26
+ return (
27
+ <main className="max-w-5xl mx-auto p-8">
28
+ <h1 className="text-3xl font-bold text-gray-900 mb-4">Page Not Found</h1>
29
+ {error && (
30
+ <div className="bg-red-50 border border-red-200 text-red-800 p-4 rounded">
31
+ {error}
32
+ </div>
33
+ )}
34
+ </main>
35
+ );
36
+ }
37
+
38
+ return (
39
+ <>
40
+ <Head>
41
+ <title>{page.title || 'My DiggoCMS App'}</title>
42
+ <meta name="description" content={page.title || 'DiggoCMS powered page'} />
43
+ </Head>
44
+ <main className="max-w-5xl mx-auto p-8">
45
+ {error && (
46
+ <div className="bg-yellow-50 border border-yellow-200 text-yellow-800 p-4 mb-6 rounded">
47
+ <strong className="font-semibold">Warning:</strong> {error}
48
+ </div>
49
+ )}
50
+ {renderPage(page, componentsRegistry)}
51
+ </main>
52
+ </>
53
+ );
54
+ }
55
+
56
+ export const getStaticPaths: GetStaticPaths = async () => {
57
+ return {
58
+ paths: [],
59
+ fallback: 'blocking',
60
+ };
61
+ };
62
+
63
+ export const getStaticProps: GetStaticProps<CatchAllPageProps> = async ({ params }) => {
64
+ const slugArray = params?.slug as string[] | undefined;
65
+ const slug = Array.isArray(slugArray) ? slugArray.join('/') : 'home';
66
+
67
+ const { page, error }: FetchPageResult = await fetchPageData(slug);
68
+
69
+ if (!page) {
70
+ return {
71
+ notFound: true,
72
+ };
73
+ }
74
+
75
+ return {
76
+ props: {
77
+ page,
78
+ error,
79
+ },
80
+ revalidate: 60,
81
+ };
82
+ };
@@ -0,0 +1,11 @@
1
+ import type { AppProps } from 'next/app';
2
+ import { DiggoProvider } from '@/components/DiggoProvider';
3
+ import '@/styles/globals.css';
4
+
5
+ export default function App({ Component, pageProps }: AppProps) {
6
+ return (
7
+ <DiggoProvider>
8
+ <Component {...pageProps} />
9
+ </DiggoProvider>
10
+ );
11
+ }
@@ -0,0 +1,14 @@
1
+ import type { GetStaticProps } from 'next';
2
+
3
+ export default function HomePage() {
4
+ return null;
5
+ }
6
+
7
+ export const getStaticProps: GetStaticProps = async () => {
8
+ return {
9
+ redirect: {
10
+ destination: '/home',
11
+ permanent: false,
12
+ },
13
+ };
14
+ };
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ };
@@ -0,0 +1,81 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ * {
6
+ margin: 0;
7
+ padding: 0;
8
+ box-sizing: border-box;
9
+ }
10
+
11
+ body {
12
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
13
+ line-height: 1.6;
14
+ color: #333;
15
+ }
16
+
17
+ /* DiggoCMS Component Styles */
18
+ .diggo-title {
19
+ @apply text-3xl font-bold mb-4 text-gray-900;
20
+ }
21
+
22
+ .diggo-text {
23
+ @apply mb-4 text-gray-700 leading-relaxed;
24
+ }
25
+
26
+ .diggo-image {
27
+ @apply max-w-full h-auto rounded-lg shadow-md mb-6;
28
+ }
29
+
30
+ .diggo-video-block {
31
+ @apply mb-6;
32
+ }
33
+
34
+ .diggo-video {
35
+ @apply w-full rounded-lg shadow-md;
36
+ }
37
+
38
+ .diggo-media-caption {
39
+ @apply text-sm text-gray-600 mt-2 text-center;
40
+ }
41
+
42
+ .diggo-gallery {
43
+ @apply grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mb-6;
44
+ }
45
+
46
+ .diggo-gallery-image {
47
+ @apply w-full h-48 object-cover rounded-lg shadow-md;
48
+ }
49
+
50
+ .diggo-gallery-video {
51
+ @apply w-full h-48 rounded-lg shadow-md;
52
+ }
53
+
54
+ .diggo-card {
55
+ @apply border border-gray-200 rounded-lg p-6 shadow-sm mb-6 bg-white;
56
+ }
57
+
58
+ .diggo-card-link {
59
+ @apply inline-block mt-4 px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors;
60
+ }
61
+
62
+ /* Navigation Styles */
63
+ .menu {
64
+ @apply bg-gray-100 py-4 mb-8;
65
+ }
66
+
67
+ .menu-list {
68
+ @apply flex flex-wrap gap-6 max-w-5xl mx-auto px-8 list-none;
69
+ }
70
+
71
+ .menu-item {
72
+ @apply relative;
73
+ }
74
+
75
+ .menu-link {
76
+ @apply text-gray-700 hover:text-blue-600 font-medium transition-colors;
77
+ }
78
+
79
+ .menu-link[aria-current="page"] {
80
+ @apply text-blue-600 font-semibold;
81
+ }
@@ -0,0 +1,14 @@
1
+ import type { Config } from 'tailwindcss';
2
+
3
+ const config: Config = {
4
+ content: [
5
+ './pages/**/*.{js,ts,jsx,tsx,mdx}',
6
+ './components/**/*.{js,ts,jsx,tsx,mdx}',
7
+ ],
8
+ theme: {
9
+ extend: {},
10
+ },
11
+ plugins: [],
12
+ };
13
+
14
+ export default config;
@@ -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,26 +1,37 @@
1
1
  # My DiggoCMS App
2
2
 
3
- A minimal DiggoCMS application built with Next.js and the DiggoCMS SDK.
3
+ A minimal DiggoCMS application built with Next.js Pages Router and the DiggoCMS SDK.
4
+
5
+ ## Features
6
+
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
+ - DiggoCMS SDK integration
4
12
 
5
13
  ## Getting Started
6
14
 
7
15
  1. Copy `.env.local.example` to `.env.local` and configure your environment:
16
+
8
17
  ```bash
9
18
  cp .env.local.example .env.local
10
19
  ```
11
20
 
12
21
  2. Install dependencies:
22
+
13
23
  ```bash
14
- npm install
15
- # or
16
24
  bun install
25
+ # or
26
+ npm install
17
27
  ```
18
28
 
19
29
  3. Run the development server:
30
+
20
31
  ```bash
21
- npm run dev
22
- # or
23
32
  bun run dev
33
+ # or
34
+ npm run dev
24
35
  ```
25
36
 
26
37
  4. Open [http://localhost:3000](http://localhost:3000) in your browser.
@@ -30,6 +41,7 @@ A minimal DiggoCMS application built with Next.js and the DiggoCMS SDK.
30
41
  ### Using a Real CMS API
31
42
 
32
43
  Set your CMS API base URL:
44
+
33
45
  ```env
34
46
  BASE_URL=https://your-cms-api.com
35
47
  MOCK=0
@@ -37,7 +49,8 @@ MOCK=0
37
49
 
38
50
  ### Using Mock Mode
39
51
 
40
- Enable mock mode to use local fixtures:
52
+ Enable mock mode to use a local mock API:
53
+
41
54
  ```env
42
55
  MOCK=1
43
56
  MOCK_API_URL=http://localhost:3001
@@ -45,13 +58,28 @@ MOCK_API_URL=http://localhost:3001
45
58
 
46
59
  ## Project Structure
47
60
 
48
- ```
49
- app/ # Next.js app router
61
+ ```text
50
62
  components/ # React components (add your extended components here)
51
63
  lib/ # Utility functions and SDK configuration
64
+ pages/ # Next.js pages (Pages Router)
65
+ ├── _app.tsx # App wrapper with DiggoProvider
66
+ ├── index.tsx # Home redirect
67
+ └── [...slug].tsx # Dynamic catch-all route
52
68
  public/ # Static assets
69
+ styles/ # Global styles
70
+ ├── globals.css # Tailwind imports + global styles
53
71
  ```
54
72
 
73
+ ## Scripts
74
+
75
+ | Script | Description |
76
+ |--------|-------------|
77
+ | `bun run dev` | Start development server with hot reload |
78
+ | `bun run build` | Build for static export |
79
+ | `bun run start` | Start production server |
80
+ | `bun run lint` | Run ESLint |
81
+ | `bun run typecheck` | Run TypeScript check |
82
+
55
83
  ## Next Steps
56
84
 
57
85
  This is a minimal template. To extend it:
@@ -60,8 +88,10 @@ This is a minimal template. To extend it:
60
88
  2. Register them in `lib/diggo-config.ts`
61
89
  3. Add navigation components if needed
62
90
  4. Set up your CMS API or mock server
91
+ 5. Configure `getStaticPaths` in `[...slug].tsx` to pre-generate pages at build time
63
92
 
64
93
  ## Documentation
65
94
 
66
95
  - [DiggoCMS SDK Documentation](https://github.com/digitalygo/diggocms-sdk)
67
- - [Next.js Documentation](https://nextjs.org/docs)
96
+ - [Next.js Pages Router Documentation](https://nextjs.org/docs/pages)
97
+ - [Tailwind CSS Documentation](https://tailwindcss.com/docs)
@@ -8,7 +8,6 @@ export interface FetchPageResult {
8
8
 
9
9
  export async function fetchPageData(slug: string): Promise<FetchPageResult> {
10
10
  if (isMockMode()) {
11
- // Mock mode: fetch from local mock API
12
11
  try {
13
12
  const mockApiUrl = process.env.MOCK_API_URL ?? 'http://localhost:3001';
14
13
  const response = await fetch(`${mockApiUrl}/pages/${slug}`);
@@ -37,7 +36,6 @@ export async function fetchPageData(slug: string): Promise<FetchPageResult> {
37
36
  };
38
37
  }
39
38
 
40
- // Real API mode: fetch from CMS
41
39
  try {
42
40
  const response = await fetch(`${sdkConfig.baseUrl}/pages/${slug}`);
43
41
 
@@ -1,12 +1,9 @@
1
1
  import type { ComponentRegistry, NavigationRegistry, DiggoConfig } from '@digitalygo/diggocms-sdk-core';
2
2
 
3
- // Add your custom components here
4
3
  export const componentsRegistry: ComponentRegistry = {
5
- // Example: title: ExtendedTitle,
6
4
  };
7
5
 
8
6
  export const navigationRegistry: NavigationRegistry = {
9
- // Example: MenuItem: ExtendedMenuItem,
10
7
  };
11
8
 
12
9
  const isMock = process.env.MOCK === '1';
@@ -20,6 +20,9 @@
20
20
  "@types/node": "^20.0.0",
21
21
  "@types/react": "^18.3.0",
22
22
  "@types/react-dom": "^18.3.0",
23
+ "autoprefixer": "^10.4.19",
24
+ "postcss": "^8.4.38",
25
+ "tailwindcss": "^3.4.4",
23
26
  "typescript": "^5.5.0"
24
27
  }
25
28
  }
@@ -0,0 +1,73 @@
1
+ import type { GetStaticPaths, GetStaticProps } from 'next';
2
+ import type { PagePayload } from '@digitalygo/diggocms-sdk-core';
3
+ import { useRouter } from 'next/router';
4
+ import Head from 'next/head';
5
+ import { renderPage } from '@digitalygo/diggocms-sdk-core/server';
6
+ import { componentsRegistry } from '@/lib/diggo-config';
7
+ import { fetchPageData, FetchPageResult } from '@/lib/data-fetching';
8
+
9
+ interface CatchAllPageProps {
10
+ page: PagePayload | null;
11
+ error: string | null;
12
+ }
13
+
14
+ export default function CatchAllPage({ page, error }: CatchAllPageProps) {
15
+ const router = useRouter();
16
+
17
+ if (router.isFallback) {
18
+ return <div className="p-8 text-center">Loading...</div>;
19
+ }
20
+
21
+ if (!page) {
22
+ return (
23
+ <main className="max-w-5xl mx-auto p-8">
24
+ <h1 className="text-2xl font-bold mb-4">Page Not Found</h1>
25
+ {error && <p className="text-red-600">{error}</p>}
26
+ </main>
27
+ );
28
+ }
29
+
30
+ return (
31
+ <>
32
+ <Head>
33
+ <title>{page.title || 'My DiggoCMS App'}</title>
34
+ </Head>
35
+ <main className="max-w-5xl mx-auto p-8">
36
+ {error && (
37
+ <div className="bg-yellow-50 border border-yellow-200 text-yellow-800 p-4 mb-6 rounded">
38
+ <strong>Warning:</strong> {error}
39
+ </div>
40
+ )}
41
+ {renderPage(page, componentsRegistry)}
42
+ </main>
43
+ </>
44
+ );
45
+ }
46
+
47
+ export const getStaticPaths: GetStaticPaths = async () => {
48
+ return {
49
+ paths: [],
50
+ fallback: 'blocking',
51
+ };
52
+ };
53
+
54
+ export const getStaticProps: GetStaticProps<CatchAllPageProps> = async ({ params }) => {
55
+ const slugArray = params?.slug as string[] | undefined;
56
+ const slug = Array.isArray(slugArray) ? slugArray.join('/') : 'home';
57
+
58
+ const { page, error }: FetchPageResult = await fetchPageData(slug);
59
+
60
+ if (!page) {
61
+ return {
62
+ notFound: true,
63
+ };
64
+ }
65
+
66
+ return {
67
+ props: {
68
+ page,
69
+ error,
70
+ },
71
+ revalidate: 60,
72
+ };
73
+ };
@@ -0,0 +1,11 @@
1
+ import type { AppProps } from 'next/app';
2
+ import { DiggoProvider } from '@/components/DiggoProvider';
3
+ import '@/styles/globals.css';
4
+
5
+ export default function App({ Component, pageProps }: AppProps) {
6
+ return (
7
+ <DiggoProvider>
8
+ <Component {...pageProps} />
9
+ </DiggoProvider>
10
+ );
11
+ }
@@ -0,0 +1,14 @@
1
+ import type { GetStaticProps } from 'next';
2
+
3
+ export default function HomePage() {
4
+ return null;
5
+ }
6
+
7
+ export const getStaticProps: GetStaticProps = async () => {
8
+ return {
9
+ redirect: {
10
+ destination: '/home',
11
+ permanent: false,
12
+ },
13
+ };
14
+ };
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ };
@@ -1,3 +1,7 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
1
5
  * {
2
6
  margin: 0;
3
7
  padding: 0;
@@ -0,0 +1,14 @@
1
+ import type { Config } from 'tailwindcss';
2
+
3
+ const config: Config = {
4
+ content: [
5
+ './pages/**/*.{js,ts,jsx,tsx,mdx}',
6
+ './components/**/*.{js,ts,jsx,tsx,mdx}',
7
+ ],
8
+ theme: {
9
+ extend: {},
10
+ },
11
+ plugins: [],
12
+ };
13
+
14
+ export default config;