create-content-sdk-app 2.0.2-canary.9 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/LICENSE.MD +202 -202
  2. package/dist/templates/nextjs/.cursor/rules/general.mdc +81 -81
  3. package/dist/templates/nextjs/.cursor/rules/javascript.mdc +112 -112
  4. package/dist/templates/nextjs/.cursor/rules/project-setup.mdc +100 -100
  5. package/dist/templates/nextjs/.cursor/rules/sitecore.mdc +150 -150
  6. package/dist/templates/nextjs/.env.container.example +27 -27
  7. package/dist/templates/nextjs/.env.remote.example +51 -51
  8. package/dist/templates/nextjs/.gitattributes +11 -11
  9. package/dist/templates/nextjs/.prettierrc +8 -8
  10. package/dist/templates/nextjs/.vscode/extensions.json +8 -8
  11. package/dist/templates/nextjs/.vscode/launch.json +15 -15
  12. package/dist/templates/nextjs/.windsurfrules +186 -186
  13. package/dist/templates/nextjs/LICENSE.txt +202 -202
  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 +40 -40
  18. package/dist/templates/nextjs/src/proxy.ts +3 -11
  19. package/dist/templates/nextjs/tsconfig.json +40 -40
  20. package/dist/templates/nextjs-app-router/.cursor/rules/app-router-setup.mdc +116 -116
  21. package/dist/templates/nextjs-app-router/.cursor/rules/general.mdc +80 -80
  22. package/dist/templates/nextjs-app-router/.cursor/rules/javascript.mdc +112 -112
  23. package/dist/templates/nextjs-app-router/.cursor/rules/sitecore.mdc +174 -174
  24. package/dist/templates/nextjs-app-router/.env.container.example +27 -27
  25. package/dist/templates/nextjs-app-router/.env.remote.example +51 -51
  26. package/dist/templates/nextjs-app-router/.gitattributes +11 -11
  27. package/dist/templates/nextjs-app-router/.windsurfrules +290 -290
  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 +55 -55
  31. package/dist/templates/nextjs-app-router/postcss.config.mjs +5 -5
  32. package/dist/templates/nextjs-app-router/sitecore.config.ts.example +40 -40
  33. package/dist/templates/nextjs-app-router/src/app/globals.css +1 -1
  34. package/dist/templates/nextjs-app-router/src/proxy.ts +3 -11
  35. package/dist/templates/nextjs-app-router/tsconfig.json +48 -48
  36. package/package.json +2 -2
@@ -1,186 +1,186 @@
1
- # Sitecore Content SDK Next.js Project - Windsurf AI Rules
2
-
3
- ## Project Purpose and Tech Stack
4
-
5
- This is a **Sitecore Content SDK** application built with **Next.js** and **TypeScript**. The project follows Sitecore best practices for XM Cloud development and provides a modern, performant web application framework.
6
-
7
- ### Key Technologies
8
-
9
- - **Next.js** - React framework with SSR/SSG capabilities
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** - Component-based UI library
14
-
15
- ## Coding Standards
16
-
17
- ### TypeScript Standards
18
-
19
- - Use **strict mode** in tsconfig.json
20
- - Prefer type assertions over `any`: `value as ContentItem`
21
- - Use discriminated unions for complex state management
22
- - Enable strict null checks and strict function types
23
-
24
- ### Naming Conventions
25
-
26
- - **Variables/Functions**: camelCase (`getUserData()`, `isLoading`, `currentUser`)
27
- - **Components**: PascalCase (`SitecoreComponent`, `PageLayout`, `ContentBlock`)
28
- - **Constants**: UPPER_SNAKE_CASE (`API_ENDPOINT`, `DEFAULT_TIMEOUT`)
29
- - **Directories**: kebab-case (`src/components`, `src/api-clients`)
30
- - **Types/Interfaces**: PascalCase (`ContentItem`, `LayoutProps`, `SitecoreConfig`)
31
-
32
- ### Modular Layout
33
-
34
- ```
35
- src/
36
- components/ # UI components (React)
37
- lib/ # Configuration and utilities
38
- pages/ # Next.js pages
39
- assets/ # Static assets and styles
40
- types/ # TypeScript type definitions
41
- hooks/ # Custom React hooks
42
- ```
43
-
44
- ## Library Usage
45
-
46
- ### @sitecore-content-sdk
47
-
48
- - Use `SitecoreClient` for content fetching
49
- - Implement proper error handling with try/catch blocks
50
- - Cache API responses using React Query or SWR
51
- - Handle content preview vs. published content scenarios
52
-
53
- ```typescript
54
- import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
55
- import scConfig from 'sitecore.config';
56
-
57
- const client = new SitecoreClient({
58
- ...scConfig,
59
- });
60
- ```
61
-
62
- ### React Patterns
63
-
64
- - Use **Server Components** for data fetching and static content
65
- - Use **Client Components** for interactivity (use 'use client')
66
- - Implement proper error boundaries
67
- - Use React.memo for expensive components
68
- - Leverage useCallback and useMemo for performance optimization
69
-
70
- ### Sitecore Field Components
71
-
72
- - Always use Sitecore field components: `<Text>`, `<RichText>`, `<Image>`
73
- - Validate field existence before rendering
74
- - Handle empty/null fields gracefully
75
- - Prefer Sitecore field components over manual rendering
76
-
77
- ```typescript
78
- // Good: Using Sitecore field components
79
- <Text field={fields?.title} tag="h1" />
80
- <RichText field={fields?.content} />
81
- <Image field={fields?.backgroundImage} />
82
-
83
- // Avoid: Manual field value extraction unless necessary
84
- ```
85
-
86
- ## Example Patterns and Prompts
87
-
88
- ### Component Development
89
-
90
- ```typescript
91
- // Component props interface
92
- interface HeroProps {
93
- fields: {
94
- title: Field;
95
- subtitle: Field;
96
- backgroundImage: Field;
97
- };
98
- }
99
-
100
- export default function Hero({ fields }: HeroProps) {
101
- return (
102
- <div>
103
- <Text field={fields?.title} tag="h1" />
104
- <Text field={fields?.subtitle} tag="p" />
105
- <Image field={fields?.backgroundImage} />
106
- </div>
107
- );
108
- }
109
- ```
110
-
111
- ### Error Handling
112
-
113
- ```typescript
114
- async function fetchPageData(path: string): Promise<Page | null> {
115
- if (!path) {
116
- throw new Error('Page path is required');
117
- }
118
-
119
- try {
120
- const pageData = await client.getPage(path);
121
- return pageData;
122
- } catch (error) {
123
- throw new SitecoreFetchError(`Failed to fetch page data for ${path}`, error);
124
- }
125
- }
126
- ```
127
-
128
- ### Configuration
129
-
130
- ```typescript
131
- // sitecore.config.ts
132
- import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
133
-
134
- export default defineConfig({
135
- api: {
136
- edge: {
137
- contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
138
- clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
139
- edgeUrl:
140
- process.env.NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME ||
141
- process.env.SITECORE_EDGE_PLATFORM_HOSTNAME ||
142
- 'https://edge-platform.sitecorecloud.io',
143
- },
144
- local: {
145
- apiKey: process.env.SITECORE_API_KEY || '',
146
- apiHost: process.env.SITECORE_API_HOST || '',
147
- },
148
- },
149
- defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
150
- defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
151
- editingSecret: process.env.SITECORE_EDITING_SECRET,
152
- });
153
- ```
154
-
155
- ## Development Workflow
156
-
157
- 1. **Install dependencies**: `npm install`
158
- 2. **Configure environment**: Copy `.env.example` to `.env.local`
159
- 3. **Start development**: `npm run dev`
160
- 4. **Build for production**: `npm run build`
161
-
162
- ## Best Practices
163
-
164
- ### Performance
165
-
166
- - Optimize images using Next.js Image component
167
- - Implement proper loading states
168
- - Cache expensive operations appropriately
169
- - Consider server-side rendering implications
170
- - Lazy-load non-critical modules
171
-
172
- ### Security
173
-
174
- - Sanitize user inputs before processing
175
- - Validate data at application boundaries
176
- - Use HTTPS for all Sitecore connections
177
- - Never expose sensitive configuration in client-side code
178
- - Escape content when rendering to prevent XSS
179
-
180
- ### Code Quality
181
-
182
- - Follow DRY principle - extract common functionality
183
- - Use SOLID principles for maintainable code
184
- - Write self-documenting code with clear intent
185
- - Implement proper error boundaries
186
- - Test behavior, not implementation details
1
+ # Sitecore Content SDK Next.js Project - Windsurf AI Rules
2
+
3
+ ## Project Purpose and Tech Stack
4
+
5
+ This is a **Sitecore Content SDK** application built with **Next.js** and **TypeScript**. The project follows Sitecore best practices for XM Cloud development and provides a modern, performant web application framework.
6
+
7
+ ### Key Technologies
8
+
9
+ - **Next.js** - React framework with SSR/SSG capabilities
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** - Component-based UI library
14
+
15
+ ## Coding Standards
16
+
17
+ ### TypeScript Standards
18
+
19
+ - Use **strict mode** in tsconfig.json
20
+ - Prefer type assertions over `any`: `value as ContentItem`
21
+ - Use discriminated unions for complex state management
22
+ - Enable strict null checks and strict function types
23
+
24
+ ### Naming Conventions
25
+
26
+ - **Variables/Functions**: camelCase (`getUserData()`, `isLoading`, `currentUser`)
27
+ - **Components**: PascalCase (`SitecoreComponent`, `PageLayout`, `ContentBlock`)
28
+ - **Constants**: UPPER_SNAKE_CASE (`API_ENDPOINT`, `DEFAULT_TIMEOUT`)
29
+ - **Directories**: kebab-case (`src/components`, `src/api-clients`)
30
+ - **Types/Interfaces**: PascalCase (`ContentItem`, `LayoutProps`, `SitecoreConfig`)
31
+
32
+ ### Modular Layout
33
+
34
+ ```
35
+ src/
36
+ components/ # UI components (React)
37
+ lib/ # Configuration and utilities
38
+ pages/ # Next.js pages
39
+ assets/ # Static assets and styles
40
+ types/ # TypeScript type definitions
41
+ hooks/ # Custom React hooks
42
+ ```
43
+
44
+ ## Library Usage
45
+
46
+ ### @sitecore-content-sdk
47
+
48
+ - Use `SitecoreClient` for content fetching
49
+ - Implement proper error handling with try/catch blocks
50
+ - Cache API responses using React Query or SWR
51
+ - Handle content preview vs. published content scenarios
52
+
53
+ ```typescript
54
+ import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
55
+ import scConfig from 'sitecore.config';
56
+
57
+ const client = new SitecoreClient({
58
+ ...scConfig,
59
+ });
60
+ ```
61
+
62
+ ### React Patterns
63
+
64
+ - Use **Server Components** for data fetching and static content
65
+ - Use **Client Components** for interactivity (use 'use client')
66
+ - Implement proper error boundaries
67
+ - Use React.memo for expensive components
68
+ - Leverage useCallback and useMemo for performance optimization
69
+
70
+ ### Sitecore Field Components
71
+
72
+ - Always use Sitecore field components: `<Text>`, `<RichText>`, `<Image>`
73
+ - Validate field existence before rendering
74
+ - Handle empty/null fields gracefully
75
+ - Prefer Sitecore field components over manual rendering
76
+
77
+ ```typescript
78
+ // Good: Using Sitecore field components
79
+ <Text field={fields?.title} tag="h1" />
80
+ <RichText field={fields?.content} />
81
+ <Image field={fields?.backgroundImage} />
82
+
83
+ // Avoid: Manual field value extraction unless necessary
84
+ ```
85
+
86
+ ## Example Patterns and Prompts
87
+
88
+ ### Component Development
89
+
90
+ ```typescript
91
+ // Component props interface
92
+ interface HeroProps {
93
+ fields: {
94
+ title: Field;
95
+ subtitle: Field;
96
+ backgroundImage: Field;
97
+ };
98
+ }
99
+
100
+ export default function Hero({ fields }: HeroProps) {
101
+ return (
102
+ <div>
103
+ <Text field={fields?.title} tag="h1" />
104
+ <Text field={fields?.subtitle} tag="p" />
105
+ <Image field={fields?.backgroundImage} />
106
+ </div>
107
+ );
108
+ }
109
+ ```
110
+
111
+ ### Error Handling
112
+
113
+ ```typescript
114
+ async function fetchPageData(path: string): Promise<Page | null> {
115
+ if (!path) {
116
+ throw new Error('Page path is required');
117
+ }
118
+
119
+ try {
120
+ const pageData = await client.getPage(path);
121
+ return pageData;
122
+ } catch (error) {
123
+ throw new SitecoreFetchError(`Failed to fetch page data for ${path}`, error);
124
+ }
125
+ }
126
+ ```
127
+
128
+ ### Configuration
129
+
130
+ ```typescript
131
+ // sitecore.config.ts
132
+ import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
133
+
134
+ export default defineConfig({
135
+ api: {
136
+ edge: {
137
+ contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
138
+ clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
139
+ edgeUrl:
140
+ process.env.NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME ||
141
+ process.env.SITECORE_EDGE_PLATFORM_HOSTNAME ||
142
+ 'https://edge-platform.sitecorecloud.io',
143
+ },
144
+ local: {
145
+ apiKey: process.env.SITECORE_API_KEY || '',
146
+ apiHost: process.env.SITECORE_API_HOST || '',
147
+ },
148
+ },
149
+ defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
150
+ defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
151
+ editingSecret: process.env.SITECORE_EDITING_SECRET,
152
+ });
153
+ ```
154
+
155
+ ## Development Workflow
156
+
157
+ 1. **Install dependencies**: `npm install`
158
+ 2. **Configure environment**: Copy `.env.example` to `.env.local`
159
+ 3. **Start development**: `npm run dev`
160
+ 4. **Build for production**: `npm run build`
161
+
162
+ ## Best Practices
163
+
164
+ ### Performance
165
+
166
+ - Optimize images using Next.js Image component
167
+ - Implement proper loading states
168
+ - Cache expensive operations appropriately
169
+ - Consider server-side rendering implications
170
+ - Lazy-load non-critical modules
171
+
172
+ ### Security
173
+
174
+ - Sanitize user inputs before processing
175
+ - Validate data at application boundaries
176
+ - Use HTTPS for all Sitecore connections
177
+ - Never expose sensitive configuration in client-side code
178
+ - Escape content when rendering to prevent XSS
179
+
180
+ ### Code Quality
181
+
182
+ - Follow DRY principle - extract common functionality
183
+ - Use SOLID principles for maintainable code
184
+ - Write self-documenting code with clear intent
185
+ - Implement proper error boundaries
186
+ - Test behavior, not implementation details