create-content-sdk-app 2.0.0 → 2.0.2-canary.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/templates/nextjs/.agents/skills/content-sdk-component-data-strategy/SKILL.md +37 -0
- package/dist/templates/nextjs/.agents/skills/content-sdk-component-registration/SKILL.md +36 -0
- package/dist/templates/nextjs/.agents/skills/content-sdk-component-scaffold/SKILL.md +34 -0
- package/dist/templates/nextjs/.agents/skills/content-sdk-component-variants/SKILL.md +36 -0
- package/dist/templates/nextjs/.agents/skills/content-sdk-dictionary-and-i18n/SKILL.md +35 -0
- package/dist/templates/nextjs/.agents/skills/content-sdk-editing-safe-rendering/SKILL.md +37 -0
- package/dist/templates/nextjs/.agents/skills/content-sdk-field-usage-image-link-text/SKILL.md +36 -0
- package/dist/templates/nextjs/.agents/skills/content-sdk-graphql-data-fetching/SKILL.md +38 -0
- package/dist/templates/nextjs/.agents/skills/content-sdk-multisite-management/SKILL.md +37 -0
- package/dist/templates/nextjs/.agents/skills/content-sdk-route-configuration/SKILL.md +38 -0
- package/dist/templates/nextjs/.agents/skills/content-sdk-site-setup-and-env/SKILL.md +36 -0
- package/dist/templates/nextjs/.agents/skills/content-sdk-sitemap-robots/SKILL.md +37 -0
- package/dist/templates/nextjs/.agents/skills/content-sdk-troubleshoot-editing/SKILL.md +39 -0
- package/dist/templates/nextjs/.agents/skills/content-sdk-upgrade-assistant/SKILL.md +36 -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/AGENTS.md +1 -0
- package/dist/templates/nextjs/CLAUDE.md +6 -170
- package/dist/templates/nextjs/LICENSE.txt +202 -202
- package/dist/templates/nextjs/Skills.md +79 -0
- 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/src/Bootstrap.tsx +20 -13
- package/dist/templates/nextjs/src/byoc/index.tsx +1 -1
- package/dist/templates/nextjs/src/components/content-sdk/CdpPageView.tsx +1 -1
- package/dist/templates/nextjs/tsconfig.json +40 -40
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-data-strategy/SKILL.md +37 -0
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-registration/SKILL.md +38 -0
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-scaffold/SKILL.md +38 -0
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-variants/SKILL.md +36 -0
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-dictionary-and-i18n/SKILL.md +37 -0
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-editing-safe-rendering/SKILL.md +37 -0
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-field-usage-image-link-text/SKILL.md +36 -0
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-graphql-data-fetching/SKILL.md +37 -0
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-multisite-management/SKILL.md +37 -0
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-route-configuration/SKILL.md +38 -0
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-site-setup-and-env/SKILL.md +36 -0
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-sitemap-robots/SKILL.md +37 -0
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-troubleshoot-editing/SKILL.md +39 -0
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-upgrade-assistant/SKILL.md +36 -0
- 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/.sitecore/import-map.server.ts +2 -2
- package/dist/templates/nextjs-app-router/.windsurfrules +290 -290
- package/dist/templates/nextjs-app-router/AGENTS.md +6 -6
- package/dist/templates/nextjs-app-router/CLAUDE.md +6 -271
- package/dist/templates/nextjs-app-router/README.md +0 -36
- package/dist/templates/nextjs-app-router/Skills.md +79 -0
- 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 +55 -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/Bootstrap.tsx +20 -12
- package/dist/templates/nextjs-app-router/src/app/[site]/[locale]/[[...path]]/layout.tsx +19 -0
- package/dist/templates/nextjs-app-router/src/app/[site]/[locale]/[[...path]]/not-found.tsx +3 -28
- package/dist/templates/nextjs-app-router/src/app/[site]/[locale]/[[...path]]/page.tsx +6 -21
- package/dist/templates/nextjs-app-router/src/app/[site]/layout.tsx +5 -21
- package/dist/templates/nextjs-app-router/src/app/globals.css +1 -1
- package/dist/templates/nextjs-app-router/src/app/not-found.tsx +1 -23
- package/dist/templates/nextjs-app-router/src/byoc/index.tsx +1 -1
- package/dist/templates/nextjs-app-router/src/components/content-sdk/CdpPageView.tsx +1 -1
- package/dist/templates/nextjs-app-router/tsconfig.json +48 -48
- package/package.json +2 -2
- package/dist/initializers/angular/args.js +0 -2
- package/dist/initializers/angular/index.js +0 -30
- package/dist/initializers/angular/prompts.js +0 -20
- package/dist/templates/angular/.postcssrc.json +0 -5
- package/dist/templates/angular/.vscode/extensions.json +0 -4
- package/dist/templates/angular/README.md +0 -3
- package/dist/templates/angular/angular.json +0 -79
- package/dist/templates/angular/package.json +0 -58
- package/dist/templates/angular/public/favicon.ico +0 -0
- package/dist/templates/angular/src/app/app.config.server.ts +0 -12
- package/dist/templates/angular/src/app/app.config.ts +0 -31
- package/dist/templates/angular/src/app/app.css +0 -0
- package/dist/templates/angular/src/app/app.html +0 -1
- package/dist/templates/angular/src/app/app.routes.server.ts +0 -15
- package/dist/templates/angular/src/app/app.routes.ts +0 -28
- package/dist/templates/angular/src/app/app.ts +0 -12
- package/dist/templates/angular/src/app/loaders/error.loader.ts +0 -12
- package/dist/templates/angular/src/app/loaders/index.ts +0 -14
- package/dist/templates/angular/src/app/loaders/not-found.loader.ts +0 -12
- package/dist/templates/angular/src/app/loaders/page.loader.ts +0 -15
- package/dist/templates/angular/src/app/loaders/stub-utils.ts +0 -83
- package/dist/templates/angular/src/app/pages/error.component.ts +0 -124
- package/dist/templates/angular/src/app/pages/not-found.component.ts +0 -85
- package/dist/templates/angular/src/app/pages/page.component.ts +0 -58
- package/dist/templates/angular/src/app/shared/layout.component.ts +0 -106
- package/dist/templates/angular/src/index.html +0 -13
- package/dist/templates/angular/src/main.server.ts +0 -8
- package/dist/templates/angular/src/main.ts +0 -6
- package/dist/templates/angular/src/server.ts +0 -65
- package/dist/templates/angular/src/styles.css +0 -3
- package/dist/templates/angular/tsconfig.json +0 -38
- package/dist/templates/angular/tsconfig.spec.json +0 -10
- package/dist/templates/nextjs/LLMs.txt +0 -179
- package/dist/templates/nextjs-app-router/LLMs.txt +0 -236
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Getting started with your Sitecore Content SDK Next.js App Router project
|
|
3
|
-
alwaysApply: true
|
|
4
|
-
globs: []
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Sitecore Content SDK Next.js App Router Project
|
|
8
|
-
|
|
9
|
-
## Project Overview
|
|
10
|
-
|
|
11
|
-
This is a Sitecore Content SDK application built with Next.js App Router. This project uses the latest Next.js features for improved performance and developer experience.
|
|
12
|
-
|
|
13
|
-
Key Technologies:
|
|
14
|
-
|
|
15
|
-
- Next.js App Router (React Server Components)
|
|
16
|
-
- Sitecore Content SDK
|
|
17
|
-
- TypeScript
|
|
18
|
-
- Sitecore XM Cloud
|
|
19
|
-
- next-intl for internationalization
|
|
20
|
-
|
|
21
|
-
## Getting Started
|
|
22
|
-
|
|
23
|
-
Development Workflow:
|
|
24
|
-
|
|
25
|
-
1. Install dependencies: `npm install`
|
|
26
|
-
2. Configure environment variables (copy `.env.example` to `.env.local`)
|
|
27
|
-
3. Start development server: `npm run dev`
|
|
28
|
-
4. Build for production: `npm run build`
|
|
29
|
-
|
|
30
|
-
App Router Specifics:
|
|
31
|
-
|
|
32
|
-
- Server Components by default
|
|
33
|
-
- Client Components when interactivity needed
|
|
34
|
-
- File-based routing in `src/app/` directory
|
|
35
|
-
- Layout files for shared UI elements
|
|
36
|
-
|
|
37
|
-
## Project Structure
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
src/
|
|
41
|
-
app/ # App Router pages and layouts
|
|
42
|
-
components/ # React-specific SDK
|
|
43
|
-
lib/ # Configuration and utilities
|
|
44
|
-
i18n/ # Internationalization setup
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Component Development:
|
|
48
|
-
|
|
49
|
-
- Server Components for data fetching and static content
|
|
50
|
-
- Client Components for interactivity (use 'use client')
|
|
51
|
-
- Shared components in `src/components/`
|
|
52
|
-
- Follow Sitecore field handling patterns
|
|
53
|
-
|
|
54
|
-
## App Router Best Practices
|
|
55
|
-
|
|
56
|
-
Server vs Client Components:
|
|
57
|
-
|
|
58
|
-
- Use Server Components for Sitecore content rendering
|
|
59
|
-
- Use Client Components for user interactions
|
|
60
|
-
- Minimize client-side JavaScript
|
|
61
|
-
- Leverage server-side data fetching
|
|
62
|
-
|
|
63
|
-
Routing and Layouts:
|
|
64
|
-
|
|
65
|
-
- Use layout.tsx for shared page structure
|
|
66
|
-
- Implement loading.tsx for loading states
|
|
67
|
-
- Create error.tsx for error boundaries
|
|
68
|
-
- Use page.tsx for route content
|
|
69
|
-
|
|
70
|
-
## Sitecore Integration
|
|
71
|
-
|
|
72
|
-
Content Rendering:
|
|
73
|
-
|
|
74
|
-
- Fetch Sitecore data in Server Components
|
|
75
|
-
- Use layout service for page structure
|
|
76
|
-
- Handle content preview scenarios
|
|
77
|
-
- Implement proper error handling
|
|
78
|
-
|
|
79
|
-
Performance:
|
|
80
|
-
|
|
81
|
-
- Leverage Server Components for better performance
|
|
82
|
-
- Use streaming for improved loading experience
|
|
83
|
-
- Implement proper caching strategies
|
|
84
|
-
- Optimize images with Next.js Image component
|
|
85
|
-
|
|
86
|
-
## Development Commands
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
npm run dev # Start development server
|
|
90
|
-
npm run build # Build for production
|
|
91
|
-
npm run start # Start production server
|
|
92
|
-
npm run lint # Run ESLint
|
|
93
|
-
npm run type-check # Run TypeScript compiler
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Environment Configuration
|
|
97
|
-
|
|
98
|
-
- Copy `.env.example` to `.env.local`
|
|
99
|
-
- Add your Sitecore API endpoint and key
|
|
100
|
-
- Configure site name and locale settings
|
|
101
|
-
- Set up internationalization if needed
|
|
102
|
-
|
|
103
|
-
## Next Steps
|
|
104
|
-
|
|
105
|
-
1. Configure your Sitecore connection
|
|
106
|
-
2. Set up internationalization (if needed)
|
|
107
|
-
3. Create your first Server Component
|
|
108
|
-
4. Add content types and templates
|
|
109
|
-
5. Implement your layout structure
|
|
110
|
-
6. Deploy to your hosting platform
|
|
111
|
-
|
|
112
|
-
Referenced:
|
|
113
|
-
@src/app/
|
|
114
|
-
@src/components/
|
|
115
|
-
@sitecore.config.ts
|
|
116
|
-
@src/i18n/
|
|
1
|
+
---
|
|
2
|
+
description: Getting started with your Sitecore Content SDK Next.js App Router project
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
globs: []
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Sitecore Content SDK Next.js App Router Project
|
|
8
|
+
|
|
9
|
+
## Project Overview
|
|
10
|
+
|
|
11
|
+
This is a Sitecore Content SDK application built with Next.js App Router. This project uses the latest Next.js features for improved performance and developer experience.
|
|
12
|
+
|
|
13
|
+
Key Technologies:
|
|
14
|
+
|
|
15
|
+
- Next.js App Router (React Server Components)
|
|
16
|
+
- Sitecore Content SDK
|
|
17
|
+
- TypeScript
|
|
18
|
+
- Sitecore XM Cloud
|
|
19
|
+
- next-intl for internationalization
|
|
20
|
+
|
|
21
|
+
## Getting Started
|
|
22
|
+
|
|
23
|
+
Development Workflow:
|
|
24
|
+
|
|
25
|
+
1. Install dependencies: `npm install`
|
|
26
|
+
2. Configure environment variables (copy `.env.example` to `.env.local`)
|
|
27
|
+
3. Start development server: `npm run dev`
|
|
28
|
+
4. Build for production: `npm run build`
|
|
29
|
+
|
|
30
|
+
App Router Specifics:
|
|
31
|
+
|
|
32
|
+
- Server Components by default
|
|
33
|
+
- Client Components when interactivity needed
|
|
34
|
+
- File-based routing in `src/app/` directory
|
|
35
|
+
- Layout files for shared UI elements
|
|
36
|
+
|
|
37
|
+
## Project Structure
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
src/
|
|
41
|
+
app/ # App Router pages and layouts
|
|
42
|
+
components/ # React-specific SDK
|
|
43
|
+
lib/ # Configuration and utilities
|
|
44
|
+
i18n/ # Internationalization setup
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Component Development:
|
|
48
|
+
|
|
49
|
+
- Server Components for data fetching and static content
|
|
50
|
+
- Client Components for interactivity (use 'use client')
|
|
51
|
+
- Shared components in `src/components/`
|
|
52
|
+
- Follow Sitecore field handling patterns
|
|
53
|
+
|
|
54
|
+
## App Router Best Practices
|
|
55
|
+
|
|
56
|
+
Server vs Client Components:
|
|
57
|
+
|
|
58
|
+
- Use Server Components for Sitecore content rendering
|
|
59
|
+
- Use Client Components for user interactions
|
|
60
|
+
- Minimize client-side JavaScript
|
|
61
|
+
- Leverage server-side data fetching
|
|
62
|
+
|
|
63
|
+
Routing and Layouts:
|
|
64
|
+
|
|
65
|
+
- Use layout.tsx for shared page structure
|
|
66
|
+
- Implement loading.tsx for loading states
|
|
67
|
+
- Create error.tsx for error boundaries
|
|
68
|
+
- Use page.tsx for route content
|
|
69
|
+
|
|
70
|
+
## Sitecore Integration
|
|
71
|
+
|
|
72
|
+
Content Rendering:
|
|
73
|
+
|
|
74
|
+
- Fetch Sitecore data in Server Components
|
|
75
|
+
- Use layout service for page structure
|
|
76
|
+
- Handle content preview scenarios
|
|
77
|
+
- Implement proper error handling
|
|
78
|
+
|
|
79
|
+
Performance:
|
|
80
|
+
|
|
81
|
+
- Leverage Server Components for better performance
|
|
82
|
+
- Use streaming for improved loading experience
|
|
83
|
+
- Implement proper caching strategies
|
|
84
|
+
- Optimize images with Next.js Image component
|
|
85
|
+
|
|
86
|
+
## Development Commands
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm run dev # Start development server
|
|
90
|
+
npm run build # Build for production
|
|
91
|
+
npm run start # Start production server
|
|
92
|
+
npm run lint # Run ESLint
|
|
93
|
+
npm run type-check # Run TypeScript compiler
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Environment Configuration
|
|
97
|
+
|
|
98
|
+
- Copy `.env.example` to `.env.local`
|
|
99
|
+
- Add your Sitecore API endpoint and key
|
|
100
|
+
- Configure site name and locale settings
|
|
101
|
+
- Set up internationalization if needed
|
|
102
|
+
|
|
103
|
+
## Next Steps
|
|
104
|
+
|
|
105
|
+
1. Configure your Sitecore connection
|
|
106
|
+
2. Set up internationalization (if needed)
|
|
107
|
+
3. Create your first Server Component
|
|
108
|
+
4. Add content types and templates
|
|
109
|
+
5. Implement your layout structure
|
|
110
|
+
6. Deploy to your hosting platform
|
|
111
|
+
|
|
112
|
+
Referenced:
|
|
113
|
+
@src/app/
|
|
114
|
+
@src/components/
|
|
115
|
+
@sitecore.config.ts
|
|
116
|
+
@src/i18n/
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Core coding principles for your Sitecore project
|
|
3
|
-
alwaysApply: true
|
|
4
|
-
globs: []
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# General Coding Principles
|
|
8
|
-
|
|
9
|
-
## Universal Standards
|
|
10
|
-
|
|
11
|
-
DRY Principle:
|
|
12
|
-
|
|
13
|
-
- Don't Repeat Yourself - extract common functionality
|
|
14
|
-
- Create reusable utilities and helper functions
|
|
15
|
-
- Use composition over inheritance
|
|
16
|
-
- Share types and interfaces across modules
|
|
17
|
-
|
|
18
|
-
SOLID Principles:
|
|
19
|
-
|
|
20
|
-
- Single Responsibility: each function/class has one purpose
|
|
21
|
-
- Open/Closed: extend functionality through composition
|
|
22
|
-
- Dependency Inversion: depend on abstractions, not implementations
|
|
23
|
-
|
|
24
|
-
Code Clarity:
|
|
25
|
-
|
|
26
|
-
- Write self-documenting code with clear intent
|
|
27
|
-
- Use meaningful names that express business concepts
|
|
28
|
-
- Prefer explicit over implicit behavior
|
|
29
|
-
- Make dependencies and requirements obvious
|
|
30
|
-
|
|
31
|
-
## Architecture Patterns
|
|
32
|
-
|
|
33
|
-
Modular Design:
|
|
34
|
-
|
|
35
|
-
- Organize code into focused, cohesive modules
|
|
36
|
-
- Minimize coupling between modules
|
|
37
|
-
- Use clear interfaces between layers
|
|
38
|
-
- Follow established patterns consistently
|
|
39
|
-
|
|
40
|
-
Data Flow:
|
|
41
|
-
|
|
42
|
-
- Prefer unidirectional data flow
|
|
43
|
-
- Validate inputs at system boundaries
|
|
44
|
-
- Transform data at appropriate layers
|
|
45
|
-
- Handle errors close to their source
|
|
46
|
-
|
|
47
|
-
Testing:
|
|
48
|
-
|
|
49
|
-
- Write testable code with minimal dependencies
|
|
50
|
-
- Use dependency injection for better testability
|
|
51
|
-
- Mock external services and side effects
|
|
52
|
-
- Test behavior, not implementation details
|
|
53
|
-
|
|
54
|
-
## Development Standards
|
|
55
|
-
|
|
56
|
-
Version Control:
|
|
57
|
-
|
|
58
|
-
- Write descriptive commit messages
|
|
59
|
-
- Keep commits focused and atomic
|
|
60
|
-
- Use branching strategies appropriate to team size
|
|
61
|
-
- Review code before merging
|
|
62
|
-
|
|
63
|
-
Documentation:
|
|
64
|
-
|
|
65
|
-
- Document public APIs and interfaces
|
|
66
|
-
- Include usage examples for complex functionality
|
|
67
|
-
- Keep documentation close to code
|
|
68
|
-
- Update documentation with code changes
|
|
69
|
-
|
|
70
|
-
Performance:
|
|
71
|
-
|
|
72
|
-
- Optimize for readability first, performance second
|
|
73
|
-
- Profile before optimizing
|
|
74
|
-
- Cache expensive operations appropriately
|
|
75
|
-
- Consider memory usage and cleanup
|
|
76
|
-
|
|
77
|
-
Referenced:
|
|
78
|
-
@src/app/
|
|
79
|
-
@src/components/
|
|
80
|
-
@src/lib/
|
|
1
|
+
---
|
|
2
|
+
description: Core coding principles for your Sitecore project
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
globs: []
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# General Coding Principles
|
|
8
|
+
|
|
9
|
+
## Universal Standards
|
|
10
|
+
|
|
11
|
+
DRY Principle:
|
|
12
|
+
|
|
13
|
+
- Don't Repeat Yourself - extract common functionality
|
|
14
|
+
- Create reusable utilities and helper functions
|
|
15
|
+
- Use composition over inheritance
|
|
16
|
+
- Share types and interfaces across modules
|
|
17
|
+
|
|
18
|
+
SOLID Principles:
|
|
19
|
+
|
|
20
|
+
- Single Responsibility: each function/class has one purpose
|
|
21
|
+
- Open/Closed: extend functionality through composition
|
|
22
|
+
- Dependency Inversion: depend on abstractions, not implementations
|
|
23
|
+
|
|
24
|
+
Code Clarity:
|
|
25
|
+
|
|
26
|
+
- Write self-documenting code with clear intent
|
|
27
|
+
- Use meaningful names that express business concepts
|
|
28
|
+
- Prefer explicit over implicit behavior
|
|
29
|
+
- Make dependencies and requirements obvious
|
|
30
|
+
|
|
31
|
+
## Architecture Patterns
|
|
32
|
+
|
|
33
|
+
Modular Design:
|
|
34
|
+
|
|
35
|
+
- Organize code into focused, cohesive modules
|
|
36
|
+
- Minimize coupling between modules
|
|
37
|
+
- Use clear interfaces between layers
|
|
38
|
+
- Follow established patterns consistently
|
|
39
|
+
|
|
40
|
+
Data Flow:
|
|
41
|
+
|
|
42
|
+
- Prefer unidirectional data flow
|
|
43
|
+
- Validate inputs at system boundaries
|
|
44
|
+
- Transform data at appropriate layers
|
|
45
|
+
- Handle errors close to their source
|
|
46
|
+
|
|
47
|
+
Testing:
|
|
48
|
+
|
|
49
|
+
- Write testable code with minimal dependencies
|
|
50
|
+
- Use dependency injection for better testability
|
|
51
|
+
- Mock external services and side effects
|
|
52
|
+
- Test behavior, not implementation details
|
|
53
|
+
|
|
54
|
+
## Development Standards
|
|
55
|
+
|
|
56
|
+
Version Control:
|
|
57
|
+
|
|
58
|
+
- Write descriptive commit messages
|
|
59
|
+
- Keep commits focused and atomic
|
|
60
|
+
- Use branching strategies appropriate to team size
|
|
61
|
+
- Review code before merging
|
|
62
|
+
|
|
63
|
+
Documentation:
|
|
64
|
+
|
|
65
|
+
- Document public APIs and interfaces
|
|
66
|
+
- Include usage examples for complex functionality
|
|
67
|
+
- Keep documentation close to code
|
|
68
|
+
- Update documentation with code changes
|
|
69
|
+
|
|
70
|
+
Performance:
|
|
71
|
+
|
|
72
|
+
- Optimize for readability first, performance second
|
|
73
|
+
- Profile before optimizing
|
|
74
|
+
- Cache expensive operations appropriately
|
|
75
|
+
- Consider memory usage and cleanup
|
|
76
|
+
|
|
77
|
+
Referenced:
|
|
78
|
+
@src/app/
|
|
79
|
+
@src/components/
|
|
80
|
+
@src/lib/
|
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: JavaScript/TypeScript rules for your Sitecore App Router project
|
|
3
|
-
alwaysApply: false
|
|
4
|
-
globs:
|
|
5
|
-
- '**/*.js'
|
|
6
|
-
- '**/*.ts'
|
|
7
|
-
- '**/*.tsx'
|
|
8
|
-
- '**/*.mjs'
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# JavaScript/TypeScript Rules
|
|
12
|
-
|
|
13
|
-
## Naming Conventions
|
|
14
|
-
|
|
15
|
-
Variables and Functions:
|
|
16
|
-
|
|
17
|
-
- Use camelCase: `getUserData()`, `isLoading`, `currentUser`
|
|
18
|
-
- Boolean variables: prefix with `is`, `has`, `can`, `should`
|
|
19
|
-
- Event handlers: prefix with `handle` or `on`: `handleClick`, `onSubmit`
|
|
20
|
-
|
|
21
|
-
Components (React):
|
|
22
|
-
|
|
23
|
-
- Use PascalCase: `SitecoreComponent`, `PageLayout`, `ContentBlock`
|
|
24
|
-
- File names match component names: `SitecoreComponent.tsx`
|
|
25
|
-
|
|
26
|
-
Constants:
|
|
27
|
-
|
|
28
|
-
- Use UPPER_SNAKE_CASE: `API_ENDPOINT`, `DEFAULT_TIMEOUT`, `MAX_RETRIES`
|
|
29
|
-
- Export at module level when shared
|
|
30
|
-
|
|
31
|
-
Directories:
|
|
32
|
-
|
|
33
|
-
- Use kebab-case: `src/components`, `src/api-clients`, `src/sitecore-utils`
|
|
34
|
-
- Organize by feature when appropriate: `src/content-management/`
|
|
35
|
-
|
|
36
|
-
Types and Interfaces:
|
|
37
|
-
|
|
38
|
-
- Use PascalCase with descriptive names: `ContentItem`, `LayoutProps`, `SitecoreConfig`
|
|
39
|
-
- Prefix interfaces with `I` only when needed for disambiguation
|
|
40
|
-
|
|
41
|
-
## Code Layout and Organization
|
|
42
|
-
|
|
43
|
-
Directory Structure:
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
src/
|
|
47
|
-
app/ # App Router pages and layouts
|
|
48
|
-
components/ # UI components (React)
|
|
49
|
-
lib/ # Configuration and utilities
|
|
50
|
-
i18n/ # Internationalization setup
|
|
51
|
-
types/ # TypeScript type definitions
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
File Organization:
|
|
55
|
-
|
|
56
|
-
- Server Components for data fetching and static content
|
|
57
|
-
- Client Components for interactivity (use 'use client')
|
|
58
|
-
- Group related functionality in feature directories
|
|
59
|
-
- Keep components co-located with their styles and tests
|
|
60
|
-
|
|
61
|
-
## Error Handling
|
|
62
|
-
|
|
63
|
-
API Calls:
|
|
64
|
-
|
|
65
|
-
- Always wrap in try/catch blocks
|
|
66
|
-
- Throw custom errors with context: `SitecoreFetchError`, `ConfigurationError`
|
|
67
|
-
- Handle edge cases with guard clauses
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
async function fetchContent(id: string): Promise<ContentItem> {
|
|
71
|
-
if (!id) {
|
|
72
|
-
throw new Error('Content ID is required');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
const response = await sitecoreClient.getItem(id);
|
|
77
|
-
return response.data;
|
|
78
|
-
} catch (error) {
|
|
79
|
-
throw new SitecoreFetchError(`Failed to fetch content ${id}`, error);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Security
|
|
85
|
-
|
|
86
|
-
Input Validation:
|
|
87
|
-
|
|
88
|
-
- Sanitize user inputs before processing
|
|
89
|
-
- Validate data at application boundaries
|
|
90
|
-
- Use type guards for runtime type checking
|
|
91
|
-
- Escape content when rendering to prevent XSS
|
|
92
|
-
|
|
93
|
-
## Performance
|
|
94
|
-
|
|
95
|
-
Optimization Patterns:
|
|
96
|
-
|
|
97
|
-
- Cache API responses using React Query or SWR
|
|
98
|
-
- Use Server Components for better performance
|
|
99
|
-
- Lazy-load non-critical modules: `const Component = lazy(() => import('./Component'))`
|
|
100
|
-
- Use useCallback and useMemo for expensive operations in Client Components
|
|
101
|
-
|
|
102
|
-
TypeScript:
|
|
103
|
-
|
|
104
|
-
- Enable strict mode in tsconfig.json
|
|
105
|
-
- Prefer type assertions over any: `value as ContentItem`
|
|
106
|
-
- Use discriminated unions for complex state management
|
|
107
|
-
|
|
108
|
-
Referenced:
|
|
109
|
-
@src/app/
|
|
110
|
-
@src/components/
|
|
111
|
-
@src/lib/
|
|
112
|
-
|
|
1
|
+
---
|
|
2
|
+
description: JavaScript/TypeScript rules for your Sitecore App Router project
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
globs:
|
|
5
|
+
- '**/*.js'
|
|
6
|
+
- '**/*.ts'
|
|
7
|
+
- '**/*.tsx'
|
|
8
|
+
- '**/*.mjs'
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# JavaScript/TypeScript Rules
|
|
12
|
+
|
|
13
|
+
## Naming Conventions
|
|
14
|
+
|
|
15
|
+
Variables and Functions:
|
|
16
|
+
|
|
17
|
+
- Use camelCase: `getUserData()`, `isLoading`, `currentUser`
|
|
18
|
+
- Boolean variables: prefix with `is`, `has`, `can`, `should`
|
|
19
|
+
- Event handlers: prefix with `handle` or `on`: `handleClick`, `onSubmit`
|
|
20
|
+
|
|
21
|
+
Components (React):
|
|
22
|
+
|
|
23
|
+
- Use PascalCase: `SitecoreComponent`, `PageLayout`, `ContentBlock`
|
|
24
|
+
- File names match component names: `SitecoreComponent.tsx`
|
|
25
|
+
|
|
26
|
+
Constants:
|
|
27
|
+
|
|
28
|
+
- Use UPPER_SNAKE_CASE: `API_ENDPOINT`, `DEFAULT_TIMEOUT`, `MAX_RETRIES`
|
|
29
|
+
- Export at module level when shared
|
|
30
|
+
|
|
31
|
+
Directories:
|
|
32
|
+
|
|
33
|
+
- Use kebab-case: `src/components`, `src/api-clients`, `src/sitecore-utils`
|
|
34
|
+
- Organize by feature when appropriate: `src/content-management/`
|
|
35
|
+
|
|
36
|
+
Types and Interfaces:
|
|
37
|
+
|
|
38
|
+
- Use PascalCase with descriptive names: `ContentItem`, `LayoutProps`, `SitecoreConfig`
|
|
39
|
+
- Prefix interfaces with `I` only when needed for disambiguation
|
|
40
|
+
|
|
41
|
+
## Code Layout and Organization
|
|
42
|
+
|
|
43
|
+
Directory Structure:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
src/
|
|
47
|
+
app/ # App Router pages and layouts
|
|
48
|
+
components/ # UI components (React)
|
|
49
|
+
lib/ # Configuration and utilities
|
|
50
|
+
i18n/ # Internationalization setup
|
|
51
|
+
types/ # TypeScript type definitions
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
File Organization:
|
|
55
|
+
|
|
56
|
+
- Server Components for data fetching and static content
|
|
57
|
+
- Client Components for interactivity (use 'use client')
|
|
58
|
+
- Group related functionality in feature directories
|
|
59
|
+
- Keep components co-located with their styles and tests
|
|
60
|
+
|
|
61
|
+
## Error Handling
|
|
62
|
+
|
|
63
|
+
API Calls:
|
|
64
|
+
|
|
65
|
+
- Always wrap in try/catch blocks
|
|
66
|
+
- Throw custom errors with context: `SitecoreFetchError`, `ConfigurationError`
|
|
67
|
+
- Handle edge cases with guard clauses
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
async function fetchContent(id: string): Promise<ContentItem> {
|
|
71
|
+
if (!id) {
|
|
72
|
+
throw new Error('Content ID is required');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
const response = await sitecoreClient.getItem(id);
|
|
77
|
+
return response.data;
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw new SitecoreFetchError(`Failed to fetch content ${id}`, error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Security
|
|
85
|
+
|
|
86
|
+
Input Validation:
|
|
87
|
+
|
|
88
|
+
- Sanitize user inputs before processing
|
|
89
|
+
- Validate data at application boundaries
|
|
90
|
+
- Use type guards for runtime type checking
|
|
91
|
+
- Escape content when rendering to prevent XSS
|
|
92
|
+
|
|
93
|
+
## Performance
|
|
94
|
+
|
|
95
|
+
Optimization Patterns:
|
|
96
|
+
|
|
97
|
+
- Cache API responses using React Query or SWR
|
|
98
|
+
- Use Server Components for better performance
|
|
99
|
+
- Lazy-load non-critical modules: `const Component = lazy(() => import('./Component'))`
|
|
100
|
+
- Use useCallback and useMemo for expensive operations in Client Components
|
|
101
|
+
|
|
102
|
+
TypeScript:
|
|
103
|
+
|
|
104
|
+
- Enable strict mode in tsconfig.json
|
|
105
|
+
- Prefer type assertions over any: `value as ContentItem`
|
|
106
|
+
- Use discriminated unions for complex state management
|
|
107
|
+
|
|
108
|
+
Referenced:
|
|
109
|
+
@src/app/
|
|
110
|
+
@src/components/
|
|
111
|
+
@src/lib/
|
|
112
|
+
|