create-content-sdk-app 1.3.1-canary.2 → 1.3.1

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 (36) hide show
  1. package/dist/templates/nextjs/.cursor/rules/general.mdc +81 -81
  2. package/dist/templates/nextjs/.cursor/rules/javascript.mdc +112 -112
  3. package/dist/templates/nextjs/.cursor/rules/project-setup.mdc +100 -100
  4. package/dist/templates/nextjs/.cursor/rules/sitecore.mdc +147 -147
  5. package/dist/templates/nextjs/.env.container.example +27 -27
  6. package/dist/templates/nextjs/.env.remote.example +45 -45
  7. package/dist/templates/nextjs/.gitattributes +11 -11
  8. package/dist/templates/nextjs/.prettierrc +8 -8
  9. package/dist/templates/nextjs/.vscode/extensions.json +8 -8
  10. package/dist/templates/nextjs/.vscode/launch.json +15 -15
  11. package/dist/templates/nextjs/.windsurfrules +183 -183
  12. package/dist/templates/nextjs/LICENSE.txt +202 -202
  13. package/dist/templates/nextjs/LLMs.txt +179 -179
  14. package/dist/templates/nextjs/eslint.config.mjs +81 -81
  15. package/dist/templates/nextjs/gitignore +28 -28
  16. package/dist/templates/nextjs/package.json +68 -68
  17. package/dist/templates/nextjs/sitecore.config.ts.example +38 -38
  18. package/dist/templates/nextjs/tsconfig.json +40 -40
  19. package/dist/templates/nextjs-app-router/.cursor/rules/app-router-setup.mdc +116 -116
  20. package/dist/templates/nextjs-app-router/.cursor/rules/general.mdc +80 -80
  21. package/dist/templates/nextjs-app-router/.cursor/rules/javascript.mdc +112 -112
  22. package/dist/templates/nextjs-app-router/.cursor/rules/sitecore.mdc +171 -171
  23. package/dist/templates/nextjs-app-router/.env.container.example +27 -27
  24. package/dist/templates/nextjs-app-router/.env.remote.example +45 -45
  25. package/dist/templates/nextjs-app-router/.gitattributes +11 -11
  26. package/dist/templates/nextjs-app-router/.windsurfrules +287 -287
  27. package/dist/templates/nextjs-app-router/LLMs.txt +236 -236
  28. package/dist/templates/nextjs-app-router/eslint.config.mjs +29 -29
  29. package/dist/templates/nextjs-app-router/gitignore +31 -31
  30. package/dist/templates/nextjs-app-router/package.json +54 -54
  31. package/dist/templates/nextjs-app-router/postcss.config.mjs +5 -5
  32. package/dist/templates/nextjs-app-router/sitecore.config.ts.example +38 -38
  33. package/dist/templates/nextjs-app-router/src/app/globals.css +1 -1
  34. package/dist/templates/nextjs-app-router/tsconfig.json +48 -48
  35. package/package.json +73 -74
  36. package/LICENSE.MD +0 -202
@@ -1,287 +1,287 @@
1
- # Sitecore Content SDK Next.js App Router Project - Windsurf AI Rules
2
-
3
- ## Project Purpose and Tech Stack
4
-
5
- This is a **Sitecore Content SDK** application built with **Next.js App Router** and **TypeScript**. The project follows Sitecore best practices for XM Cloud development and leverages the latest Next.js App Router features for improved performance and developer experience.
6
-
7
- ### Key Technologies
8
-
9
- - **Next.js App Router** - React framework with Server Components and modern routing
10
- - **Sitecore Content SDK** - Official SDK for Sitecore XM Cloud integration
11
- - **TypeScript** - Type-safe JavaScript development
12
- - **Sitecore XM Cloud** - Headless CMS platform
13
- - **React Server Components** - Server-side rendering for better performance
14
- - **next-intl** - Internationalization support
15
-
16
- ## Coding Standards
17
-
18
- ### TypeScript Standards
19
-
20
- - Use **strict mode** in tsconfig.json
21
- - Prefer type assertions over `any`: `value as ContentItem`
22
- - Use discriminated unions for complex state management
23
- - Enable strict null checks and strict function types
24
-
25
- ### Naming Conventions
26
-
27
- - **Variables/Functions**: camelCase (`getUserData()`, `isLoading`, `currentUser`)
28
- - **Components**: PascalCase (`SitecoreComponent`, `PageLayout`, `ContentBlock`)
29
- - **Constants**: UPPER_SNAKE_CASE (`API_ENDPOINT`, `DEFAULT_TIMEOUT`)
30
- - **Directories**: kebab-case (`src/components`, `src/api-clients`)
31
- - **Types/Interfaces**: PascalCase (`ContentItem`, `LayoutProps`, `SitecoreConfig`)
32
-
33
- ### Modular Layout (App Router)
34
-
35
- ```
36
- src/
37
- app/ # App Router pages and layouts
38
- components/ # UI components (React)
39
- lib/ # Configuration and utilities
40
- i18n/ # Internationalization setup
41
- types/ # TypeScript type definitions
42
- hooks/ # Custom React hooks
43
- ```
44
-
45
- ## Library Usage
46
-
47
- ### @sitecore-content-sdk
48
-
49
- - Use `SitecoreClient` for content fetching
50
- - Implement proper error handling with try/catch blocks
51
- - Cache API responses using React Query or SWR
52
- - Handle content preview vs. published content scenarios
53
-
54
- ```typescript
55
- import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
56
- import scConfig from 'sitecore.config';
57
-
58
- const client = new SitecoreClient({
59
- ...scConfig,
60
- });
61
- ```
62
-
63
- ### React App Router Patterns
64
-
65
- - Use **Server Components** for data fetching and static content (default)
66
- - Use **Client Components** for interactivity (use 'use client' directive)
67
- - Implement proper error boundaries with error.tsx
68
- - Use loading.tsx for loading states
69
- - Leverage layout.tsx for shared page structure
70
-
71
- ### Sitecore Field Components
72
-
73
- - Always use Sitecore field components: `<Text>`, `<RichText>`, `<Image>`
74
- - Validate field existence before rendering
75
- - Handle empty/null fields gracefully
76
- - Prefer Sitecore field components over manual rendering
77
-
78
- ```typescript
79
- // Good: Using Sitecore field components
80
- <Text field={fields?.title} tag="h1" />
81
- <RichText field={fields?.content} />
82
- <Image field={fields?.backgroundImage} />
83
-
84
- // Avoid: Manual field value extraction unless necessary
85
- ```
86
-
87
- ## Example Patterns and Prompts
88
-
89
- ### Server Component Development
90
-
91
- ```typescript
92
- // Server Component example (default in App Router)
93
- import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
94
- import scConfig from 'sitecore.config';
95
-
96
- const client = new SitecoreClient({
97
- ...scConfig,
98
- });
99
-
100
- export default async function SitecorePage({ params }: { params: { path: string[] } }) {
101
- try {
102
- const pageData = await client.getPage(params.path.join('/'));
103
- return <SitecoreLayout layoutData={pageData?.layout} />;
104
- } catch (error) {
105
- return <div>Content not found</div>;
106
- }
107
- }
108
- ```
109
-
110
- ### Client Component Integration
111
-
112
- Interactive Sitecore Components:
113
-
114
- - Use 'use client' directive when needed
115
- - Keep client components focused on interactivity
116
- - Pass server-fetched data as props
117
- - Handle hydration mismatches carefully
118
-
119
- ```typescript
120
- 'use client';
121
-
122
- interface InteractiveSitecoreComponentProps {
123
- fields: {
124
- title: Field;
125
- content: Field;
126
- };
127
- }
128
-
129
- export default function InteractiveSitecoreComponent({
130
- fields,
131
- }: InteractiveSitecoreComponentProps) {
132
- // Client-side interactivity here
133
- return (
134
- <div>
135
- <Text field={fields?.title} tag="h2" />
136
- <RichText field={fields?.content} />
137
- </div>
138
- );
139
- }
140
- ```
141
-
142
- ### Component Development
143
-
144
- ```typescript
145
- // Component props interface
146
- interface HeroProps {
147
- fields: {
148
- title: Field;
149
- subtitle: Field;
150
- backgroundImage: Field;
151
- };
152
- }
153
-
154
- export default function Hero({ fields }: HeroProps) {
155
- return (
156
- <div>
157
- <Text field={fields?.title} tag="h1" />
158
- <Text field={fields?.subtitle} tag="p" />
159
- <Image field={fields?.backgroundImage} />
160
- </div>
161
- );
162
- }
163
- ```
164
-
165
- ### Error Handling
166
-
167
- API Calls:
168
-
169
- - Always wrap in try/catch blocks
170
- - Throw custom errors with context: `SitecoreFetchError`, `ConfigurationError`
171
- - Handle edge cases with guard clauses
172
-
173
- ```typescript
174
- async function fetchPageData(path: string): Promise<Page | null> {
175
- if (!path) {
176
- throw new Error('Page path is required');
177
- }
178
-
179
- try {
180
- const pageData = await client.getPage(path);
181
- return pageData;
182
- } catch (error) {
183
- throw new SitecoreFetchError(`Failed to fetch page data for ${path}`, error);
184
- }
185
- }
186
- ```
187
-
188
- ### Configuration
189
-
190
- ```typescript
191
- // sitecore.config.ts
192
- import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
193
-
194
- export default defineConfig({
195
- api: {
196
- edge: {
197
- contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
198
- clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
199
- edgeUrl: process.env.SITECORE_EDGE_URL || 'https://edge-platform.sitecorecloud.io',
200
- },
201
- local: {
202
- apiKey: process.env.SITECORE_API_KEY || '',
203
- apiHost: process.env.SITECORE_API_HOST || '',
204
- },
205
- },
206
- defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
207
- defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
208
- editingSecret: process.env.SITECORE_EDITING_SECRET,
209
- });
210
- ```
211
-
212
- ### Internationalization
213
-
214
- Multi-language Support:
215
-
216
- - Configure next-intl for language routing
217
- - Handle Sitecore language contexts
218
- - Implement language switching
219
- - Use proper locale-based data fetching
220
-
221
- ```typescript
222
- // Language-aware data fetching
223
- import { getTranslations } from 'next-intl/server';
224
-
225
- export default async function LocalizedPage() {
226
- const t = await getTranslations('common');
227
- // Fetch Sitecore content for current locale
228
- }
229
- ```
230
-
231
- ## Development Workflow
232
-
233
- 1. **Install dependencies**: `npm install`
234
- 2. **Configure environment**: Copy `.env.example` to `.env.local`
235
- 3. **Start development**: `npm run dev`
236
- 4. **Build for production**: `npm run build`
237
-
238
- ## App Router Best Practices
239
-
240
- ### Server vs Client Components
241
-
242
- - Use Server Components for Sitecore content rendering (default)
243
- - Use Client Components for user interactions
244
- - Minimize client-side JavaScript
245
- - Leverage server-side data fetching
246
-
247
- ### Routing and Layouts
248
-
249
- - Use layout.tsx for shared page structure
250
- - Implement loading.tsx for loading states
251
- - Create error.tsx for error boundaries
252
- - Use page.tsx for route content
253
- - Use [...path] for Sitecore catch-all routes
254
-
255
- ### Performance Optimization
256
-
257
- - Leverage Server Components for better performance
258
- - Use streaming for improved loading experience
259
- - Implement proper caching strategies
260
- - Optimize images with Next.js Image component
261
-
262
- ## Best Practices
263
-
264
- ### Performance
265
-
266
- - Optimize images using Next.js Image component
267
- - Implement proper loading states
268
- - Cache expensive operations appropriately
269
- - Consider server-side rendering implications
270
- - Lazy-load non-critical modules
271
- - Use Server Components for better performance
272
-
273
- ### Security
274
-
275
- - Sanitize user inputs before processing
276
- - Validate data at application boundaries
277
- - Use HTTPS for all Sitecore connections
278
- - Never expose sensitive configuration in client-side code
279
- - Escape content when rendering to prevent XSS
280
-
281
- ### Code Quality
282
-
283
- - Follow DRY principle - extract common functionality
284
- - Use SOLID principles for maintainable code
285
- - Write self-documenting code with clear intent
286
- - Implement proper error boundaries
287
- - Test behavior, not implementation details
1
+ # Sitecore Content SDK Next.js App Router Project - Windsurf AI Rules
2
+
3
+ ## Project Purpose and Tech Stack
4
+
5
+ This is a **Sitecore Content SDK** application built with **Next.js App Router** and **TypeScript**. The project follows Sitecore best practices for XM Cloud development and leverages the latest Next.js App Router features for improved performance and developer experience.
6
+
7
+ ### Key Technologies
8
+
9
+ - **Next.js App Router** - React framework with Server Components and modern routing
10
+ - **Sitecore Content SDK** - Official SDK for Sitecore XM Cloud integration
11
+ - **TypeScript** - Type-safe JavaScript development
12
+ - **Sitecore XM Cloud** - Headless CMS platform
13
+ - **React Server Components** - Server-side rendering for better performance
14
+ - **next-intl** - Internationalization support
15
+
16
+ ## Coding Standards
17
+
18
+ ### TypeScript Standards
19
+
20
+ - Use **strict mode** in tsconfig.json
21
+ - Prefer type assertions over `any`: `value as ContentItem`
22
+ - Use discriminated unions for complex state management
23
+ - Enable strict null checks and strict function types
24
+
25
+ ### Naming Conventions
26
+
27
+ - **Variables/Functions**: camelCase (`getUserData()`, `isLoading`, `currentUser`)
28
+ - **Components**: PascalCase (`SitecoreComponent`, `PageLayout`, `ContentBlock`)
29
+ - **Constants**: UPPER_SNAKE_CASE (`API_ENDPOINT`, `DEFAULT_TIMEOUT`)
30
+ - **Directories**: kebab-case (`src/components`, `src/api-clients`)
31
+ - **Types/Interfaces**: PascalCase (`ContentItem`, `LayoutProps`, `SitecoreConfig`)
32
+
33
+ ### Modular Layout (App Router)
34
+
35
+ ```
36
+ src/
37
+ app/ # App Router pages and layouts
38
+ components/ # UI components (React)
39
+ lib/ # Configuration and utilities
40
+ i18n/ # Internationalization setup
41
+ types/ # TypeScript type definitions
42
+ hooks/ # Custom React hooks
43
+ ```
44
+
45
+ ## Library Usage
46
+
47
+ ### @sitecore-content-sdk
48
+
49
+ - Use `SitecoreClient` for content fetching
50
+ - Implement proper error handling with try/catch blocks
51
+ - Cache API responses using React Query or SWR
52
+ - Handle content preview vs. published content scenarios
53
+
54
+ ```typescript
55
+ import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
56
+ import scConfig from 'sitecore.config';
57
+
58
+ const client = new SitecoreClient({
59
+ ...scConfig,
60
+ });
61
+ ```
62
+
63
+ ### React App Router Patterns
64
+
65
+ - Use **Server Components** for data fetching and static content (default)
66
+ - Use **Client Components** for interactivity (use 'use client' directive)
67
+ - Implement proper error boundaries with error.tsx
68
+ - Use loading.tsx for loading states
69
+ - Leverage layout.tsx for shared page structure
70
+
71
+ ### Sitecore Field Components
72
+
73
+ - Always use Sitecore field components: `<Text>`, `<RichText>`, `<Image>`
74
+ - Validate field existence before rendering
75
+ - Handle empty/null fields gracefully
76
+ - Prefer Sitecore field components over manual rendering
77
+
78
+ ```typescript
79
+ // Good: Using Sitecore field components
80
+ <Text field={fields?.title} tag="h1" />
81
+ <RichText field={fields?.content} />
82
+ <Image field={fields?.backgroundImage} />
83
+
84
+ // Avoid: Manual field value extraction unless necessary
85
+ ```
86
+
87
+ ## Example Patterns and Prompts
88
+
89
+ ### Server Component Development
90
+
91
+ ```typescript
92
+ // Server Component example (default in App Router)
93
+ import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
94
+ import scConfig from 'sitecore.config';
95
+
96
+ const client = new SitecoreClient({
97
+ ...scConfig,
98
+ });
99
+
100
+ export default async function SitecorePage({ params }: { params: { path: string[] } }) {
101
+ try {
102
+ const pageData = await client.getPage(params.path.join('/'));
103
+ return <SitecoreLayout layoutData={pageData?.layout} />;
104
+ } catch (error) {
105
+ return <div>Content not found</div>;
106
+ }
107
+ }
108
+ ```
109
+
110
+ ### Client Component Integration
111
+
112
+ Interactive Sitecore Components:
113
+
114
+ - Use 'use client' directive when needed
115
+ - Keep client components focused on interactivity
116
+ - Pass server-fetched data as props
117
+ - Handle hydration mismatches carefully
118
+
119
+ ```typescript
120
+ 'use client';
121
+
122
+ interface InteractiveSitecoreComponentProps {
123
+ fields: {
124
+ title: Field;
125
+ content: Field;
126
+ };
127
+ }
128
+
129
+ export default function InteractiveSitecoreComponent({
130
+ fields,
131
+ }: InteractiveSitecoreComponentProps) {
132
+ // Client-side interactivity here
133
+ return (
134
+ <div>
135
+ <Text field={fields?.title} tag="h2" />
136
+ <RichText field={fields?.content} />
137
+ </div>
138
+ );
139
+ }
140
+ ```
141
+
142
+ ### Component Development
143
+
144
+ ```typescript
145
+ // Component props interface
146
+ interface HeroProps {
147
+ fields: {
148
+ title: Field;
149
+ subtitle: Field;
150
+ backgroundImage: Field;
151
+ };
152
+ }
153
+
154
+ export default function Hero({ fields }: HeroProps) {
155
+ return (
156
+ <div>
157
+ <Text field={fields?.title} tag="h1" />
158
+ <Text field={fields?.subtitle} tag="p" />
159
+ <Image field={fields?.backgroundImage} />
160
+ </div>
161
+ );
162
+ }
163
+ ```
164
+
165
+ ### Error Handling
166
+
167
+ API Calls:
168
+
169
+ - Always wrap in try/catch blocks
170
+ - Throw custom errors with context: `SitecoreFetchError`, `ConfigurationError`
171
+ - Handle edge cases with guard clauses
172
+
173
+ ```typescript
174
+ async function fetchPageData(path: string): Promise<Page | null> {
175
+ if (!path) {
176
+ throw new Error('Page path is required');
177
+ }
178
+
179
+ try {
180
+ const pageData = await client.getPage(path);
181
+ return pageData;
182
+ } catch (error) {
183
+ throw new SitecoreFetchError(`Failed to fetch page data for ${path}`, error);
184
+ }
185
+ }
186
+ ```
187
+
188
+ ### Configuration
189
+
190
+ ```typescript
191
+ // sitecore.config.ts
192
+ import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
193
+
194
+ export default defineConfig({
195
+ api: {
196
+ edge: {
197
+ contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
198
+ clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
199
+ edgeUrl: process.env.SITECORE_EDGE_URL || 'https://edge-platform.sitecorecloud.io',
200
+ },
201
+ local: {
202
+ apiKey: process.env.SITECORE_API_KEY || '',
203
+ apiHost: process.env.SITECORE_API_HOST || '',
204
+ },
205
+ },
206
+ defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
207
+ defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
208
+ editingSecret: process.env.SITECORE_EDITING_SECRET,
209
+ });
210
+ ```
211
+
212
+ ### Internationalization
213
+
214
+ Multi-language Support:
215
+
216
+ - Configure next-intl for language routing
217
+ - Handle Sitecore language contexts
218
+ - Implement language switching
219
+ - Use proper locale-based data fetching
220
+
221
+ ```typescript
222
+ // Language-aware data fetching
223
+ import { getTranslations } from 'next-intl/server';
224
+
225
+ export default async function LocalizedPage() {
226
+ const t = await getTranslations('common');
227
+ // Fetch Sitecore content for current locale
228
+ }
229
+ ```
230
+
231
+ ## Development Workflow
232
+
233
+ 1. **Install dependencies**: `npm install`
234
+ 2. **Configure environment**: Copy `.env.example` to `.env.local`
235
+ 3. **Start development**: `npm run dev`
236
+ 4. **Build for production**: `npm run build`
237
+
238
+ ## App Router Best Practices
239
+
240
+ ### Server vs Client Components
241
+
242
+ - Use Server Components for Sitecore content rendering (default)
243
+ - Use Client Components for user interactions
244
+ - Minimize client-side JavaScript
245
+ - Leverage server-side data fetching
246
+
247
+ ### Routing and Layouts
248
+
249
+ - Use layout.tsx for shared page structure
250
+ - Implement loading.tsx for loading states
251
+ - Create error.tsx for error boundaries
252
+ - Use page.tsx for route content
253
+ - Use [...path] for Sitecore catch-all routes
254
+
255
+ ### Performance Optimization
256
+
257
+ - Leverage Server Components for better performance
258
+ - Use streaming for improved loading experience
259
+ - Implement proper caching strategies
260
+ - Optimize images with Next.js Image component
261
+
262
+ ## Best Practices
263
+
264
+ ### Performance
265
+
266
+ - Optimize images using Next.js Image component
267
+ - Implement proper loading states
268
+ - Cache expensive operations appropriately
269
+ - Consider server-side rendering implications
270
+ - Lazy-load non-critical modules
271
+ - Use Server Components for better performance
272
+
273
+ ### Security
274
+
275
+ - Sanitize user inputs before processing
276
+ - Validate data at application boundaries
277
+ - Use HTTPS for all Sitecore connections
278
+ - Never expose sensitive configuration in client-side code
279
+ - Escape content when rendering to prevent XSS
280
+
281
+ ### Code Quality
282
+
283
+ - Follow DRY principle - extract common functionality
284
+ - Use SOLID principles for maintainable code
285
+ - Write self-documenting code with clear intent
286
+ - Implement proper error boundaries
287
+ - Test behavior, not implementation details