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,183 +1,183 @@
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: process.env.SITECORE_EDGE_URL || 'https://edge-platform.sitecorecloud.io',
140
- },
141
- local: {
142
- apiKey: process.env.SITECORE_API_KEY || '',
143
- apiHost: process.env.SITECORE_API_HOST || '',
144
- },
145
- },
146
- defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
147
- defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
148
- editingSecret: process.env.SITECORE_EDITING_SECRET,
149
- });
150
- ```
151
-
152
- ## Development Workflow
153
-
154
- 1. **Install dependencies**: `npm install`
155
- 2. **Configure environment**: Copy `.env.example` to `.env.local`
156
- 3. **Start development**: `npm run dev`
157
- 4. **Build for production**: `npm run build`
158
-
159
- ## Best Practices
160
-
161
- ### Performance
162
-
163
- - Optimize images using Next.js Image component
164
- - Implement proper loading states
165
- - Cache expensive operations appropriately
166
- - Consider server-side rendering implications
167
- - Lazy-load non-critical modules
168
-
169
- ### Security
170
-
171
- - Sanitize user inputs before processing
172
- - Validate data at application boundaries
173
- - Use HTTPS for all Sitecore connections
174
- - Never expose sensitive configuration in client-side code
175
- - Escape content when rendering to prevent XSS
176
-
177
- ### Code Quality
178
-
179
- - Follow DRY principle - extract common functionality
180
- - Use SOLID principles for maintainable code
181
- - Write self-documenting code with clear intent
182
- - Implement proper error boundaries
183
- - 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: process.env.SITECORE_EDGE_URL || 'https://edge-platform.sitecorecloud.io',
140
+ },
141
+ local: {
142
+ apiKey: process.env.SITECORE_API_KEY || '',
143
+ apiHost: process.env.SITECORE_API_HOST || '',
144
+ },
145
+ },
146
+ defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
147
+ defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
148
+ editingSecret: process.env.SITECORE_EDITING_SECRET,
149
+ });
150
+ ```
151
+
152
+ ## Development Workflow
153
+
154
+ 1. **Install dependencies**: `npm install`
155
+ 2. **Configure environment**: Copy `.env.example` to `.env.local`
156
+ 3. **Start development**: `npm run dev`
157
+ 4. **Build for production**: `npm run build`
158
+
159
+ ## Best Practices
160
+
161
+ ### Performance
162
+
163
+ - Optimize images using Next.js Image component
164
+ - Implement proper loading states
165
+ - Cache expensive operations appropriately
166
+ - Consider server-side rendering implications
167
+ - Lazy-load non-critical modules
168
+
169
+ ### Security
170
+
171
+ - Sanitize user inputs before processing
172
+ - Validate data at application boundaries
173
+ - Use HTTPS for all Sitecore connections
174
+ - Never expose sensitive configuration in client-side code
175
+ - Escape content when rendering to prevent XSS
176
+
177
+ ### Code Quality
178
+
179
+ - Follow DRY principle - extract common functionality
180
+ - Use SOLID principles for maintainable code
181
+ - Write self-documenting code with clear intent
182
+ - Implement proper error boundaries
183
+ - Test behavior, not implementation details