@digitalygo/create-diggocms-app 0.1.1 → 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.
- package/README.md +94 -23
- package/bin/cli.js +58 -94
- package/package.json +1 -1
- package/templates/full/README.md +58 -21
- package/templates/full/lib/diggo-config.ts +2 -0
- package/templates/full/package.json +3 -0
- package/templates/full/pages/[...slug].tsx +82 -0
- package/templates/full/pages/_app.tsx +11 -0
- package/templates/full/pages/index.tsx +14 -0
- package/templates/full/postcss.config.js +6 -0
- package/templates/full/styles/globals.css +81 -0
- package/templates/full/tailwind.config.ts +14 -0
- package/templates/full/tsconfig.json +2 -1
- package/templates/minimal/README.md +39 -9
- package/templates/minimal/lib/data-fetching.ts +0 -2
- package/templates/minimal/lib/diggo-config.ts +0 -3
- package/templates/minimal/package.json +3 -0
- package/templates/minimal/pages/[...slug].tsx +73 -0
- package/templates/minimal/pages/_app.tsx +11 -0
- package/templates/minimal/pages/index.tsx +14 -0
- package/templates/minimal/postcss.config.js +6 -0
- package/templates/minimal/{app → styles}/globals.css +4 -0
- package/templates/minimal/tailwind.config.ts +14 -0
- package/templates/minimal/tsconfig.json +2 -1
- package/templates/with-mock/README.md +58 -33
- package/templates/with-mock/lib/data-fetching.ts +1 -1
- package/templates/with-mock/lib/diggo-config.ts +2 -0
- package/templates/with-mock/package.json +7 -2
- package/templates/with-mock/pages/[...slug].tsx +103 -0
- package/templates/with-mock/pages/_app.tsx +11 -0
- package/templates/with-mock/pages/index.tsx +14 -0
- package/templates/with-mock/postcss.config.js +6 -0
- package/templates/with-mock/scripts/mock-server.ts +0 -6
- package/templates/with-mock/styles/globals.css +86 -0
- package/templates/with-mock/tailwind.config.ts +14 -0
- package/templates/with-mock/tsconfig.json +2 -1
- package/templates/full/app/[...slug]/page.tsx +0 -115
- package/templates/full/app/globals.css +0 -238
- package/templates/full/app/layout.tsx +0 -25
- package/templates/full/app/page.tsx +0 -6
- package/templates/full/tsconfig.tsbuildinfo +0 -1
- package/templates/minimal/app/[...slug]/page.tsx +0 -56
- package/templates/minimal/app/layout.tsx +0 -22
- package/templates/minimal/app/page.tsx +0 -6
- package/templates/with-mock/app/[...slug]/page.tsx +0 -115
- package/templates/with-mock/app/globals.css +0 -238
- package/templates/with-mock/app/layout.tsx +0 -25
- package/templates/with-mock/app/page.tsx +0 -6
- package/templates/with-mock/tsconfig.tsbuildinfo +0 -1
|
@@ -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
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
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,13 +33,15 @@ 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 with title, text, image, video, gallery, and card payloads
|
|
44
|
+
- `/` or `/home` - Home page with title, text, image, video, gallery, and card payloads
|
|
44
45
|
- `/chi-siamo` - About page with title, text, and image payloads
|
|
45
46
|
- `/contatti` - Contact page with title, text, and card payloads
|
|
46
47
|
|
|
@@ -48,11 +49,13 @@ The mock API includes these sample pages:
|
|
|
48
49
|
|
|
49
50
|
| Script | Description |
|
|
50
51
|
|--------|-------------|
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
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,13 +68,7 @@ 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
|
|
@@ -85,10 +82,15 @@ components/ # React components
|
|
|
85
82
|
└── ExtendedMenuContainer.tsx
|
|
86
83
|
|
|
87
84
|
lib/ # Utility functions
|
|
88
|
-
├── diggo-config.ts
|
|
89
|
-
└── data-fetching.ts
|
|
85
|
+
├── diggo-config.ts # SDK configuration
|
|
86
|
+
└── data-fetching.ts # Data fetching helpers
|
|
90
87
|
|
|
91
|
-
|
|
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
|
|
92
|
+
|
|
93
|
+
fixtures/ # Mock data (optional, CLI-configurable)
|
|
92
94
|
├── pages/
|
|
93
95
|
│ ├── index.json # Pages list
|
|
94
96
|
│ ├── home.json # Home page
|
|
@@ -99,6 +101,10 @@ fixtures/ # Mock data
|
|
|
99
101
|
|
|
100
102
|
scripts/
|
|
101
103
|
└── mock-server.ts # Mock API server
|
|
104
|
+
|
|
105
|
+
public/ # Static assets
|
|
106
|
+
styles/ # Global styles
|
|
107
|
+
└── globals.css # Tailwind + component styles
|
|
102
108
|
```
|
|
103
109
|
|
|
104
110
|
## Switching to Real API
|
|
@@ -106,26 +112,45 @@ scripts/
|
|
|
106
112
|
To use a real CMS API instead of mock data:
|
|
107
113
|
|
|
108
114
|
1. Update `.env.local`:
|
|
115
|
+
|
|
109
116
|
```env
|
|
110
117
|
BASE_URL=https://your-cms-api.com
|
|
111
118
|
MOCK=0
|
|
112
119
|
```
|
|
113
120
|
|
|
114
121
|
2. Restart the dev server:
|
|
122
|
+
|
|
115
123
|
```bash
|
|
116
124
|
bun run dev
|
|
117
125
|
```
|
|
118
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
|
+
|
|
119
141
|
## Customization
|
|
120
142
|
|
|
121
143
|
1. **Edit fixtures** - Modify files in `fixtures/` to change content
|
|
122
144
|
2. **Add components** - Create new components in `components/` and register in `lib/diggo-config.ts`
|
|
123
|
-
3. **Update styles** - Edit `
|
|
145
|
+
3. **Update styles** - Edit `styles/globals.css` or component styles
|
|
124
146
|
4. **Extend mock API** - Add new routes in `scripts/mock-server.ts`
|
|
125
147
|
|
|
126
|
-
|
|
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.
|
|
127
151
|
|
|
128
152
|
## Documentation
|
|
129
153
|
|
|
130
154
|
- [DiggoCMS SDK Documentation](https://github.com/digitalygo/diggocms-sdk)
|
|
131
|
-
- [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)
|
|
@@ -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
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ComponentRegistry, NavigationRegistry, DiggoConfig } from '@digitalygo/diggocms-sdk-core';
|
|
2
2
|
import {
|
|
3
|
+
ExtendedTitle,
|
|
3
4
|
ExtendedImage,
|
|
4
5
|
ExtendedText,
|
|
5
6
|
ExtendedVideo,
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
} from '@/components/server-components';
|
|
11
12
|
|
|
12
13
|
export const componentsRegistry = {
|
|
14
|
+
title: ExtendedTitle,
|
|
13
15
|
image: ExtendedImage,
|
|
14
16
|
text: ExtendedText,
|
|
15
17
|
video: ExtendedVideo,
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"start": "next start",
|
|
10
10
|
"lint": "next lint",
|
|
11
11
|
"typecheck": "tsc --noEmit",
|
|
12
|
-
"mock:api": "
|
|
13
|
-
"dev:mock": "
|
|
12
|
+
"mock:api": "tsx scripts/mock-server.ts",
|
|
13
|
+
"dev:mock": "concurrently \"pm run mock:api\" \"pm run dev\""
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@digitalygo/diggocms-sdk-core": "^0.1.0",
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
"@types/node": "^20.0.0",
|
|
23
23
|
"@types/react": "^18.3.0",
|
|
24
24
|
"@types/react-dom": "^18.3.0",
|
|
25
|
+
"autoprefixer": "^10.4.19",
|
|
26
|
+
"concurrently": "^9.0.0",
|
|
27
|
+
"postcss": "^8.4.38",
|
|
28
|
+
"tailwindcss": "^3.4.4",
|
|
29
|
+
"tsx": "^4.0.0",
|
|
25
30
|
"typescript": "^5.5.0"
|
|
26
31
|
}
|
|
27
32
|
}
|
|
@@ -0,0 +1,103 @@
|
|
|
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, isMockMode } from '@/lib/diggo-config';
|
|
7
|
+
import { fetchPageData, FetchPageResult, loadPagesIndex } from '@/lib/data-fetching';
|
|
8
|
+
|
|
9
|
+
interface CatchAllPageProps {
|
|
10
|
+
page: PagePayload | null;
|
|
11
|
+
error: string | null;
|
|
12
|
+
usingMock: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default function CatchAllPage({ page, error, usingMock }: CatchAllPageProps) {
|
|
16
|
+
const router = useRouter();
|
|
17
|
+
|
|
18
|
+
if (router.isFallback) {
|
|
19
|
+
return (
|
|
20
|
+
<div className="min-h-screen flex items-center justify-center">
|
|
21
|
+
<div className="text-lg text-gray-600">Loading...</div>
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!page) {
|
|
27
|
+
return (
|
|
28
|
+
<main className="max-w-5xl mx-auto p-8">
|
|
29
|
+
<h1 className="text-3xl font-bold text-gray-900 mb-4">Page Not Found</h1>
|
|
30
|
+
{error && (
|
|
31
|
+
<div className="bg-red-50 border border-red-200 text-red-800 p-4 rounded">
|
|
32
|
+
{error}
|
|
33
|
+
</div>
|
|
34
|
+
)}
|
|
35
|
+
</main>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<Head>
|
|
42
|
+
<title>{page.title || 'My DiggoCMS App'}</title>
|
|
43
|
+
<meta name="description" content={page.title || 'DiggoCMS powered page'} />
|
|
44
|
+
</Head>
|
|
45
|
+
{usingMock && (
|
|
46
|
+
<div className="mock-indicator">
|
|
47
|
+
Mock Mode
|
|
48
|
+
</div>
|
|
49
|
+
)}
|
|
50
|
+
<main className="max-w-5xl mx-auto p-8">
|
|
51
|
+
{error && (
|
|
52
|
+
<div className="bg-yellow-50 border border-yellow-200 text-yellow-800 p-4 mb-6 rounded">
|
|
53
|
+
<strong className="font-semibold">Warning:</strong> {error}
|
|
54
|
+
</div>
|
|
55
|
+
)}
|
|
56
|
+
{renderPage(page, componentsRegistry)}
|
|
57
|
+
</main>
|
|
58
|
+
</>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const getStaticPaths: GetStaticPaths = async () => {
|
|
63
|
+
if (isMockMode()) {
|
|
64
|
+
try {
|
|
65
|
+
const pages = await loadPagesIndex();
|
|
66
|
+
return {
|
|
67
|
+
paths: pages.map((page) => ({
|
|
68
|
+
params: {
|
|
69
|
+
slug: page.slug === '' ? ['home'] : page.slug.split('/')
|
|
70
|
+
},
|
|
71
|
+
})),
|
|
72
|
+
fallback: 'blocking',
|
|
73
|
+
};
|
|
74
|
+
} catch {}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
paths: [],
|
|
79
|
+
fallback: 'blocking',
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const getStaticProps: GetStaticProps<CatchAllPageProps> = async ({ params }) => {
|
|
84
|
+
const slugArray = params?.slug as string[] | undefined;
|
|
85
|
+
const slug = Array.isArray(slugArray) ? slugArray.join('/') : 'home';
|
|
86
|
+
|
|
87
|
+
const { page, error, usingMock }: FetchPageResult = await fetchPageData(slug);
|
|
88
|
+
|
|
89
|
+
if (!page) {
|
|
90
|
+
return {
|
|
91
|
+
notFound: true,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
props: {
|
|
97
|
+
page,
|
|
98
|
+
error,
|
|
99
|
+
usingMock,
|
|
100
|
+
},
|
|
101
|
+
revalidate: isMockMode() ? false : 60,
|
|
102
|
+
};
|
|
103
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
/**
|
|
3
|
-
* Standalone mock API server for DiggoCMS SDK.
|
|
4
|
-
* Serves fixtures as REST API endpoints for local development.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
1
|
import { createServer, type IncomingMessage, type ServerResponse } from 'http';
|
|
8
2
|
import { readFile } from 'fs/promises';
|
|
9
3
|
import { join } from 'path';
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
}
|
|
82
|
+
|
|
83
|
+
/* Mock Mode Indicator */
|
|
84
|
+
.mock-indicator {
|
|
85
|
+
@apply fixed bottom-4 right-4 bg-blue-600 text-white px-3 py-1 rounded text-sm font-medium shadow-lg z-50;
|
|
86
|
+
}
|
|
@@ -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"
|
|
22
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
|
22
23
|
"exclude": ["node_modules"]
|
|
23
24
|
}
|
|
@@ -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 © {new Date().getFullYear()}</p>
|
|
111
|
-
</div>
|
|
112
|
-
</footer>
|
|
113
|
-
</div>
|
|
114
|
-
);
|
|
115
|
-
}
|