@agility/create-next-app 1.0.0-beta.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/.claude/settings.json +7 -0
- package/.claude/settings.local.json +24 -0
- package/FEATURE_ROADMAP.md +343 -0
- package/README.md +205 -0
- package/TESTING.md +131 -0
- package/bin/create-agility-app.js +48 -0
- package/dist/agility/api-keys/generateApiKeys.d.ts +9 -0
- package/dist/agility/api-keys/generateApiKeys.d.ts.map +1 -0
- package/dist/agility/api-keys/generateApiKeys.js +99 -0
- package/dist/agility/api-keys/generateApiKeys.js.map +1 -0
- package/dist/agility/api-keys/getApiKeys.d.ts +9 -0
- package/dist/agility/api-keys/getApiKeys.d.ts.map +1 -0
- package/dist/agility/api-keys/getApiKeys.js +14 -0
- package/dist/agility/api-keys/getApiKeys.js.map +1 -0
- package/dist/agility/index.d.ts +3 -0
- package/dist/agility/index.d.ts.map +1 -0
- package/dist/agility/index.js +8 -0
- package/dist/agility/index.js.map +1 -0
- package/dist/agility/instance/createNewInstance.d.ts +8 -0
- package/dist/agility/instance/createNewInstance.d.ts.map +1 -0
- package/dist/agility/instance/createNewInstance.js +65 -0
- package/dist/agility/instance/createNewInstance.js.map +1 -0
- package/dist/agility/instance/getAvailableInstances.d.ts +8 -0
- package/dist/agility/instance/getAvailableInstances.d.ts.map +1 -0
- package/dist/agility/instance/getAvailableInstances.js +43 -0
- package/dist/agility/instance/getAvailableInstances.js.map +1 -0
- package/dist/agility/instance/manageInstance.d.ts +9 -0
- package/dist/agility/instance/manageInstance.d.ts.map +1 -0
- package/dist/agility/instance/manageInstance.js +82 -0
- package/dist/agility/instance/manageInstance.js.map +1 -0
- package/dist/agility/utils/getMgmtAPIUrl.d.ts +20 -0
- package/dist/agility/utils/getMgmtAPIUrl.d.ts.map +1 -0
- package/dist/agility/utils/getMgmtAPIUrl.js +61 -0
- package/dist/agility/utils/getMgmtAPIUrl.js.map +1 -0
- package/dist/auth/api-key/authenticateWithApiKey.d.ts +6 -0
- package/dist/auth/api-key/authenticateWithApiKey.d.ts.map +1 -0
- package/dist/auth/api-key/authenticateWithApiKey.js +28 -0
- package/dist/auth/api-key/authenticateWithApiKey.js.map +1 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +8 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/oauth/authenticate.d.ts +6 -0
- package/dist/auth/oauth/authenticate.d.ts.map +1 -0
- package/dist/auth/oauth/authenticate.js +162 -0
- package/dist/auth/oauth/authenticate.js.map +1 -0
- package/dist/auth/oauth/constants.d.ts +5 -0
- package/dist/auth/oauth/constants.d.ts.map +1 -0
- package/dist/auth/oauth/constants.js +9 -0
- package/dist/auth/oauth/constants.js.map +1 -0
- package/dist/auth/oauth/exchangeCodeForToken.d.ts +7 -0
- package/dist/auth/oauth/exchangeCodeForToken.d.ts.map +1 -0
- package/dist/auth/oauth/exchangeCodeForToken.js +39 -0
- package/dist/auth/oauth/exchangeCodeForToken.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +290 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/promptForMissingOptions.d.ts +8 -0
- package/dist/cli/promptForMissingOptions.d.ts.map +1 -0
- package/dist/cli/promptForMissingOptions.js +92 -0
- package/dist/cli/promptForMissingOptions.js.map +1 -0
- package/dist/config/env/createEnvFile.d.ts +6 -0
- package/dist/config/env/createEnvFile.d.ts.map +1 -0
- package/dist/config/env/createEnvFile.js +31 -0
- package/dist/config/env/createEnvFile.js.map +1 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +6 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/mcp/createMcpConfig.d.ts +5 -0
- package/dist/config/mcp/createMcpConfig.d.ts.map +1 -0
- package/dist/config/mcp/createMcpConfig.js +32 -0
- package/dist/config/mcp/createMcpConfig.js.map +1 -0
- package/dist/config/packages/installAgilityPackages.d.ts +6 -0
- package/dist/config/packages/installAgilityPackages.d.ts.map +1 -0
- package/dist/config/packages/installAgilityPackages.js +61 -0
- package/dist/config/packages/installAgilityPackages.js.map +1 -0
- package/dist/config/setupProject.d.ts +8 -0
- package/dist/config/setupProject.d.ts.map +1 -0
- package/dist/config/setupProject.js +32 -0
- package/dist/config/setupProject.js.map +1 -0
- package/dist/create-next-app/createNextApp.d.ts +9 -0
- package/dist/create-next-app/createNextApp.d.ts.map +1 -0
- package/dist/create-next-app/createNextApp.js +83 -0
- package/dist/create-next-app/createNextApp.js.map +1 -0
- package/dist/create-next-app/index.d.ts +3 -0
- package/dist/create-next-app/index.d.ts.map +1 -0
- package/dist/create-next-app/index.js +8 -0
- package/dist/create-next-app/index.js.map +1 -0
- package/dist/scaffold/components/createPageComponents.d.ts +6 -0
- package/dist/scaffold/components/createPageComponents.d.ts.map +1 -0
- package/dist/scaffold/components/createPageComponents.js +62 -0
- package/dist/scaffold/components/createPageComponents.js.map +1 -0
- package/dist/scaffold/containers/createContainers.d.ts +6 -0
- package/dist/scaffold/containers/createContainers.d.ts.map +1 -0
- package/dist/scaffold/containers/createContainers.js +48 -0
- package/dist/scaffold/containers/createContainers.js.map +1 -0
- package/dist/scaffold/index.d.ts +2 -0
- package/dist/scaffold/index.d.ts.map +1 -0
- package/dist/scaffold/index.js +6 -0
- package/dist/scaffold/index.js.map +1 -0
- package/dist/scaffold/instance/createBlankInstance.d.ts +8 -0
- package/dist/scaffold/instance/createBlankInstance.d.ts.map +1 -0
- package/dist/scaffold/instance/createBlankInstance.js +51 -0
- package/dist/scaffold/instance/createBlankInstance.js.map +1 -0
- package/dist/scaffold/models/createContentModels.d.ts +6 -0
- package/dist/scaffold/models/createContentModels.d.ts.map +1 -0
- package/dist/scaffold/models/createContentModels.js +70 -0
- package/dist/scaffold/models/createContentModels.js.map +1 -0
- package/dist/templates/copyDirectory.d.ts +5 -0
- package/dist/templates/copyDirectory.d.ts.map +1 -0
- package/dist/templates/copyDirectory.js +28 -0
- package/dist/templates/copyDirectory.js.map +1 -0
- package/dist/templates/copyTemplates.d.ts +8 -0
- package/dist/templates/copyTemplates.d.ts.map +1 -0
- package/dist/templates/copyTemplates.js +58 -0
- package/dist/templates/copyTemplates.js.map +1 -0
- package/dist/templates/index.d.ts +2 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +6 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/types/index.d.ts +50 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/git.d.ts +9 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +71 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/validation.d.ts +45 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +180 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +45 -0
- package/src/agility/api-keys/generateApiKeys.ts +100 -0
- package/src/agility/api-keys/getApiKeys.ts +13 -0
- package/src/agility/index.ts +3 -0
- package/src/agility/instance/createNewInstance.ts +67 -0
- package/src/agility/instance/getAvailableInstances.ts +49 -0
- package/src/agility/instance/manageInstance.ts +90 -0
- package/src/agility/utils/getMgmtAPIUrl.ts +68 -0
- package/src/auth/api-key/authenticateWithApiKey.ts +24 -0
- package/src/auth/index.ts +3 -0
- package/src/auth/oauth/authenticate.ts +165 -0
- package/src/auth/oauth/constants.ts +6 -0
- package/src/auth/oauth/exchangeCodeForToken.ts +43 -0
- package/src/cli/index.ts +281 -0
- package/src/cli/promptForMissingOptions.ts +104 -0
- package/src/config/env/createEnvFile.ts +30 -0
- package/src/config/index.ts +2 -0
- package/src/config/mcp/createMcpConfig.ts +30 -0
- package/src/config/packages/installAgilityPackages.ts +63 -0
- package/src/config/setupProject.ts +31 -0
- package/src/create-next-app/createNextApp.ts +75 -0
- package/src/create-next-app/index.ts +3 -0
- package/src/scaffold/components/createPageComponents.ts +74 -0
- package/src/scaffold/containers/createContainers.ts +55 -0
- package/src/scaffold/index.ts +2 -0
- package/src/scaffold/instance/createBlankInstance.ts +55 -0
- package/src/scaffold/models/createContentModels.ts +83 -0
- package/src/templates/copyDirectory.ts +24 -0
- package/src/templates/copyTemplates.ts +57 -0
- package/src/templates/index.ts +2 -0
- package/src/types/index.ts +55 -0
- package/src/utils/git.ts +74 -0
- package/src/utils/validation.ts +184 -0
- package/templates/.claude/QUICK-START.md +230 -0
- package/templates/.claude/README.md +32 -0
- package/templates/.claude/settings.json +8 -0
- package/templates/BLANK-INSTANCE-SETUP.md +375 -0
- package/templates/DEVELOPMENT.md +160 -0
- package/templates/EXAMPLE-PROMPTS.md +643 -0
- package/templates/PROMPTS.md +410 -0
- package/templates/README.md +281 -0
- package/templates/agents.md +429 -0
- package/templates/app/[locale]/[...slug]/error.tsx +17 -0
- package/templates/app/[locale]/[...slug]/not-found.tsx +9 -0
- package/templates/app/[locale]/[...slug]/page.tsx +102 -0
- package/templates/app/[locale]/layout.tsx +22 -0
- package/templates/app/[locale]/page.tsx +12 -0
- package/templates/app/api/dynamic-redirect/route.ts +24 -0
- package/templates/app/api/preview/exit/route.ts +34 -0
- package/templates/app/api/preview/route.ts +63 -0
- package/templates/app/api/revalidate/route.ts +118 -0
- package/templates/components/agility-components/RichTextArea.tsx +66 -0
- package/templates/components/agility-components/index.ts +30 -0
- package/templates/components/agility-pages/MainTemplate.tsx +36 -0
- package/templates/components/agility-pages/index.ts +11 -0
- package/templates/docs/01-agility-cms-overview.md +139 -0
- package/templates/docs/02-page-routing.md +251 -0
- package/templates/docs/03-creating-components.md +462 -0
- package/templates/docs/04-data-fetching.md +484 -0
- package/templates/docs/05-containers-and-lists.md +596 -0
- package/templates/docs/06-localization.md +561 -0
- package/templates/docs/07-caching-strategies.md +410 -0
- package/templates/docs/08-common-components.md +756 -0
- package/templates/docs/09-whats-included.md +279 -0
- package/templates/docs/10-mcp-server-setup.md +153 -0
- package/templates/docs/11-linked-nested-content.md +611 -0
- package/templates/docs/README.md +164 -0
- package/templates/lib/cms/getAgilityContext.ts +28 -0
- package/templates/lib/cms/getAgilityPage.ts +51 -0
- package/templates/lib/cms/getAgilitySDK.ts +22 -0
- package/templates/lib/cms/getContentItem.ts +20 -0
- package/templates/lib/cms/getContentList.ts +19 -0
- package/templates/lib/cms/getRedirections.ts +85 -0
- package/templates/lib/cms/getSitemapFlat.ts +19 -0
- package/templates/lib/cms/getSitemapNested.ts +19 -0
- package/templates/lib/env.ts +99 -0
- package/templates/lib/i18n/config.ts +28 -0
- package/templates/proxy.ts +101 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Reserved names that cannot be used as project names
|
|
7
|
+
*/
|
|
8
|
+
const RESERVED_NAMES = [
|
|
9
|
+
'node_modules',
|
|
10
|
+
'package.json',
|
|
11
|
+
'package-lock.json',
|
|
12
|
+
'yarn.lock',
|
|
13
|
+
'pnpm-lock.yaml',
|
|
14
|
+
'bun.lockb',
|
|
15
|
+
'.git',
|
|
16
|
+
'.env',
|
|
17
|
+
'.env.local',
|
|
18
|
+
'dist',
|
|
19
|
+
'build',
|
|
20
|
+
'out',
|
|
21
|
+
'test',
|
|
22
|
+
'tests',
|
|
23
|
+
'__tests__',
|
|
24
|
+
'public',
|
|
25
|
+
'static',
|
|
26
|
+
'src',
|
|
27
|
+
'lib',
|
|
28
|
+
'components',
|
|
29
|
+
'app',
|
|
30
|
+
'pages',
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Validates a project name
|
|
35
|
+
*/
|
|
36
|
+
export function validateProjectName(projectName: string): { valid: boolean; message?: string } {
|
|
37
|
+
// Check if empty
|
|
38
|
+
if (!projectName || projectName.trim().length === 0) {
|
|
39
|
+
return {
|
|
40
|
+
valid: false,
|
|
41
|
+
message: 'Project name cannot be empty',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Check for valid characters (lowercase letters, numbers, hyphens, underscores)
|
|
46
|
+
if (!/^[a-z0-9-_]+$/i.test(projectName)) {
|
|
47
|
+
return {
|
|
48
|
+
valid: false,
|
|
49
|
+
message: 'Project name can only contain letters, numbers, hyphens (-), and underscores (_)',
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Check if it starts with a dot
|
|
54
|
+
if (projectName.startsWith('.')) {
|
|
55
|
+
return {
|
|
56
|
+
valid: false,
|
|
57
|
+
message: 'Project name cannot start with a dot (.)',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Check if it starts with a number
|
|
62
|
+
if (/^\d/.test(projectName)) {
|
|
63
|
+
return {
|
|
64
|
+
valid: false,
|
|
65
|
+
message: 'Project name cannot start with a number',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Check for reserved names
|
|
70
|
+
if (RESERVED_NAMES.includes(projectName.toLowerCase())) {
|
|
71
|
+
return {
|
|
72
|
+
valid: false,
|
|
73
|
+
message: `"${projectName}" is a reserved name and cannot be used`,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { valid: true };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Checks if a directory already exists
|
|
82
|
+
*/
|
|
83
|
+
export function checkDirectoryExists(projectPath: string): boolean {
|
|
84
|
+
return fs.existsSync(projectPath);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Checks if directory is empty
|
|
89
|
+
*/
|
|
90
|
+
export function isDirectoryEmpty(projectPath: string): boolean {
|
|
91
|
+
if (!fs.existsSync(projectPath)) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const files = fs.readdirSync(projectPath);
|
|
96
|
+
return files.length === 0 || files.every(file => file === '.git');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Validates that we can create a project at the given path
|
|
101
|
+
*/
|
|
102
|
+
export function validateProjectPath(projectPath: string): { valid: boolean; message?: string } {
|
|
103
|
+
const exists = checkDirectoryExists(projectPath);
|
|
104
|
+
|
|
105
|
+
if (exists) {
|
|
106
|
+
const isEmpty = isDirectoryEmpty(projectPath);
|
|
107
|
+
if (!isEmpty) {
|
|
108
|
+
return {
|
|
109
|
+
valid: false,
|
|
110
|
+
message: `Directory "${path.basename(projectPath)}" already exists and is not empty.\nPlease choose a different project name or remove the existing directory.`,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Check write permissions of parent directory
|
|
116
|
+
const parentDir = path.dirname(projectPath);
|
|
117
|
+
try {
|
|
118
|
+
fs.accessSync(parentDir, fs.constants.W_OK);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
return {
|
|
121
|
+
valid: false,
|
|
122
|
+
message: `No write permission in directory "${parentDir}".\nPlease check your permissions or choose a different location.`,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return { valid: true };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Check if git is installed
|
|
131
|
+
*/
|
|
132
|
+
export function isGitInstalled(): boolean {
|
|
133
|
+
try {
|
|
134
|
+
const { execSync } = require('child_process');
|
|
135
|
+
execSync('git --version', { stdio: 'ignore' });
|
|
136
|
+
return true;
|
|
137
|
+
} catch {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Displays validation error with helpful formatting
|
|
144
|
+
*/
|
|
145
|
+
export function displayValidationError(message: string): void {
|
|
146
|
+
console.error('\n' + chalk.red('✖') + ' ' + chalk.red.bold('Validation Error'));
|
|
147
|
+
console.error(chalk.red(message));
|
|
148
|
+
console.error();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Check available disk space (basic check)
|
|
153
|
+
*/
|
|
154
|
+
export function checkDiskSpace(): { hasSpace: boolean; message?: string } {
|
|
155
|
+
try {
|
|
156
|
+
const os = require('os');
|
|
157
|
+
// Basic check - Next.js projects typically need at least 500MB
|
|
158
|
+
const REQUIRED_SPACE_MB = 500;
|
|
159
|
+
const tmpdir = os.tmpdir();
|
|
160
|
+
|
|
161
|
+
// This is a rough check - not perfect but better than nothing
|
|
162
|
+
return { hasSpace: true };
|
|
163
|
+
} catch {
|
|
164
|
+
// If we can't check, assume it's okay
|
|
165
|
+
return { hasSpace: true };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Validate Node.js version
|
|
171
|
+
*/
|
|
172
|
+
export function validateNodeVersion(): { valid: boolean; message?: string } {
|
|
173
|
+
const currentVersion = process.version;
|
|
174
|
+
const majorVersion = parseInt(currentVersion.split('.')[0].slice(1), 10);
|
|
175
|
+
|
|
176
|
+
if (majorVersion < 18) {
|
|
177
|
+
return {
|
|
178
|
+
valid: false,
|
|
179
|
+
message: `Node.js 18.0.0 or higher is required. You are using ${currentVersion}.\nPlease upgrade Node.js: https://nodejs.org/`,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return { valid: true };
|
|
184
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Quick Start Guide
|
|
2
|
+
|
|
3
|
+
Get up and running with Agility CMS + Next.js in 5 minutes.
|
|
4
|
+
|
|
5
|
+
## 1. Project Setup ✅
|
|
6
|
+
|
|
7
|
+
Your project is already set up with:
|
|
8
|
+
- ✅ Next.js 15 with App Router
|
|
9
|
+
- ✅ Agility CMS integration
|
|
10
|
+
- ✅ Multi-locale support
|
|
11
|
+
- ✅ TypeScript
|
|
12
|
+
- ✅ Caching configured
|
|
13
|
+
- ✅ MCP Server configured (connects AI assistants to your Agility CMS)
|
|
14
|
+
|
|
15
|
+
## 2. Environment Variables
|
|
16
|
+
|
|
17
|
+
Required in `.env.local`:
|
|
18
|
+
```env
|
|
19
|
+
AGILITY_GUID=your-instance-guid
|
|
20
|
+
AGILITY_API_FETCH_KEY=your-fetch-key
|
|
21
|
+
AGILITY_API_PREVIEW_KEY=your-preview-key
|
|
22
|
+
AGILITY_LOCALES=en-us
|
|
23
|
+
AGILITY_SITEMAP=website
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 3. File Structure
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
src/
|
|
30
|
+
├── app/[locale]/[...slug]/page.tsx ← All pages route here
|
|
31
|
+
├── components/
|
|
32
|
+
│ ├── agility-components/ ← Add modules here
|
|
33
|
+
│ └── agility-pages/ ← Add templates here
|
|
34
|
+
└── lib/cms/ ← CMS helper functions
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 4. Common Tasks
|
|
38
|
+
|
|
39
|
+
### Add a New Component
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
// 1. Create: src/components/agility-components/Hero.tsx
|
|
43
|
+
interface HeroProps {
|
|
44
|
+
module: {
|
|
45
|
+
fields: {
|
|
46
|
+
title: string;
|
|
47
|
+
subtitle: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
locale: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default function Hero({ module, locale }: HeroProps) {
|
|
54
|
+
return (
|
|
55
|
+
<div>
|
|
56
|
+
<h1>{module.fields.title}</h1>
|
|
57
|
+
<p>{module.fields.subtitle}</p>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 2. Register: src/components/agility-components/index.ts
|
|
63
|
+
import Hero from "./Hero";
|
|
64
|
+
|
|
65
|
+
export const getModule = (moduleName: string) => {
|
|
66
|
+
switch (moduleName) {
|
|
67
|
+
case "Hero":
|
|
68
|
+
return Hero;
|
|
69
|
+
// ... other modules
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// 3. Create module in Agility CMS with reference name "Hero"
|
|
74
|
+
// 4. Add to page in Agility CMS
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Fetch a Content List
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { getContentList } from "@/lib/cms/getContentList";
|
|
81
|
+
|
|
82
|
+
export default async function BlogList({ locale }: any) {
|
|
83
|
+
const posts = await getContentList({
|
|
84
|
+
referenceName: "posts",
|
|
85
|
+
locale,
|
|
86
|
+
take: 10,
|
|
87
|
+
sort: "fields.date desc",
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div>
|
|
92
|
+
{posts.map((post) => (
|
|
93
|
+
<article key={post.contentID}>
|
|
94
|
+
<h2>{post.fields.title}</h2>
|
|
95
|
+
</article>
|
|
96
|
+
))}
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Add Interactive Component
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
// Server component (fetches data)
|
|
106
|
+
import MyClient from "./MyComponent.client";
|
|
107
|
+
|
|
108
|
+
export default async function MyComponent({ locale }: any) {
|
|
109
|
+
const data = await fetchData(locale);
|
|
110
|
+
return <MyClient data={data} />;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Client component (interactivity)
|
|
114
|
+
"use client";
|
|
115
|
+
import { useState } from "react";
|
|
116
|
+
|
|
117
|
+
export default function MyClient({ data }: any) {
|
|
118
|
+
const [active, setActive] = useState(false);
|
|
119
|
+
return <button onClick={() => setActive(!active)}>Toggle</button>;
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## 5. Development
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npm run dev # Start development server
|
|
127
|
+
npm run build # Build for production
|
|
128
|
+
npm run start # Start production server
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 6. Key Concepts
|
|
132
|
+
|
|
133
|
+
### Components (Modules in CMS)
|
|
134
|
+
Reusable components editors add to pages. Created in Agility CMS, implemented as React components.
|
|
135
|
+
|
|
136
|
+
### Page Templates
|
|
137
|
+
Define page layout with zones. Components (Modules in CMS) are placed in zones.
|
|
138
|
+
|
|
139
|
+
### Content Lists
|
|
140
|
+
Collections like blog posts, testimonials, team members. Fetched with `getContentList()`.
|
|
141
|
+
|
|
142
|
+
### Locales
|
|
143
|
+
Multi-language support. Default locale (en-us) has clean URLs, others prefixed (/fr/, /es/).
|
|
144
|
+
|
|
145
|
+
## 7. CMS Helper Functions
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
import {
|
|
149
|
+
getAgilityPage, // Fetch complete page
|
|
150
|
+
getContentItem, // Fetch single item
|
|
151
|
+
getContentList, // Fetch collection
|
|
152
|
+
getSitemapFlat, // Fetch sitemap
|
|
153
|
+
} from "@/lib/cms";
|
|
154
|
+
|
|
155
|
+
// Fetch page
|
|
156
|
+
const page = await getAgilityPage({ params });
|
|
157
|
+
|
|
158
|
+
// Fetch single item
|
|
159
|
+
const item = await getContentItem({ contentID: 123, locale: "en-us" });
|
|
160
|
+
|
|
161
|
+
// Fetch list
|
|
162
|
+
const items = await getContentList({ referenceName: "posts", locale: "en-us" });
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## 8. MCP Server Setup (Optional but Recommended)
|
|
166
|
+
|
|
167
|
+
The Agility CMS MCP Server allows AI assistants to directly access your CMS content and configuration. This makes it easier to build components and features.
|
|
168
|
+
|
|
169
|
+
**The MCP server is pre-configured in this project!** Just authenticate when prompted.
|
|
170
|
+
|
|
171
|
+
For manual setup or troubleshooting, see [10-mcp-server-setup.md](./docs/10-mcp-server-setup.md).
|
|
172
|
+
|
|
173
|
+
## 9. Next Steps
|
|
174
|
+
|
|
175
|
+
1. **Setup MCP**: Read [10-mcp-server-setup.md](./docs/10-mcp-server-setup.md) to connect your AI assistant
|
|
176
|
+
2. **Read docs**: Check `.claude/README.md`
|
|
177
|
+
3. **Create modules**: Follow [03-creating-components.md](./docs/03-creating-components.md)
|
|
178
|
+
4. **See examples**: Check [08-common-components.md](./docs/08-common-components.md)
|
|
179
|
+
5. **Build your site**: Ask your AI assistant to help!
|
|
180
|
+
|
|
181
|
+
## 10. Getting Help
|
|
182
|
+
|
|
183
|
+
### Documentation
|
|
184
|
+
- [MCP Server Setup](./docs/10-mcp-server-setup.md) - Connect AI assistant to CMS
|
|
185
|
+
- [AI Assistant Guide](./docs/00-ai-assistant-guide.md) - For AI coding
|
|
186
|
+
- [Agility CMS Overview](./docs/01-agility-cms-overview.md) - How it works
|
|
187
|
+
- [Creating Components](./docs/03-creating-components.md) - Build components
|
|
188
|
+
- [Common Components](./docs/08-common-components.md) - Examples
|
|
189
|
+
|
|
190
|
+
### AI Assistant Prompts
|
|
191
|
+
|
|
192
|
+
Try these prompts with your AI assistant:
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
"Add a blog listing with pagination"
|
|
196
|
+
"Create a hero section with background image"
|
|
197
|
+
"Add a contact form"
|
|
198
|
+
"Implement a testimonials carousel"
|
|
199
|
+
"Add FAQ accordion"
|
|
200
|
+
"Create a team members grid"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## 11. Checklist
|
|
204
|
+
|
|
205
|
+
Before deploying, make sure:
|
|
206
|
+
- [ ] Environment variables set
|
|
207
|
+
- [ ] Components (Modules in CMS) registered in index.ts
|
|
208
|
+
- [ ] Content created in Agility CMS
|
|
209
|
+
- [ ] Locales configured if multi-language
|
|
210
|
+
- [ ] Build succeeds (`npm run build`)
|
|
211
|
+
- [ ] Test preview mode
|
|
212
|
+
- [ ] Test all pages and modules
|
|
213
|
+
|
|
214
|
+
## Quick Reference
|
|
215
|
+
|
|
216
|
+
| Task | File | Function |
|
|
217
|
+
|------|------|----------|
|
|
218
|
+
| Add module | `agility-components/YourModule.tsx` | `export default function` |
|
|
219
|
+
| Register module | `agility-components/index.ts` | Add to `getModule()` |
|
|
220
|
+
| Add template | `agility-pages/YourTemplate.tsx` | Use `<ContentZone>` |
|
|
221
|
+
| Register template | `agility-pages/index.ts` | Add to `getPageTemplate()` |
|
|
222
|
+
| Fetch page | Any component | `getAgilityPage({ params })` |
|
|
223
|
+
| Fetch item | Any component | `getContentItem({ contentID, locale })` |
|
|
224
|
+
| Fetch list | Any component | `getContentList({ referenceName, locale })` |
|
|
225
|
+
| Configure locales | `lib/i18n/config.ts` | Update `locales` array |
|
|
226
|
+
| Env vars | `.env.local` | Add `AGILITY_*` vars |
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
**Ready to build? Start with: "Hey assistant, add a blog to my site!"** 🚀
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Agility CMS + Next.js - Claude Code Configuration
|
|
2
|
+
|
|
3
|
+
This directory contains Claude Code specific configuration and agent documentation.
|
|
4
|
+
|
|
5
|
+
## For AI Coding Assistants
|
|
6
|
+
|
|
7
|
+
**📖 Start Here**: Read [agents.md](./agents.md) - Complete guide for AI coding assistants working with Agility CMS
|
|
8
|
+
|
|
9
|
+
## General Documentation
|
|
10
|
+
|
|
11
|
+
All general documentation has been moved to the `/docs` folder in the project root:
|
|
12
|
+
|
|
13
|
+
### Core Concepts
|
|
14
|
+
- **[../docs/01-agility-cms-overview.md](../docs/01-agility-cms-overview.md)** - How Agility CMS works
|
|
15
|
+
- **[../docs/02-page-routing.md](../docs/02-page-routing.md)** - Dynamic routing and URLs
|
|
16
|
+
|
|
17
|
+
### Development
|
|
18
|
+
- **[../docs/03-creating-components.md](../docs/03-creating-components.md)** - Create module components
|
|
19
|
+
- **[../docs/04-data-fetching.md](../docs/04-data-fetching.md)** - Fetch content from CMS
|
|
20
|
+
- **[../docs/05-containers-and-lists.md](../docs/05-containers-and-lists.md)** - Work with content lists
|
|
21
|
+
- **[../docs/08-common-components.md](../docs/08-common-components.md)** - Ready-to-use examples
|
|
22
|
+
|
|
23
|
+
### Advanced Features
|
|
24
|
+
- **[../docs/06-localization.md](../docs/06-localization.md)** - Multi-language support
|
|
25
|
+
- **[../docs/07-caching-strategies.md](../docs/07-caching-strategies.md)** - Performance optimization
|
|
26
|
+
- **[../docs/10-mcp-server-setup.md](../docs/10-mcp-server-setup.md)** - AI assistant MCP integration
|
|
27
|
+
- **[../docs/11-linked-nested-content.md](../docs/11-linked-nested-content.md)** - Linked and nested content patterns
|
|
28
|
+
|
|
29
|
+
## Claude Code Settings
|
|
30
|
+
|
|
31
|
+
- **[settings.json](./settings.json)** - Claude Code project settings
|
|
32
|
+
- **[QUICK-START.md](./QUICK-START.md)** - Quick reference for Claude Code users
|