create-content-sdk-app 2.0.0-canary.8 → 2.0.0
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/LICENSE.MD +202 -202
- package/dist/initializers/angular/args.js +2 -0
- package/dist/initializers/angular/index.js +30 -0
- package/dist/initializers/angular/prompts.js +20 -0
- package/dist/templates/angular/.postcssrc.json +5 -0
- package/dist/templates/angular/.vscode/extensions.json +4 -0
- package/dist/templates/angular/README.md +3 -0
- package/dist/templates/angular/angular.json +79 -0
- package/dist/templates/angular/package.json +58 -0
- package/dist/templates/angular/public/favicon.ico +0 -0
- package/dist/templates/angular/src/app/app.config.server.ts +12 -0
- package/dist/templates/angular/src/app/app.config.ts +31 -0
- package/dist/templates/angular/src/app/app.css +0 -0
- package/dist/templates/angular/src/app/app.html +1 -0
- package/dist/templates/angular/src/app/app.routes.server.ts +15 -0
- package/dist/templates/angular/src/app/app.routes.ts +28 -0
- package/dist/templates/angular/src/app/app.ts +12 -0
- package/dist/templates/angular/src/app/loaders/error.loader.ts +12 -0
- package/dist/templates/angular/src/app/loaders/index.ts +14 -0
- package/dist/templates/angular/src/app/loaders/not-found.loader.ts +12 -0
- package/dist/templates/angular/src/app/loaders/page.loader.ts +15 -0
- package/dist/templates/angular/src/app/loaders/stub-utils.ts +83 -0
- package/dist/templates/angular/src/app/pages/error.component.ts +124 -0
- package/dist/templates/angular/src/app/pages/not-found.component.ts +85 -0
- package/dist/templates/angular/src/app/pages/page.component.ts +58 -0
- package/dist/templates/angular/src/app/shared/layout.component.ts +106 -0
- package/dist/templates/angular/src/index.html +13 -0
- package/dist/templates/angular/src/main.server.ts +8 -0
- package/dist/templates/angular/src/main.ts +6 -0
- package/dist/templates/angular/src/server.ts +65 -0
- package/dist/templates/angular/src/styles.css +3 -0
- package/dist/templates/angular/tsconfig.json +38 -0
- package/dist/templates/angular/tsconfig.spec.json +10 -0
- package/dist/templates/nextjs/.cursor/rules/general.mdc +81 -81
- package/dist/templates/nextjs/.cursor/rules/javascript.mdc +112 -112
- package/dist/templates/nextjs/.cursor/rules/project-setup.mdc +100 -100
- package/dist/templates/nextjs/.cursor/rules/sitecore.mdc +150 -150
- package/dist/templates/nextjs/.env.container.example +27 -27
- package/dist/templates/nextjs/.env.remote.example +51 -51
- package/dist/templates/nextjs/.gitattributes +11 -11
- package/dist/templates/nextjs/.prettierrc +8 -8
- package/dist/templates/nextjs/.vscode/extensions.json +8 -8
- package/dist/templates/nextjs/.vscode/launch.json +15 -15
- package/dist/templates/nextjs/.windsurfrules +186 -186
- package/dist/templates/nextjs/LICENSE.txt +202 -202
- package/dist/templates/nextjs/LLMs.txt +179 -179
- package/dist/templates/nextjs/eslint.config.mjs +81 -81
- package/dist/templates/nextjs/gitignore +28 -28
- package/dist/templates/nextjs/package.json +68 -68
- package/dist/templates/nextjs/sitecore.config.ts.example +40 -40
- package/dist/templates/nextjs/tsconfig.json +40 -40
- package/dist/templates/nextjs-app-router/.cursor/rules/app-router-setup.mdc +116 -116
- package/dist/templates/nextjs-app-router/.cursor/rules/general.mdc +80 -80
- package/dist/templates/nextjs-app-router/.cursor/rules/javascript.mdc +112 -112
- package/dist/templates/nextjs-app-router/.cursor/rules/sitecore.mdc +174 -174
- package/dist/templates/nextjs-app-router/.env.container.example +27 -27
- package/dist/templates/nextjs-app-router/.env.remote.example +51 -51
- package/dist/templates/nextjs-app-router/.gitattributes +11 -11
- package/dist/templates/nextjs-app-router/.windsurfrules +290 -290
- package/dist/templates/nextjs-app-router/LLMs.txt +236 -236
- package/dist/templates/nextjs-app-router/eslint.config.mjs +29 -29
- package/dist/templates/nextjs-app-router/gitignore +31 -31
- package/dist/templates/nextjs-app-router/package.json +54 -54
- package/dist/templates/nextjs-app-router/postcss.config.mjs +5 -5
- package/dist/templates/nextjs-app-router/sitecore.config.ts.example +40 -40
- package/dist/templates/nextjs-app-router/src/app/globals.css +1 -1
- package/dist/templates/nextjs-app-router/tsconfig.json +48 -48
- package/package.json +2 -2
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Getting started with your Sitecore Content SDK Next.js project
|
|
3
|
-
alwaysApply: true
|
|
4
|
-
globs: []
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Sitecore Content SDK Next.js Project
|
|
8
|
-
|
|
9
|
-
## Project Overview
|
|
10
|
-
|
|
11
|
-
This is a Sitecore Content SDK application built with Next.js. The project structure follows Sitecore best practices for XM Cloud development.
|
|
12
|
-
|
|
13
|
-
Key Technologies:
|
|
14
|
-
|
|
15
|
-
- Next.js (React framework)
|
|
16
|
-
- Sitecore Content SDK
|
|
17
|
-
- TypeScript
|
|
18
|
-
- Sitecore XM Cloud
|
|
19
|
-
|
|
20
|
-
## Getting Started
|
|
21
|
-
|
|
22
|
-
Development Workflow:
|
|
23
|
-
|
|
24
|
-
1. Install dependencies: `npm install`
|
|
25
|
-
2. Configure environment variables (copy `.env.example` to `.env.local`)
|
|
26
|
-
3. Start development server: `npm run dev`
|
|
27
|
-
4. Build for production: `npm run build`
|
|
28
|
-
|
|
29
|
-
Environment Configuration:
|
|
30
|
-
|
|
31
|
-
- Copy `.env.example` to `.env.local`
|
|
32
|
-
- Add your Sitecore API endpoint and key
|
|
33
|
-
- Configure site name and other settings
|
|
34
|
-
|
|
35
|
-
## Sitecore Integration
|
|
36
|
-
|
|
37
|
-
Configuration:
|
|
38
|
-
|
|
39
|
-
- Configure Sitecore connection in `sitecore.config.ts`
|
|
40
|
-
- Register components in the component map
|
|
41
|
-
- Use Sitecore field components for content rendering
|
|
42
|
-
- Follow Sitecore's layout service patterns
|
|
43
|
-
|
|
44
|
-
Component Development:
|
|
45
|
-
|
|
46
|
-
- Create components in `src/components/`
|
|
47
|
-
- Export from component files for registration
|
|
48
|
-
- Use TypeScript interfaces for component props
|
|
49
|
-
- Follow Sitecore field handling patterns
|
|
50
|
-
|
|
51
|
-
## Project Structure
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
src/
|
|
55
|
-
components/ # React-specific SDK
|
|
56
|
-
lib/ # Configuration and utilities
|
|
57
|
-
pages/ # Next.js pages
|
|
58
|
-
assets/ # Static assets and styles
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Best Practices
|
|
62
|
-
|
|
63
|
-
Sitecore Components:
|
|
64
|
-
|
|
65
|
-
- Use descriptive component names
|
|
66
|
-
- Handle field validation gracefully
|
|
67
|
-
- Implement proper error boundaries
|
|
68
|
-
- Cache content when appropriate
|
|
69
|
-
|
|
70
|
-
Performance:
|
|
71
|
-
|
|
72
|
-
- Optimize images using Next.js Image component
|
|
73
|
-
- Implement proper loading states
|
|
74
|
-
- Use React.memo for expensive components
|
|
75
|
-
- Consider server-side rendering implications
|
|
76
|
-
|
|
77
|
-
## Development Commands
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
npm run dev # Start development server
|
|
81
|
-
npm run build # Build for production
|
|
82
|
-
npm run start # Start production server
|
|
83
|
-
npm run lint # Run ESLint
|
|
84
|
-
npm run type-check # Run TypeScript compiler
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Next Steps
|
|
88
|
-
|
|
89
|
-
1. Configure your Sitecore connection
|
|
90
|
-
2. Create your first component
|
|
91
|
-
3. Add content types and templates
|
|
92
|
-
4. Set up your development workflow
|
|
93
|
-
5. Deploy to your hosting platform
|
|
94
|
-
|
|
95
|
-
Referenced:
|
|
96
|
-
@src/components/
|
|
97
|
-
@sitecore.config.ts
|
|
98
|
-
@package.json
|
|
99
|
-
@.env.example
|
|
100
|
-
|
|
1
|
+
---
|
|
2
|
+
description: Getting started with your Sitecore Content SDK Next.js project
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
globs: []
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Sitecore Content SDK Next.js Project
|
|
8
|
+
|
|
9
|
+
## Project Overview
|
|
10
|
+
|
|
11
|
+
This is a Sitecore Content SDK application built with Next.js. The project structure follows Sitecore best practices for XM Cloud development.
|
|
12
|
+
|
|
13
|
+
Key Technologies:
|
|
14
|
+
|
|
15
|
+
- Next.js (React framework)
|
|
16
|
+
- Sitecore Content SDK
|
|
17
|
+
- TypeScript
|
|
18
|
+
- Sitecore XM Cloud
|
|
19
|
+
|
|
20
|
+
## Getting Started
|
|
21
|
+
|
|
22
|
+
Development Workflow:
|
|
23
|
+
|
|
24
|
+
1. Install dependencies: `npm install`
|
|
25
|
+
2. Configure environment variables (copy `.env.example` to `.env.local`)
|
|
26
|
+
3. Start development server: `npm run dev`
|
|
27
|
+
4. Build for production: `npm run build`
|
|
28
|
+
|
|
29
|
+
Environment Configuration:
|
|
30
|
+
|
|
31
|
+
- Copy `.env.example` to `.env.local`
|
|
32
|
+
- Add your Sitecore API endpoint and key
|
|
33
|
+
- Configure site name and other settings
|
|
34
|
+
|
|
35
|
+
## Sitecore Integration
|
|
36
|
+
|
|
37
|
+
Configuration:
|
|
38
|
+
|
|
39
|
+
- Configure Sitecore connection in `sitecore.config.ts`
|
|
40
|
+
- Register components in the component map
|
|
41
|
+
- Use Sitecore field components for content rendering
|
|
42
|
+
- Follow Sitecore's layout service patterns
|
|
43
|
+
|
|
44
|
+
Component Development:
|
|
45
|
+
|
|
46
|
+
- Create components in `src/components/`
|
|
47
|
+
- Export from component files for registration
|
|
48
|
+
- Use TypeScript interfaces for component props
|
|
49
|
+
- Follow Sitecore field handling patterns
|
|
50
|
+
|
|
51
|
+
## Project Structure
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
src/
|
|
55
|
+
components/ # React-specific SDK
|
|
56
|
+
lib/ # Configuration and utilities
|
|
57
|
+
pages/ # Next.js pages
|
|
58
|
+
assets/ # Static assets and styles
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Best Practices
|
|
62
|
+
|
|
63
|
+
Sitecore Components:
|
|
64
|
+
|
|
65
|
+
- Use descriptive component names
|
|
66
|
+
- Handle field validation gracefully
|
|
67
|
+
- Implement proper error boundaries
|
|
68
|
+
- Cache content when appropriate
|
|
69
|
+
|
|
70
|
+
Performance:
|
|
71
|
+
|
|
72
|
+
- Optimize images using Next.js Image component
|
|
73
|
+
- Implement proper loading states
|
|
74
|
+
- Use React.memo for expensive components
|
|
75
|
+
- Consider server-side rendering implications
|
|
76
|
+
|
|
77
|
+
## Development Commands
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm run dev # Start development server
|
|
81
|
+
npm run build # Build for production
|
|
82
|
+
npm run start # Start production server
|
|
83
|
+
npm run lint # Run ESLint
|
|
84
|
+
npm run type-check # Run TypeScript compiler
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Next Steps
|
|
88
|
+
|
|
89
|
+
1. Configure your Sitecore connection
|
|
90
|
+
2. Create your first component
|
|
91
|
+
3. Add content types and templates
|
|
92
|
+
4. Set up your development workflow
|
|
93
|
+
5. Deploy to your hosting platform
|
|
94
|
+
|
|
95
|
+
Referenced:
|
|
96
|
+
@src/components/
|
|
97
|
+
@sitecore.config.ts
|
|
98
|
+
@package.json
|
|
99
|
+
@.env.example
|
|
100
|
+
|
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Sitecore development patterns for your project
|
|
3
|
-
alwaysApply: false
|
|
4
|
-
globs:
|
|
5
|
-
- 'src/components/**'
|
|
6
|
-
- 'src/lib/**'
|
|
7
|
-
- 'sitecore.config.ts'
|
|
8
|
-
- '**/*sitecore*'
|
|
9
|
-
- '**/*content*'
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# Sitecore Development Patterns
|
|
13
|
-
|
|
14
|
-
## Component Development
|
|
15
|
-
|
|
16
|
-
Sitecore Component Naming:
|
|
17
|
-
|
|
18
|
-
- Use descriptive, feature-based names: `HeroWithContent`, `ProductListing`, `ContentBlockGrid`
|
|
19
|
-
- Follow PascalCase convention
|
|
20
|
-
- Include component type in name when helpful: `LayoutContainer`, `ContentRenderer`
|
|
21
|
-
|
|
22
|
-
Component Registration:
|
|
23
|
-
|
|
24
|
-
- Export component from component file
|
|
25
|
-
- Use descriptive, PascalCase names
|
|
26
|
-
- Include TypeScript interfaces for props
|
|
27
|
-
- Handle missing fields gracefully
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
// Component props interface
|
|
31
|
-
interface HeroProps {
|
|
32
|
-
fields: {
|
|
33
|
-
title: Field;
|
|
34
|
-
subtitle: Field;
|
|
35
|
-
backgroundImage: Field;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default function Hero({ fields }: HeroProps) {
|
|
40
|
-
return (
|
|
41
|
-
<div>
|
|
42
|
-
<Text field={fields?.title} tag="h1" />
|
|
43
|
-
<Text field={fields?.subtitle} tag="p" />
|
|
44
|
-
<Image field={fields?.backgroundImage} />
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Content Management
|
|
51
|
-
|
|
52
|
-
Field Handling:
|
|
53
|
-
|
|
54
|
-
- Always validate field existence before rendering
|
|
55
|
-
- Use helper functions for common field operations
|
|
56
|
-
- Handle empty/null fields gracefully
|
|
57
|
-
- Prefer Sitecore field components over manual rendering
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
// Good: Using Sitecore field components
|
|
61
|
-
<Text field={fields?.title} tag="h1" />
|
|
62
|
-
<RichText field={fields?.content} />
|
|
63
|
-
|
|
64
|
-
// Avoid: Manual field value extraction unless necessary
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Layout Service:
|
|
68
|
-
|
|
69
|
-
- Use the Layout Service for page data fetching
|
|
70
|
-
- Implement proper error boundaries for layout rendering
|
|
71
|
-
- Handle missing placeholder content gracefully
|
|
72
|
-
- Cache layout data when appropriate
|
|
73
|
-
|
|
74
|
-
## Configuration
|
|
75
|
-
|
|
76
|
-
Environment Setup:
|
|
77
|
-
|
|
78
|
-
- Use `.env.local` for local development
|
|
79
|
-
- Never commit API keys to version control
|
|
80
|
-
- Use `.env.example` to document required variables
|
|
81
|
-
- Configure Sitecore endpoints in `sitecore.config.ts`
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
// sitecore.config.ts
|
|
85
|
-
import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
|
|
86
|
-
|
|
87
|
-
export default defineConfig({
|
|
88
|
-
api: {
|
|
89
|
-
edge: {
|
|
90
|
-
contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
|
|
91
|
-
clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
|
|
92
|
-
edgeUrl:
|
|
93
|
-
process.env.NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME ||
|
|
94
|
-
process.env.SITECORE_EDGE_PLATFORM_HOSTNAME ||
|
|
95
|
-
'https://edge-platform.sitecorecloud.io',
|
|
96
|
-
},
|
|
97
|
-
local: {
|
|
98
|
-
apiKey: process.env.SITECORE_API_KEY || '',
|
|
99
|
-
apiHost: process.env.SITECORE_API_HOST || '',
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
|
|
103
|
-
defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
|
|
104
|
-
editingSecret: process.env.SITECORE_EDITING_SECRET,
|
|
105
|
-
});
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## Security and Performance
|
|
109
|
-
|
|
110
|
-
Security Best Practices:
|
|
111
|
-
|
|
112
|
-
- Sanitize user inputs before processing
|
|
113
|
-
- Validate content from Sitecore before rendering
|
|
114
|
-
- Use HTTPS for all Sitecore connections
|
|
115
|
-
- Never expose sensitive configuration in client-side code
|
|
116
|
-
|
|
117
|
-
Content Fetching:
|
|
118
|
-
|
|
119
|
-
- Implement caching strategy for content (React Query recommended)
|
|
120
|
-
- Use GraphQL queries efficiently (avoid over-fetching)
|
|
121
|
-
- Implement proper loading states and error handling
|
|
122
|
-
- Consider content preview vs. published content scenarios
|
|
123
|
-
|
|
124
|
-
## Development Patterns
|
|
125
|
-
|
|
126
|
-
Error Handling:
|
|
127
|
-
|
|
128
|
-
- Create custom error classes: `SitecoreFetchError`, `ComponentRenderError`
|
|
129
|
-
- Log errors appropriately for debugging
|
|
130
|
-
- Provide fallback content when components fail to render
|
|
131
|
-
- Use error boundaries in React applications
|
|
132
|
-
|
|
133
|
-
Placeholder Management:
|
|
134
|
-
|
|
135
|
-
- Use strongly-typed placeholder names
|
|
136
|
-
- Handle dynamic placeholders appropriately
|
|
137
|
-
- Implement fallback rendering for missing placeholders
|
|
138
|
-
- Follow Sitecore's placeholder naming conventions
|
|
139
|
-
|
|
140
|
-
Testing:
|
|
141
|
-
|
|
142
|
-
- Mock Sitecore services in unit tests
|
|
143
|
-
- Test component rendering with various field configurations
|
|
144
|
-
- Include tests for error scenarios (missing fields, API failures)
|
|
145
|
-
- Use Sitecore's test data helpers when available
|
|
146
|
-
|
|
147
|
-
Referenced:
|
|
148
|
-
@src/components/
|
|
149
|
-
@sitecore.config.ts
|
|
150
|
-
@.env.example
|
|
1
|
+
---
|
|
2
|
+
description: Sitecore development patterns for your project
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
globs:
|
|
5
|
+
- 'src/components/**'
|
|
6
|
+
- 'src/lib/**'
|
|
7
|
+
- 'sitecore.config.ts'
|
|
8
|
+
- '**/*sitecore*'
|
|
9
|
+
- '**/*content*'
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Sitecore Development Patterns
|
|
13
|
+
|
|
14
|
+
## Component Development
|
|
15
|
+
|
|
16
|
+
Sitecore Component Naming:
|
|
17
|
+
|
|
18
|
+
- Use descriptive, feature-based names: `HeroWithContent`, `ProductListing`, `ContentBlockGrid`
|
|
19
|
+
- Follow PascalCase convention
|
|
20
|
+
- Include component type in name when helpful: `LayoutContainer`, `ContentRenderer`
|
|
21
|
+
|
|
22
|
+
Component Registration:
|
|
23
|
+
|
|
24
|
+
- Export component from component file
|
|
25
|
+
- Use descriptive, PascalCase names
|
|
26
|
+
- Include TypeScript interfaces for props
|
|
27
|
+
- Handle missing fields gracefully
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// Component props interface
|
|
31
|
+
interface HeroProps {
|
|
32
|
+
fields: {
|
|
33
|
+
title: Field;
|
|
34
|
+
subtitle: Field;
|
|
35
|
+
backgroundImage: Field;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default function Hero({ fields }: HeroProps) {
|
|
40
|
+
return (
|
|
41
|
+
<div>
|
|
42
|
+
<Text field={fields?.title} tag="h1" />
|
|
43
|
+
<Text field={fields?.subtitle} tag="p" />
|
|
44
|
+
<Image field={fields?.backgroundImage} />
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Content Management
|
|
51
|
+
|
|
52
|
+
Field Handling:
|
|
53
|
+
|
|
54
|
+
- Always validate field existence before rendering
|
|
55
|
+
- Use helper functions for common field operations
|
|
56
|
+
- Handle empty/null fields gracefully
|
|
57
|
+
- Prefer Sitecore field components over manual rendering
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// Good: Using Sitecore field components
|
|
61
|
+
<Text field={fields?.title} tag="h1" />
|
|
62
|
+
<RichText field={fields?.content} />
|
|
63
|
+
|
|
64
|
+
// Avoid: Manual field value extraction unless necessary
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Layout Service:
|
|
68
|
+
|
|
69
|
+
- Use the Layout Service for page data fetching
|
|
70
|
+
- Implement proper error boundaries for layout rendering
|
|
71
|
+
- Handle missing placeholder content gracefully
|
|
72
|
+
- Cache layout data when appropriate
|
|
73
|
+
|
|
74
|
+
## Configuration
|
|
75
|
+
|
|
76
|
+
Environment Setup:
|
|
77
|
+
|
|
78
|
+
- Use `.env.local` for local development
|
|
79
|
+
- Never commit API keys to version control
|
|
80
|
+
- Use `.env.example` to document required variables
|
|
81
|
+
- Configure Sitecore endpoints in `sitecore.config.ts`
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// sitecore.config.ts
|
|
85
|
+
import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
|
|
86
|
+
|
|
87
|
+
export default defineConfig({
|
|
88
|
+
api: {
|
|
89
|
+
edge: {
|
|
90
|
+
contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
|
|
91
|
+
clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
|
|
92
|
+
edgeUrl:
|
|
93
|
+
process.env.NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME ||
|
|
94
|
+
process.env.SITECORE_EDGE_PLATFORM_HOSTNAME ||
|
|
95
|
+
'https://edge-platform.sitecorecloud.io',
|
|
96
|
+
},
|
|
97
|
+
local: {
|
|
98
|
+
apiKey: process.env.SITECORE_API_KEY || '',
|
|
99
|
+
apiHost: process.env.SITECORE_API_HOST || '',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
|
|
103
|
+
defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
|
|
104
|
+
editingSecret: process.env.SITECORE_EDITING_SECRET,
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Security and Performance
|
|
109
|
+
|
|
110
|
+
Security Best Practices:
|
|
111
|
+
|
|
112
|
+
- Sanitize user inputs before processing
|
|
113
|
+
- Validate content from Sitecore before rendering
|
|
114
|
+
- Use HTTPS for all Sitecore connections
|
|
115
|
+
- Never expose sensitive configuration in client-side code
|
|
116
|
+
|
|
117
|
+
Content Fetching:
|
|
118
|
+
|
|
119
|
+
- Implement caching strategy for content (React Query recommended)
|
|
120
|
+
- Use GraphQL queries efficiently (avoid over-fetching)
|
|
121
|
+
- Implement proper loading states and error handling
|
|
122
|
+
- Consider content preview vs. published content scenarios
|
|
123
|
+
|
|
124
|
+
## Development Patterns
|
|
125
|
+
|
|
126
|
+
Error Handling:
|
|
127
|
+
|
|
128
|
+
- Create custom error classes: `SitecoreFetchError`, `ComponentRenderError`
|
|
129
|
+
- Log errors appropriately for debugging
|
|
130
|
+
- Provide fallback content when components fail to render
|
|
131
|
+
- Use error boundaries in React applications
|
|
132
|
+
|
|
133
|
+
Placeholder Management:
|
|
134
|
+
|
|
135
|
+
- Use strongly-typed placeholder names
|
|
136
|
+
- Handle dynamic placeholders appropriately
|
|
137
|
+
- Implement fallback rendering for missing placeholders
|
|
138
|
+
- Follow Sitecore's placeholder naming conventions
|
|
139
|
+
|
|
140
|
+
Testing:
|
|
141
|
+
|
|
142
|
+
- Mock Sitecore services in unit tests
|
|
143
|
+
- Test component rendering with various field configurations
|
|
144
|
+
- Include tests for error scenarios (missing fields, API failures)
|
|
145
|
+
- Use Sitecore's test data helpers when available
|
|
146
|
+
|
|
147
|
+
Referenced:
|
|
148
|
+
@src/components/
|
|
149
|
+
@sitecore.config.ts
|
|
150
|
+
@.env.example
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
# This file should be copied to .env.local and modified with your environment variables to connect to your Sitecore container instance.
|
|
2
|
-
|
|
3
|
-
# To secure the Sitecore editor endpoint exposed by your Next.js app
|
|
4
|
-
# (`/api/editing/render` by default), a secret token is used. This (client-side)
|
|
5
|
-
SITECORE_EDITING_SECRET=
|
|
6
|
-
|
|
7
|
-
# Your Sitecore site name.
|
|
8
|
-
# The value of the variable represents the default/configured site.
|
|
9
|
-
NEXT_PUBLIC_DEFAULT_SITE_NAME=
|
|
10
|
-
|
|
11
|
-
# Your default app language.
|
|
12
|
-
NEXT_PUBLIC_DEFAULT_LANGUAGE=
|
|
13
|
-
|
|
14
|
-
# Your Sitecore API key is needed to build the app.
|
|
15
|
-
NEXT_PUBLIC_SITECORE_API_KEY=
|
|
16
|
-
|
|
17
|
-
# Your Sitecore API hostname is needed to build the app.
|
|
18
|
-
NEXT_PUBLIC_SITECORE_API_HOST=
|
|
19
|
-
|
|
20
|
-
# Sitecore Content SDK npm packages utilize the debug module for debug logging.
|
|
21
|
-
# https://www.npmjs.com/package/debug
|
|
22
|
-
# Set the DEBUG environment variable to 'content-sdk:*' to see all logs:
|
|
23
|
-
#DEBUG=content-sdk:*
|
|
24
|
-
# Or be selective and show for example only layout service logs:
|
|
25
|
-
#DEBUG=content-sdk:layout
|
|
26
|
-
# Or everything BUT layout service logs:
|
|
27
|
-
#DEBUG=content-sdk:*,-content-sdk:layout
|
|
1
|
+
# This file should be copied to .env.local and modified with your environment variables to connect to your Sitecore container instance.
|
|
2
|
+
|
|
3
|
+
# To secure the Sitecore editor endpoint exposed by your Next.js app
|
|
4
|
+
# (`/api/editing/render` by default), a secret token is used. This (client-side)
|
|
5
|
+
SITECORE_EDITING_SECRET=
|
|
6
|
+
|
|
7
|
+
# Your Sitecore site name.
|
|
8
|
+
# The value of the variable represents the default/configured site.
|
|
9
|
+
NEXT_PUBLIC_DEFAULT_SITE_NAME=
|
|
10
|
+
|
|
11
|
+
# Your default app language.
|
|
12
|
+
NEXT_PUBLIC_DEFAULT_LANGUAGE=
|
|
13
|
+
|
|
14
|
+
# Your Sitecore API key is needed to build the app.
|
|
15
|
+
NEXT_PUBLIC_SITECORE_API_KEY=
|
|
16
|
+
|
|
17
|
+
# Your Sitecore API hostname is needed to build the app.
|
|
18
|
+
NEXT_PUBLIC_SITECORE_API_HOST=
|
|
19
|
+
|
|
20
|
+
# Sitecore Content SDK npm packages utilize the debug module for debug logging.
|
|
21
|
+
# https://www.npmjs.com/package/debug
|
|
22
|
+
# Set the DEBUG environment variable to 'content-sdk:*' to see all logs:
|
|
23
|
+
#DEBUG=content-sdk:*
|
|
24
|
+
# Or be selective and show for example only layout service logs:
|
|
25
|
+
#DEBUG=content-sdk:layout
|
|
26
|
+
# Or everything BUT layout service logs:
|
|
27
|
+
#DEBUG=content-sdk:*,-content-sdk:layout
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
# This file should be copied to .env.local and modified with your environment variables to connect to your remote Sitecore instance.
|
|
2
|
-
|
|
3
|
-
# To secure the Sitecore editor endpoint exposed by your Next.js app
|
|
4
|
-
# (`/api/editing/render` by default), a secret token is used. This (client-side)
|
|
5
|
-
SITECORE_EDITING_SECRET=
|
|
6
|
-
|
|
7
|
-
# Your Sitecore site name.
|
|
8
|
-
# The value of the variable represents the default/configured site.
|
|
9
|
-
NEXT_PUBLIC_DEFAULT_SITE_NAME=
|
|
10
|
-
|
|
11
|
-
# Your default app language.
|
|
12
|
-
NEXT_PUBLIC_DEFAULT_LANGUAGE=
|
|
13
|
-
|
|
14
|
-
# Your unified Sitecore Edge Context Id for server-side use.
|
|
15
|
-
# This will be used over any Sitecore Preview / Delivery Edge variables (above).
|
|
16
|
-
SITECORE_EDGE_CONTEXT_ID=
|
|
17
|
-
|
|
18
|
-
# Your Sitecore Edge Context Id for client-side use.
|
|
19
|
-
# Will be used as a fallback if separate SITECORE_EDGE_CONTEXT_ID value is not provided
|
|
20
|
-
NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID=
|
|
21
|
-
|
|
22
|
-
# Optional: custom Sitecore Edge Platform hostname (hostname or full URL).
|
|
23
|
-
NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME=
|
|
24
|
-
|
|
25
|
-
# Optional: custom Experience Edge hostname for media URL rewriting (e.g. staging).
|
|
26
|
-
SITECORE_EXPERIENCE_EDGE_HOSTNAME=
|
|
27
|
-
|
|
28
|
-
# An optional Sitecore Personalize scope identifier.
|
|
29
|
-
# This can be used to isolate personalization data when multiple XM Cloud Environments share a Personalize tenant.
|
|
30
|
-
# This should match the PAGES_PERSONALIZE_SCOPE environment variable for your connected XM Cloud Environment.
|
|
31
|
-
NEXT_PUBLIC_PERSONALIZE_SCOPE=
|
|
32
|
-
|
|
33
|
-
# Timeout (ms) for Sitecore CDP requests to respond within. Default is 400.
|
|
34
|
-
PERSONALIZE_MIDDLEWARE_CDP_TIMEOUT=
|
|
35
|
-
|
|
36
|
-
# Timeout (ms) for Sitecore Experience Edge requests to respond within. Default is 400.
|
|
37
|
-
PERSONALIZE_MIDDLEWARE_EDGE_TIMEOUT=
|
|
38
|
-
|
|
39
|
-
# Sitecore Content SDK npm packages utilize the debug module for debug logging.
|
|
40
|
-
# https://www.npmjs.com/package/debug
|
|
41
|
-
# Set the DEBUG environment variable to 'content-sdk:*' to see all logs:
|
|
42
|
-
#DEBUG=content-sdk:*
|
|
43
|
-
# Or be selective and show for example only layout service logs:
|
|
44
|
-
#DEBUG=content-sdk:layout
|
|
45
|
-
# Or everything BUT layout service logs:
|
|
46
|
-
#DEBUG=content-sdk:*,-content-sdk:layout
|
|
47
|
-
|
|
48
|
-
# Client ID, Secret and Rendering Host Name used for Design Library functionality
|
|
49
|
-
SITECORE_AUTH_CLIENT_ID=
|
|
50
|
-
SITECORE_AUTH_CLIENT_SECRET=
|
|
51
|
-
SITECORE_RENDERINGHOST_NAME=
|
|
1
|
+
# This file should be copied to .env.local and modified with your environment variables to connect to your remote Sitecore instance.
|
|
2
|
+
|
|
3
|
+
# To secure the Sitecore editor endpoint exposed by your Next.js app
|
|
4
|
+
# (`/api/editing/render` by default), a secret token is used. This (client-side)
|
|
5
|
+
SITECORE_EDITING_SECRET=
|
|
6
|
+
|
|
7
|
+
# Your Sitecore site name.
|
|
8
|
+
# The value of the variable represents the default/configured site.
|
|
9
|
+
NEXT_PUBLIC_DEFAULT_SITE_NAME=
|
|
10
|
+
|
|
11
|
+
# Your default app language.
|
|
12
|
+
NEXT_PUBLIC_DEFAULT_LANGUAGE=
|
|
13
|
+
|
|
14
|
+
# Your unified Sitecore Edge Context Id for server-side use.
|
|
15
|
+
# This will be used over any Sitecore Preview / Delivery Edge variables (above).
|
|
16
|
+
SITECORE_EDGE_CONTEXT_ID=
|
|
17
|
+
|
|
18
|
+
# Your Sitecore Edge Context Id for client-side use.
|
|
19
|
+
# Will be used as a fallback if separate SITECORE_EDGE_CONTEXT_ID value is not provided
|
|
20
|
+
NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID=
|
|
21
|
+
|
|
22
|
+
# Optional: custom Sitecore Edge Platform hostname (hostname or full URL).
|
|
23
|
+
NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME=
|
|
24
|
+
|
|
25
|
+
# Optional: custom Experience Edge hostname for media URL rewriting (e.g. staging).
|
|
26
|
+
SITECORE_EXPERIENCE_EDGE_HOSTNAME=
|
|
27
|
+
|
|
28
|
+
# An optional Sitecore Personalize scope identifier.
|
|
29
|
+
# This can be used to isolate personalization data when multiple XM Cloud Environments share a Personalize tenant.
|
|
30
|
+
# This should match the PAGES_PERSONALIZE_SCOPE environment variable for your connected XM Cloud Environment.
|
|
31
|
+
NEXT_PUBLIC_PERSONALIZE_SCOPE=
|
|
32
|
+
|
|
33
|
+
# Timeout (ms) for Sitecore CDP requests to respond within. Default is 400.
|
|
34
|
+
PERSONALIZE_MIDDLEWARE_CDP_TIMEOUT=
|
|
35
|
+
|
|
36
|
+
# Timeout (ms) for Sitecore Experience Edge requests to respond within. Default is 400.
|
|
37
|
+
PERSONALIZE_MIDDLEWARE_EDGE_TIMEOUT=
|
|
38
|
+
|
|
39
|
+
# Sitecore Content SDK npm packages utilize the debug module for debug logging.
|
|
40
|
+
# https://www.npmjs.com/package/debug
|
|
41
|
+
# Set the DEBUG environment variable to 'content-sdk:*' to see all logs:
|
|
42
|
+
#DEBUG=content-sdk:*
|
|
43
|
+
# Or be selective and show for example only layout service logs:
|
|
44
|
+
#DEBUG=content-sdk:layout
|
|
45
|
+
# Or everything BUT layout service logs:
|
|
46
|
+
#DEBUG=content-sdk:*,-content-sdk:layout
|
|
47
|
+
|
|
48
|
+
# Client ID, Secret and Rendering Host Name used for Design Library functionality
|
|
49
|
+
SITECORE_AUTH_CLIENT_ID=
|
|
50
|
+
SITECORE_AUTH_CLIENT_SECRET=
|
|
51
|
+
SITECORE_RENDERINGHOST_NAME=
|