@digitalygo/create-diggocms-app 0.1.1 → 0.1.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.
Files changed (55) hide show
  1. package/README.md +96 -23
  2. package/bin/cli.js +52 -94
  3. package/package.json +1 -1
  4. package/templates/full/.env.local.example +3 -2
  5. package/templates/full/README.md +64 -22
  6. package/templates/full/components/PageLayout.tsx +40 -0
  7. package/templates/full/lib/data-fetching.ts +55 -10
  8. package/templates/full/lib/diggo-config.ts +4 -2
  9. package/templates/full/package.json +3 -1
  10. package/templates/full/pages/[...slug].tsx +93 -0
  11. package/templates/full/pages/_app.tsx +11 -0
  12. package/templates/full/pages/index.tsx +14 -0
  13. package/templates/full/postcss.config.js +6 -0
  14. package/templates/full/styles/globals.css +113 -0
  15. package/templates/full/tailwind.config.ts +14 -0
  16. package/templates/full/tsconfig.json +2 -1
  17. package/templates/minimal/.env.local.example +3 -2
  18. package/templates/minimal/README.md +44 -10
  19. package/templates/minimal/lib/data-fetching.ts +46 -12
  20. package/templates/minimal/lib/diggo-config.ts +2 -5
  21. package/templates/minimal/package.json +3 -1
  22. package/templates/minimal/pages/[...slug].tsx +73 -0
  23. package/templates/minimal/pages/_app.tsx +11 -0
  24. package/templates/minimal/pages/index.tsx +14 -0
  25. package/templates/minimal/postcss.config.js +6 -0
  26. package/templates/minimal/{app → styles}/globals.css +4 -0
  27. package/templates/minimal/tailwind.config.ts +14 -0
  28. package/templates/minimal/tsconfig.json +2 -1
  29. package/templates/with-mock/.env.local.example +3 -2
  30. package/templates/with-mock/README.md +61 -33
  31. package/templates/with-mock/components/PageLayout.tsx +40 -0
  32. package/templates/with-mock/lib/data-fetching.ts +56 -11
  33. package/templates/with-mock/lib/diggo-config.ts +4 -2
  34. package/templates/with-mock/package.json +7 -3
  35. package/templates/with-mock/pages/[...slug].tsx +117 -0
  36. package/templates/with-mock/pages/_app.tsx +11 -0
  37. package/templates/with-mock/pages/index.tsx +14 -0
  38. package/templates/with-mock/postcss.config.js +6 -0
  39. package/templates/with-mock/scripts/mock-server.ts +0 -6
  40. package/templates/with-mock/styles/globals.css +118 -0
  41. package/templates/with-mock/tailwind.config.ts +14 -0
  42. package/templates/with-mock/tsconfig.json +2 -1
  43. package/templates/full/app/[...slug]/page.tsx +0 -115
  44. package/templates/full/app/globals.css +0 -238
  45. package/templates/full/app/layout.tsx +0 -25
  46. package/templates/full/app/page.tsx +0 -6
  47. package/templates/full/tsconfig.tsbuildinfo +0 -1
  48. package/templates/minimal/app/[...slug]/page.tsx +0 -56
  49. package/templates/minimal/app/layout.tsx +0 -22
  50. package/templates/minimal/app/page.tsx +0 -6
  51. package/templates/with-mock/app/[...slug]/page.tsx +0 -115
  52. package/templates/with-mock/app/globals.css +0 -238
  53. package/templates/with-mock/app/layout.tsx +0 -25
  54. package/templates/with-mock/app/page.tsx +0 -6
  55. package/templates/with-mock/tsconfig.tsbuildinfo +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Create DiggoCMS App
2
2
 
3
- A CLI tool to scaffold new DiggoCMS projects with Next.js and the DiggoCMS SDK.
3
+ A CLI tool to scaffold new DiggoCMS projects with Next.js Pages Router and the DiggoCMS SDK.
4
4
 
5
5
  ## Usage
6
6
 
@@ -10,7 +10,7 @@ A CLI tool to scaffold new DiggoCMS projects with Next.js and the DiggoCMS SDK.
10
10
  npx create-diggocms-app@latest
11
11
  ```
12
12
 
13
- ### With bun
13
+ ### With bun (recommended)
14
14
 
15
15
  ```bash
16
16
  bun x create-diggocms-app
@@ -29,41 +29,53 @@ The CLI will guide you through the setup process:
29
29
 
30
30
  1. **Project name** - Name of your new project directory
31
31
  2. **Template** - Choose from:
32
- - `full` - Complete setup with the current supported component templates (recommended)
33
- - `with-mock` - Full setup + mock API server + sample fixtures aligned with the SDK/demo payload model
32
+ - `full` - Complete setup with all components, SSG-ready with Pages Router (recommended)
33
+ - `with-mock` - Full setup + mock API server + optional fixtures
34
34
  - `minimal` - Basic setup, add components yourself
35
- 3. **Package manager** - Choose your preferred package manager (bun, npm, yarn, pnpm)
35
+ 3. **Fixtures** (with-mock only) - Include sample fixtures for development
36
+ 4. **Package manager** - Choose your preferred package manager (bun, npm, yarn, pnpm)
36
37
 
37
38
  ## Templates
38
39
 
39
40
  ### Minimal
40
41
 
41
42
  A bare-bones setup with just the SDK installed. You'll need to:
43
+
42
44
  - Create your own extended components
43
45
  - Configure the SDK manually
44
46
  - Set up data fetching
45
47
 
48
+ **Features:**
49
+
50
+ - Next.js 16 with Pages Router
51
+ - Tailwind CSS configured
52
+ - SSG structure with `getStaticProps`/`getStaticPaths`
53
+ - Hot reload via `next dev`
54
+
46
55
  Best for: Experienced developers who want full control.
47
56
 
48
57
  ### Full
49
58
 
50
59
  Complete setup including:
51
- - Extended templates for the current supported component set (title, image, text, video, gallery, card)
60
+
61
+ - Extended templates for all supported component types (title, image, text, video, gallery, card)
52
62
  - Navigation components with dropdown support
53
- - Dynamic routing with `[...slug]`
54
- - Data fetching helpers
63
+ - Dynamic routing with `[...slug]` using Pages Router
64
+ - Data fetching helpers with SSG
55
65
  - Error handling and mock indicators
56
- - Ready-to-use styles
66
+ - Tailwind CSS with component styles
57
67
 
58
68
  Best for: Most users starting a new project.
59
69
 
60
70
  ### With Mock
61
71
 
62
72
  Everything from the full template, plus:
63
- - Standalone mock API server (`scripts/mock-server.ts`)
64
- - Sample fixtures (pages, menu, collection) aligned with the current JSON/content standards used by the SDK/demo
65
- - Scripts: `mock:api` and `dev:mock`
73
+
74
+ - Standalone mock API server (`scripts/mock-server.ts`) using tsx (works with any package manager)
75
+ - Optional sample fixtures (pages, menu, collection) aligned with SDK payload model
76
+ - Scripts: `mock:api` and `dev:mock` (uses `concurrently` for cross-platform parallel execution)
66
77
  - Pre-configured `.env.local` for mock mode
78
+ - Mock mode indicator in UI
67
79
 
68
80
  Best for: Developing without a real CMS API, testing, or learning.
69
81
 
@@ -71,13 +83,12 @@ Best for: Developing without a real CMS API, testing, or learning.
71
83
 
72
84
  After scaffolding, your project will have this structure:
73
85
 
74
- ```
86
+ ```text
75
87
  my-app/
76
- ├── app/ # Next.js app router
77
- │ ├── [...slug]/ # Dynamic routes
78
- │ ├── layout.tsx
79
- │ ├── page.tsx
80
- │ └── globals.css
88
+ ├── pages/ # Next.js pages (Pages Router)
89
+ │ ├── [...slug].tsx # Dynamic routes
90
+ │ ├── _app.tsx # App wrapper
91
+ │ ├── index.tsx # Home redirect
81
92
  ├── components/ # React components
82
93
  │ ├── DiggoProvider.tsx
83
94
  │ ├── server-components.ts
@@ -85,10 +96,14 @@ my-app/
85
96
  ├── lib/ # Utilities
86
97
  │ ├── diggo-config.ts
87
98
  │ └── data-fetching.ts
88
- ├── fixtures/ # Mock data (with-mock only)
99
+ ├── fixtures/ # Mock data (with-mock only, optional)
89
100
  ├── scripts/ # Mock server (with-mock only)
101
+ ├── styles/ # Global styles
102
+ │ └── globals.css # Tailwind + custom styles
90
103
  ├── .env.local.example
91
104
  ├── next.config.ts
105
+ ├── tailwind.config.ts # Tailwind configuration
106
+ ├── postcss.config.js # PostCSS configuration
92
107
  ├── package.json
93
108
  ├── tsconfig.json
94
109
  └── README.md
@@ -108,6 +123,19 @@ MOCK=1
108
123
  MOCK_API_URL=http://localhost:3001
109
124
  ```
110
125
 
126
+ Note: `BASE_URL` must be set to a valid URL when not using mock mode. Requests will timeout after 5 seconds if the server is unreachable.
127
+
128
+ ## Package Manager Support
129
+
130
+ The CLI supports multiple package managers:
131
+
132
+ - **bun** (default if available) - Fast, all-in-one JavaScript runtime
133
+ - **npm** - Node.js default package manager
134
+ - **yarn** - Fast, reliable, and secure dependency management
135
+ - **pnpm** - Fast, disk space efficient package manager
136
+
137
+ Scripts in `package.json` are automatically adjusted for your chosen package manager.
138
+
111
139
  ## Requirements
112
140
 
113
141
  - Node.js >= 18.0.0 or Bun >= 1.1.0
@@ -115,22 +143,63 @@ MOCK_API_URL=http://localhost:3001
115
143
 
116
144
  ## Options
117
145
 
118
- You can also pass the project name as an argument:
146
+ ### Default path
147
+
148
+ You can pass the project name as an argument to skip the prompt:
119
149
 
120
150
  ```bash
121
151
  npx create-diggocms-app@latest my-project
122
152
  ```
123
153
 
124
- This skips the project name prompt and uses `my-project` directly.
154
+ ### With fixtures toggle (with-mock template)
155
+
156
+ When selecting the `with-mock` template, you'll be prompted to include fixtures:
157
+
158
+ - **Yes** (default) - Includes sample pages, menu, and collection fixtures
159
+ - **No** - Sets up the mock server infrastructure without sample data
160
+
161
+ ## SSG (Static Site Generation)
162
+
163
+ All templates use Next.js Pages Router with SSG-first approach:
164
+
165
+ - `getStaticProps` - Fetches page data at build time
166
+ - `getStaticPaths` - Pre-generates pages (configure for your CMS)
167
+ - ISR (Incremental Static Regeneration) - Enabled with 60s revalidation by default
168
+
169
+ To pre-generate specific pages at build time, update `getStaticPaths` in `pages/[...slug].tsx`.
170
+
171
+ ## Commands Reference
172
+
173
+ Commands work with any package manager (bun, npm, yarn, pnpm). Examples use `bun`:
174
+
175
+ ### All Templates
176
+
177
+ ```bash
178
+ bun run dev # Start development server with hot reload
179
+ bun run build # Build for production
180
+ bun run start # Start production server
181
+ bun run lint # Run ESLint
182
+ bun run typecheck # Run TypeScript check
183
+ ```
184
+
185
+ ### With-Mock Template Only
186
+
187
+ ```bash
188
+ bun run mock:api # Start the mock API server
189
+ bun run dev:mock # Start mock API and dev server together
190
+ ```
191
+
192
+ With yarn, omit `run` (for example: `yarn dev`, `yarn mock:api`).
125
193
 
126
194
  ## Troubleshooting
127
195
 
128
196
  ### Permission denied
129
197
 
130
- If you get a permission error, try:
198
+ If you get a permission error with npx, try:
131
199
 
132
200
  ```bash
133
- npx create-diggocms-app@latest --use-npm
201
+ npm install -g create-diggocms-app
202
+ create-diggocms-app
134
203
  ```
135
204
 
136
205
  Or use a Node version manager like nvm/fnm.
@@ -143,6 +212,10 @@ If the mock API server fails to start due to port conflicts, set a different por
143
212
  PORT=3002 bun run mock:api
144
213
  ```
145
214
 
215
+ ### Hot reload not working
216
+
217
+ Ensure you're using `next dev` (via `bun run dev`, `npm run dev`, `yarn dev`, or `pnpm run dev`). Hot reload is enabled by default in development mode.
218
+
146
219
  ## Contributing
147
220
 
148
221
  This CLI is part of the DiggoCMS SDK monorepo. See the main repository for contribution guidelines.
package/bin/cli.js CHANGED
@@ -1,13 +1,9 @@
1
1
  #!/usr/bin/env node
2
- /**
3
- * Create DiggoCMS App - CLI tool to scaffold new DiggoCMS projects
4
- * Inspired by create-next-app and create-vite
5
- */
6
2
 
7
3
  import { createRequire } from 'module';
8
4
  import { fileURLToPath } from 'url';
9
5
  import { dirname, join } from 'path';
10
- import { cp, mkdir, readFile, writeFile, access, stat } from 'fs/promises';
6
+ import { cp, mkdir, readFile, writeFile, access, stat, readdir, rm } from 'fs/promises';
11
7
  import { execSync } from 'child_process';
12
8
  import process from 'process';
13
9
  import prompts from 'prompts';
@@ -31,11 +27,6 @@ const PACKAGE_MANAGERS = ['bun', 'npm', 'yarn', 'pnpm'];
31
27
 
32
28
  const DEFAULT_PROJECT_NAME = 'my-diggocms-app';
33
29
 
34
- /**
35
- * Validates project name (no spaces, special chars, etc.)
36
- * @param {string} name
37
- * @returns {string | true} Error message or true if valid
38
- */
39
30
  function validateProjectName(name) {
40
31
  if (!name || name.trim().length === 0) {
41
32
  return 'Project name is required';
@@ -52,11 +43,6 @@ function validateProjectName(name) {
52
43
  return true;
53
44
  }
54
45
 
55
- /**
56
- * Checks if directory exists and is not empty
57
- * @param {string} dir
58
- * @returns {Promise<boolean>}
59
- */
60
46
  async function isDirectoryEmpty(dir) {
61
47
  try {
62
48
  const stats = await stat(dir);
@@ -70,11 +56,6 @@ async function isDirectoryEmpty(dir) {
70
56
  }
71
57
  }
72
58
 
73
- /**
74
- * Checks if a command exists
75
- * @param {string} cmd
76
- * @returns {boolean}
77
- */
78
59
  function commandExists(cmd) {
79
60
  try {
80
61
  execSync(`${cmd} --version`, { stdio: 'ignore' });
@@ -84,11 +65,6 @@ function commandExists(cmd) {
84
65
  }
85
66
  }
86
67
 
87
- /**
88
- * Gets the version of Node.js or Bun
89
- * @param {string} runtime
90
- * @returns {string | null}
91
- */
92
68
  function getRuntimeVersion(runtime) {
93
69
  try {
94
70
  const version = execSync(`${runtime} --version`, { encoding: 'utf-8' }).trim();
@@ -98,10 +74,6 @@ function getRuntimeVersion(runtime) {
98
74
  }
99
75
  }
100
76
 
101
- /**
102
- * Checks version requirements
103
- * @returns {{ node: string | null, bun: string | null }}
104
- */
105
77
  function checkRuntimeVersions() {
106
78
  return {
107
79
  node: getRuntimeVersion('node'),
@@ -109,12 +81,7 @@ function checkRuntimeVersions() {
109
81
  };
110
82
  }
111
83
 
112
- /**
113
- * Copies template files to target directory
114
- * @param {string} template
115
- * @param {string} targetDir
116
- */
117
- async function copyTemplate(template, targetDir) {
84
+ async function copyTemplate(template, targetDir, includeFixtures = true) {
118
85
  const templateDir = join(__dirname, '..', 'templates', template);
119
86
 
120
87
  async function copyRecursive(src, dest) {
@@ -124,6 +91,11 @@ async function copyTemplate(template, targetDir) {
124
91
  const srcPath = join(src, entry.name);
125
92
  const destPath = join(dest, entry.name);
126
93
 
94
+ // Skip fixtures if not included (for with-mock template)
95
+ if (entry.name === 'fixtures' && !includeFixtures) {
96
+ continue;
97
+ }
98
+
127
99
  if (entry.isDirectory()) {
128
100
  await mkdir(destPath, { recursive: true });
129
101
  await copyRecursive(srcPath, destPath);
@@ -136,26 +108,36 @@ async function copyTemplate(template, targetDir) {
136
108
  await copyRecursive(templateDir, targetDir);
137
109
  }
138
110
 
139
- /**
140
- * Updates package.json with project name
141
- * @param {string} targetDir
142
- * @param {string} projectName
143
- */
144
- async function updatePackageJson(targetDir, projectName) {
111
+ async function updatePackageJson(targetDir, projectName, packageManager) {
145
112
  const packageJsonPath = join(targetDir, 'package.json');
146
113
  const content = await readFile(packageJsonPath, 'utf-8');
147
114
  const packageJson = JSON.parse(content);
148
115
 
149
116
  packageJson.name = projectName;
150
117
 
118
+ const scripts = packageJson.scripts;
119
+
120
+ if (scripts['dev:mock']) {
121
+ const mockCmd = {
122
+ bun: 'bun run mock:api',
123
+ npm: 'npm run mock:api',
124
+ yarn: 'yarn mock:api',
125
+ pnpm: 'pnpm run mock:api',
126
+ }[packageManager];
127
+
128
+ const devCmd = {
129
+ bun: 'bun run dev',
130
+ npm: 'npm run dev',
131
+ yarn: 'yarn dev',
132
+ pnpm: 'pnpm run dev',
133
+ }[packageManager];
134
+
135
+ scripts['dev:mock'] = `concurrently "${mockCmd}" "${devCmd}"`;
136
+ }
137
+
151
138
  await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
152
139
  }
153
140
 
154
- /**
155
- * Installs dependencies using specified package manager
156
- * @param {string} packageManager
157
- * @param {string} cwd
158
- */
159
141
  function installDependencies(packageManager, cwd) {
160
142
  const installCmd = {
161
143
  bun: 'bun install',
@@ -168,10 +150,6 @@ function installDependencies(packageManager, cwd) {
168
150
  execSync(installCmd, { cwd, stdio: 'inherit' });
169
151
  }
170
152
 
171
- /**
172
- * Initializes git repository
173
- * @param {string} cwd
174
- */
175
153
  function initGit(cwd) {
176
154
  try {
177
155
  execSync('git init', { cwd, stdio: 'ignore' });
@@ -186,14 +164,7 @@ function initGit(cwd) {
186
164
  }
187
165
  }
188
166
 
189
- /**
190
- * Shows the final success message with next steps
191
- * @param {string} projectName
192
- * @param {string} targetDir
193
- * @param {string} packageManager
194
- * @param {string} template
195
- */
196
- function showSuccessMessage(projectName, targetDir, packageManager, template) {
167
+ function showSuccessMessage(projectName, targetDir, packageManager, template, includeFixtures) {
197
168
  const runCmd = {
198
169
  bun: 'bun run',
199
170
  npm: 'npm run',
@@ -202,6 +173,13 @@ function showSuccessMessage(projectName, targetDir, packageManager, template) {
202
173
  }[packageManager];
203
174
 
204
175
  console.log(`\n${green('✔')} Successfully created ${cyan(projectName)}`);
176
+ console.log(`\n${lightGray('Configuration:')}`);
177
+ console.log(` Template: ${cyan(template)}`);
178
+ console.log(` Package manager: ${cyan(packageManager)}`);
179
+ if (template === 'with-mock') {
180
+ console.log(` Fixtures: ${includeFixtures ? cyan('included') : dim('excluded')}`);
181
+ }
182
+
205
183
  console.log(`\n${lightGray('Next steps:')}`);
206
184
  console.log(` ${cyan('cd')} ${projectName}`);
207
185
 
@@ -227,13 +205,9 @@ function showSuccessMessage(projectName, targetDir, packageManager, template) {
227
205
  console.log(`\n${blue('Happy coding with DiggoCMS!')} ${magenta('🚀')}\n`);
228
206
  }
229
207
 
230
- /**
231
- * Main CLI function
232
- */
233
208
  async function main() {
234
209
  console.log(`\n${cyan('◆')} ${bold('DiggoCMS')} ${lightGray('– Create a new CMS-powered app')}\n`);
235
210
 
236
- // Check runtime versions
237
211
  const versions = checkRuntimeVersions();
238
212
 
239
213
  if (!versions.node && !versions.bun) {
@@ -241,7 +215,6 @@ async function main() {
241
215
  process.exit(1);
242
216
  }
243
217
 
244
- // Get project name from command line or prompt
245
218
  let projectName = process.argv[2];
246
219
 
247
220
  if (!projectName) {
@@ -267,7 +240,6 @@ async function main() {
267
240
  process.exit(1);
268
241
  }
269
242
 
270
- // Check if directory exists
271
243
  const targetDir = join(process.cwd(), projectName);
272
244
 
273
245
  try {
@@ -297,18 +269,16 @@ async function main() {
297
269
  }
298
270
  }
299
271
  } catch {
300
- // Directory doesn't exist, create it
301
272
  await mkdir(targetDir, { recursive: true });
302
273
  }
303
274
 
304
- // Choose template
305
275
  const { template } = await prompts({
306
276
  type: 'select',
307
277
  name: 'template',
308
278
  message: 'Choose a template:',
309
279
  choices: [
310
- { title: green('full'), value: 'full', description: 'Complete setup with all components' },
311
- { title: blue('with-mock'), value: 'with-mock', description: 'Full setup + mock API server' },
280
+ { title: green('full'), value: 'full', description: 'Complete setup with all components (SSG, Pages Router)' },
281
+ { title: blue('with-mock'), value: 'with-mock', description: 'Full setup + mock API server + optional fixtures' },
312
282
  { title: yellow('minimal'), value: 'minimal', description: 'Basic setup, add components yourself' },
313
283
  ],
314
284
  initial: 0,
@@ -319,7 +289,17 @@ async function main() {
319
289
  process.exit(1);
320
290
  }
321
291
 
322
- // Choose package manager
292
+ let includeFixtures = true;
293
+ if (template === 'with-mock') {
294
+ const { fixtures } = await prompts({
295
+ type: 'confirm',
296
+ name: 'fixtures',
297
+ message: 'Include sample fixtures (pages, menu, collection)?',
298
+ initial: true,
299
+ });
300
+ includeFixtures = fixtures;
301
+ }
302
+
323
303
  const availableManagers = PACKAGE_MANAGERS.filter(commandExists);
324
304
  const defaultManager = availableManagers.includes('bun') ? 'bun' : 'npm';
325
305
 
@@ -340,24 +320,14 @@ async function main() {
340
320
  process.exit(1);
341
321
  }
342
322
 
343
- // Scaffold project
344
323
  console.log(dim(`\nScaffolding project in ${targetDir}...`));
345
324
 
346
325
  try {
347
- // Copy template
348
- await copyTemplate(template, targetDir);
349
-
350
- // Update package.json
351
- await updatePackageJson(targetDir, projectName);
352
-
353
- // Initialize git
326
+ await copyTemplate(template, targetDir, includeFixtures);
327
+ await updatePackageJson(targetDir, projectName, packageManager);
354
328
  const gitInitialized = initGit(targetDir);
355
-
356
- // Install dependencies
357
329
  installDependencies(packageManager, targetDir);
358
-
359
- // Show success message
360
- showSuccessMessage(projectName, targetDir, packageManager, template);
330
+ showSuccessMessage(projectName, targetDir, packageManager, template, includeFixtures);
361
331
 
362
332
  if (gitInitialized) {
363
333
  console.log(`${green('✔')} Git repository initialized\n`);
@@ -369,22 +339,10 @@ async function main() {
369
339
  }
370
340
  }
371
341
 
372
- // Helper functions
373
342
  function bold(str) {
374
343
  return `\x1b[1m${str}\x1b[0m`;
375
344
  }
376
345
 
377
- async function readdir(path, options) {
378
- const fs = await import('fs/promises');
379
- return fs.readdir(path, options);
380
- }
381
-
382
- async function rm(path, options) {
383
- const fs = await import('fs/promises');
384
- return fs.rm(path, options);
385
- }
386
-
387
- // Run main function
388
346
  main().catch((error) => {
389
347
  console.error(red('\nUnexpected error:'));
390
348
  console.error(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalygo/create-diggocms-app",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "CLI tool to scaffold a new DiggoCMS project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -2,8 +2,9 @@
2
2
  # Copy this file to .env.local and update the values
3
3
 
4
4
  # CMS API Configuration
5
- # Set your DiggoCMS API base URL
6
- BASE_URL=https://your-cms-api.com
5
+ # Set your DiggoCMS API base URL (required when not using mock mode)
6
+ # Example: BASE_URL=https://cms.example.com
7
+ BASE_URL=
7
8
 
8
9
  # Mock Mode
9
10
  # Set to 1 to use local mock data instead of a real API
@@ -1,34 +1,40 @@
1
1
  # My DiggoCMS App
2
2
 
3
- A complete DiggoCMS application built with Next.js and the DiggoCMS SDK.
3
+ A complete DiggoCMS application built with Next.js Pages Router and the DiggoCMS SDK.
4
4
 
5
5
  ## Features
6
6
 
7
- - Dynamic routing with `[...slug]` pattern
8
- - Extended components for the current supported standalone types: title, image, text, video, gallery, and card
9
- - Navigation with dropdown support
10
- - Mock mode for development
11
- - 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
+ - Header renders the main menu from CMS or mock API data
14
+ - Error handling and mock indicators
12
15
 
13
16
  ## Getting Started
14
17
 
15
18
  1. Copy `.env.local.example` to `.env.local` and configure:
19
+
16
20
  ```bash
17
21
  cp .env.local.example .env.local
18
22
  ```
19
23
 
20
24
  2. Install dependencies:
25
+
21
26
  ```bash
22
- npm install
23
- # or
24
27
  bun install
28
+ # or
29
+ npm install
25
30
  ```
26
31
 
27
32
  3. Run the development server:
33
+
28
34
  ```bash
29
- npm run dev
30
- # or
31
35
  bun run dev
36
+ # or
37
+ npm run dev
32
38
  ```
33
39
 
34
40
  4. Open [http://localhost:3000](http://localhost:3000) in your browser.
@@ -37,29 +43,29 @@ A complete DiggoCMS application built with Next.js and the DiggoCMS SDK.
37
43
 
38
44
  ### Using a Real CMS API
39
45
 
40
- Set your CMS API base URL:
46
+ Set your CMS API base URL in `.env.local`:
47
+
41
48
  ```env
42
49
  BASE_URL=https://your-cms-api.com
43
50
  MOCK=0
44
51
  ```
45
52
 
53
+ Note: The template defaults to an empty `BASE_URL`. You must configure it before running in non-mock mode. Requests timeout after 5 seconds to prevent hanging.
54
+
46
55
  ### Using Mock Mode
47
56
 
48
57
  Enable mock mode for development without a real API:
58
+
49
59
  ```env
50
60
  MOCK=1
51
61
  MOCK_API_URL=http://localhost:3001
52
62
  ```
53
63
 
54
- ## Project Structure
64
+ When `MOCK=1`, the `BASE_URL` setting is ignored.
55
65
 
56
- ```
57
- app/ # Next.js app router
58
- ├── [...slug]/ # Dynamic catch-all route
59
- ├── layout.tsx # Root layout with DiggoProvider
60
- ├── page.tsx # Home redirect
61
- └── globals.css # Global styles
66
+ ## Project Structure
62
67
 
68
+ ```text
63
69
  components/ # React components
64
70
  ├── DiggoProvider.tsx # SDK provider wrapper
65
71
  ├── server-components.ts # Server-safe component exports
@@ -75,11 +81,30 @@ components/ # React components
75
81
  lib/ # Utility functions
76
82
  ├── diggo-config.ts # SDK configuration
77
83
  └── data-fetching.ts # Data fetching helpers
84
+
85
+ pages/ # Next.js pages (Pages Router)
86
+ ├── _app.tsx # App wrapper with DiggoProvider
87
+ ├── index.tsx # Home redirect
88
+ └── [...slug].tsx # Dynamic catch-all route
89
+
90
+ public/ # Static assets
91
+ styles/ # Global styles
92
+ └── globals.css # Tailwind + component styles
78
93
  ```
79
94
 
95
+ ## Scripts
96
+
97
+ | Script | Description |
98
+ |--------|-------------|
99
+ | `bun run dev` | Start development server with hot reload |
100
+ | `bun run build` | Build for static export |
101
+ | `bun run start` | Start production server |
102
+ | `bun run lint` | Run ESLint |
103
+ | `bun run typecheck` | Run TypeScript check |
104
+
80
105
  ## Extended Components
81
106
 
82
- This template includes extended versions of the current SDK component set used by the starter:
107
+ This template includes extended versions of all SDK-supported component types:
83
108
 
84
109
  - **ExtendedTitle** - Styled H1 heading
85
110
  - **ExtendedImage** - Responsive image with shadow
@@ -90,11 +115,27 @@ This template includes extended versions of the current SDK component set used b
90
115
  - **ExtendedMenuItem** - Navigation item with active state
91
116
  - **ExtendedMenuContainer** - Navigation wrapper
92
117
 
93
- Standalone page payloads in this template are expected to use only the supported types above. Card payloads can still include internal card fields such as `richtext` when provided by the CMS.
118
+ Page payloads should use only the supported types above. Card payloads can include card-specific fields such as `richtext` when provided by the CMS.
119
+
120
+ ## SSG Configuration
121
+
122
+ By default, pages are generated on-demand. To pre-generate pages at build time, modify `getStaticPaths` in `pages/[...slug].tsx`:
123
+
124
+ ```typescript
125
+ export const getStaticPaths: GetStaticPaths = async () => {
126
+ // Fetch all page slugs from your CMS
127
+ const pages = await fetchAllPages();
128
+
129
+ return {
130
+ paths: pages.map(page => ({ params: { slug: page.slug.split('/') } })),
131
+ fallback: 'blocking',
132
+ };
133
+ };
134
+ ```
94
135
 
95
136
  ## Customization
96
137
 
97
- 1. Edit styles in `app/globals.css`
138
+ 1. Edit styles in `styles/globals.css`
98
139
  2. Modify components in `components/`
99
140
  3. Update configuration in `lib/diggo-config.ts`
100
141
  4. Add more data fetching functions in `lib/data-fetching.ts`
@@ -102,4 +143,5 @@ Standalone page payloads in this template are expected to use only the supported
102
143
  ## Documentation
103
144
 
104
145
  - [DiggoCMS SDK Documentation](https://github.com/digitalygo/diggocms-sdk)
105
- - [Next.js Documentation](https://nextjs.org/docs)
146
+ - [Next.js Pages Router Documentation](https://nextjs.org/docs/pages)
147
+ - [Tailwind CSS Documentation](https://tailwindcss.com/docs)