create-content-sdk-app 2.2.0 → 2.2.1-canary.20260630132751
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/dist/templates/nextjs/.agents/skills/content-sdk-component-registration/SKILL.md +2 -2
- package/dist/templates/nextjs/.agents/skills/content-sdk-component-scaffold/SKILL.md +5 -2
- package/dist/templates/nextjs/.agents/skills/content-sdk-component-variants/SKILL.md +1 -1
- package/dist/templates/nextjs/AGENTS.md +7 -5
- package/dist/templates/nextjs/Skills.md +3 -3
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-registration/SKILL.md +2 -2
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-scaffold/SKILL.md +6 -4
- package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-variants/SKILL.md +1 -1
- package/dist/templates/nextjs-app-router/AGENTS.md +7 -5
- package/dist/templates/nextjs-app-router/Skills.md +3 -3
- package/dist/templates/nextjs-app-router-cache-components/.agents/skills/content-sdk-component-registration/SKILL.md +2 -2
- package/dist/templates/nextjs-app-router-cache-components/.agents/skills/content-sdk-component-scaffold/SKILL.md +6 -4
- package/dist/templates/nextjs-app-router-cache-components/.agents/skills/content-sdk-component-variants/SKILL.md +1 -1
- package/dist/templates/nextjs-app-router-cache-components/AGENTS.md +7 -5
- package/dist/templates/nextjs-app-router-cache-components/Skills.md +3 -3
- package/package.json +1 -1
|
@@ -16,11 +16,11 @@ Register components in the Sitecore component map so the layout and editing pipe
|
|
|
16
16
|
|
|
17
17
|
## How to perform
|
|
18
18
|
|
|
19
|
-
-
|
|
19
|
+
- The component map at `.sitecore/component-map.ts` is generated from `src/components/` during `npm run dev` or `npm run build`; run `npm run sitecore-tools:generate-map` to refresh it manually, and edit the file only when the generator cannot handle your case.
|
|
20
20
|
|
|
21
21
|
## Hard Rules
|
|
22
22
|
|
|
23
|
-
- Every component rendered from Sitecore layout must be registered in `.sitecore/component-map.ts`.
|
|
23
|
+
- Every component rendered from Sitecore layout must be registered in `.sitecore/component-map.ts`. Prefer the project's `sitecore-tools:generate-map` script to keep the map in sync with `src/components/`. Do not hand-edit generated map entries unless necessary.
|
|
24
24
|
- The map is used by `getComponentData(page.layout, context, components)` in the catch-all page and by editing API routes (`src/pages/api/editing/config.ts`, `render.ts`, `feaas/render.ts`).
|
|
25
25
|
- Use consistent component names (same key in map as used in layout). Follow existing naming in the map.
|
|
26
26
|
- Do not remove or rename registrations without updating all references (layout, getComponentData, editing routes).
|
|
@@ -15,14 +15,17 @@ Scaffold new Sitecore components so they integrate with the layout and editing p
|
|
|
15
15
|
|
|
16
16
|
## How to perform
|
|
17
17
|
|
|
18
|
-
- Create a new file under `src/components/` (or existing feature folder). Define props (fields, params), export a single default component.
|
|
18
|
+
- Create a new file under `src/components/` (or existing feature folder). Define props (fields, params), export a single default component.
|
|
19
|
+
- **Map:** Regenerates automatically during `npm run dev` and `npm run build`; otherwise run `npm run sitecore-tools:generate-map` (see content-sdk-component-registration).
|
|
20
|
+
- Run `npm run build` to verify.
|
|
19
21
|
|
|
20
22
|
## Hard Rules
|
|
21
23
|
|
|
22
24
|
- Place components under `src/components/`. Use existing folder conventions.
|
|
25
|
+
- Prefer `npm run sitecore-tools:generate-map` to regenerate `.sitecore/component-map.ts` instead of hand-editing it. Only manually register the component if the generator cannot handle the change.
|
|
23
26
|
- Define a props interface with the component's fields (e.g. `fields: { title: Field; ... }`) and any params. Use types from `@sitecore-content-sdk/react` or the app's types.
|
|
24
27
|
- Export a single default component; one component per file unless the app pattern differs.
|
|
25
|
-
-
|
|
28
|
+
- Ensure the component map regenerates (or update `.sitecore/component-map.ts` manually only if the generator cannot handle the case) before considering the task complete (see content-sdk-component-registration). Pages Router has a single map used by getComponentData and editing API routes.
|
|
26
29
|
|
|
27
30
|
## Stop Conditions
|
|
28
31
|
|
|
@@ -22,7 +22,7 @@ One component definition can have multiple presentations or data-driven variants
|
|
|
22
22
|
- Prefer a single component registration that accepts variant/style data (e.g. params or fields) and branches internally, over multiple map entries for the same logical component unless the app pattern uses separate registrations per variant.
|
|
23
23
|
- Use props (fields, params) from layout to decide variant; do not rely on global state or URL for variant selection when data comes from Sitecore. getComponentData passes the layout-driven props to the component.
|
|
24
24
|
- Register in `.sitecore/component-map.ts` only. If the app uses one key per variant, register each; if one key with variant param, single registration. Follow existing app convention.
|
|
25
|
-
-
|
|
25
|
+
- Prefer `sitecore-tools:generate-map` to keep the map in sync with `src/components/`.
|
|
26
26
|
|
|
27
27
|
## Stop Conditions
|
|
28
28
|
|
|
@@ -21,6 +21,8 @@ npm run type-check # Run TypeScript compiler
|
|
|
21
21
|
|
|
22
22
|
**Environment:** Copy `.env.example` to `.env.local` and set Sitecore API endpoint, key, default site, and language. Never commit `.env` or `.env.local`.
|
|
23
23
|
|
|
24
|
+
**Component map:** `.sitecore/component-map.ts` is auto-generated from `src/components/` during `npm run dev` (watch) and `npm run build`. No manual action needed; the generator scans `src/components/` and creates entries for all Sitecore-registered components.
|
|
25
|
+
|
|
24
26
|
---
|
|
25
27
|
|
|
26
28
|
## Application Structure (Pages Router)
|
|
@@ -73,7 +75,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
|
|
|
73
75
|
|
|
74
76
|
### More (component map, editing, env)
|
|
75
77
|
|
|
76
|
-
- **Component map:** `.sitecore/component-map.ts` —
|
|
78
|
+
- **Component map:** `.sitecore/component-map.ts` — Lists every Sitecore component the layout can render, the map is auto-generated from `src/components/`. Do not edit manually unless needed. Used by `getComponentData` and by the editing API routes.
|
|
77
79
|
- **Editing/preview:** Use `context.preview` and `context.previewData` in the catch-all page; when in preview, use `client.getPreview(context.previewData)` or `client.getDesignLibraryData(context.previewData)`. Editing API routes: `src/pages/api/editing/config.ts`, `render.ts`, `feaas/render.ts`.
|
|
78
80
|
- **Env:** All config via environment variables in `sitecore.config.ts`. Document vars in `.env.example` (or `.env.remote.example` / `.env.container.example`); never commit `.env` or `.env.local`.
|
|
79
81
|
|
|
@@ -121,7 +123,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
|
|
|
121
123
|
|
|
122
124
|
### Component map and layout
|
|
123
125
|
|
|
124
|
-
- **Component map:** `.sitecore/component-map.ts` —
|
|
126
|
+
- **Component map:** `.sitecore/component-map.ts` — Lists every Sitecore component the layout can render, the map is auto-generated from `src/components/`. Do not edit manually unless needed.
|
|
125
127
|
- **Layout:** `Layout.tsx` renders page layout and placeholders; `Providers` wrap component props and page context; `Bootstrap` handles site name and preview mode.
|
|
126
128
|
- **404 / 500 / _error:** When the catch-all returns `notFound: true` (no page), Next.js renders `404.tsx`. When the server returns 500, Next.js renders `500.tsx`. Both can optionally fetch and show Sitecore error content via `client.getErrorPage(ErrorPage.NotFound)` / `ErrorPage.InternalServerError` in their getStaticProps (when `scConfig.generateStaticPaths`); otherwise they show a simple fallback. `_error.tsx` is Next.js's error boundary for uncaught errors (client and server); it does not fetch from Sitecore.
|
|
127
129
|
|
|
@@ -132,7 +134,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
|
|
|
132
134
|
- **Quick checks:** If path or locale is wrong, ensure you use `extractPath(context)` and `context.locale` (from getStaticProps/getServerSideProps); do not assume path or locale from elsewhere. Keep the proxy chain order (Multisite → Redirects → Personalize).
|
|
133
135
|
- **Security:** Use only environment variables in `sitecore.config.ts`; never hardcode API keys, editing secret, or host URLs. Do not expose secrets in client-side code or in logs. Validate and sanitize user input at boundaries.
|
|
134
136
|
- **Performance:** Keep middleware lightweight; use the proxy `skip` callback and `matcher` so middleware does not run on `/api`, `_next`, static files, or health checks. Use `revalidate` in getStaticProps for ISR where appropriate. Prefer server-side data fetching for Sitecore content.
|
|
135
|
-
- **Sitecore patterns:** Use SDK field components (`<Text>`, `<RichText>`, `<Image>`) and validate field existence before render.
|
|
137
|
+
- **Sitecore patterns:** Use SDK field components (`<Text>`, `<RichText>`, `<Image>`) and validate field existence before render. Regenerate `.sitecore/component-map.ts` with `npm run sitecore-tools:generate-map` or `npm run sitecore-tools:generate-map:watch`; edit the map manually only when the generator cannot handle the change. Keep the single Sitecore client instance in `lib/sitecore-client.ts` and pass it (or use it) in API routes and getStaticProps/getServerSideProps.
|
|
136
138
|
- **Consistency:** Follow the existing patterns in `[[...path]].tsx`, `_app.tsx`, and API routes. When adding API routes, add the corresponding rewrite in `next.config.js` and keep the middleware matcher in sync.
|
|
137
139
|
|
|
138
140
|
---
|
|
@@ -164,7 +166,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
|
|
|
164
166
|
|
|
165
167
|
## Example agent tasks
|
|
166
168
|
|
|
167
|
-
- **Add a new Sitecore component:** Create the component under `src/components
|
|
169
|
+
- **Add a new Sitecore component:** Create the component under `src/components/` (map regenerates automatically during `npm run dev`; otherwise run `npm run sitecore-tools:generate-map`), and ensure it is rendered in the layout/placeholder as in existing components.
|
|
168
170
|
- **Add an API route:** Create the route under `src/pages/api/`, add a rewrite in `next.config.js` if the route should be reached from a public URL (e.g. `/my-path` → `/api/my-handler`), and ensure the proxy `matcher` in `proxy.ts` still excludes it (or add the path to the matcher exclusions if needed).
|
|
169
171
|
|
|
170
172
|
---
|
|
@@ -177,7 +179,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
|
|
|
177
179
|
|
|
178
180
|
**Edit with care:** `next.config.js` (rewrites, i18n), `sitecore.config.ts` (env only), `proxy.ts` (matcher and proxy order). When adding API routes or rewrites, keep middleware `matcher` and rewrite rules consistent.
|
|
179
181
|
|
|
180
|
-
**Focus on:** `src/pages/`, `src/components/`, `src/lib/`, `Layout.tsx`, `Providers.tsx`, `sitecore.config.ts`, `next.config.js`, `proxy.ts
|
|
182
|
+
**Focus on:** `src/pages/`, `src/components/`, `src/lib/`, `Layout.tsx`, `Providers.tsx`, `sitecore.config.ts`, `next.config.js`, `proxy.ts`. `.sitecore/component-map.ts` is auto-generated — do not edit manually.
|
|
181
183
|
|
|
182
184
|
---
|
|
183
185
|
|
|
@@ -16,11 +16,11 @@ Grouping related capabilities makes it easier to know which area of the app appl
|
|
|
16
16
|
|
|
17
17
|
### content-sdk-component-scaffold
|
|
18
18
|
|
|
19
|
-
Creating new Sitecore components: file structure, props interface, and placement under `src/components/`. Use when adding a new component from scratch.
|
|
19
|
+
Creating new Sitecore components: file structure, props interface, and placement under `src/components/`. Use when adding a new component from scratch. Map regenerates automatically during `npm run dev`; run `npm run sitecore-tools:generate-map` if dev is not running.
|
|
20
20
|
|
|
21
21
|
### content-sdk-component-registration
|
|
22
22
|
|
|
23
|
-
Registering components in `.sitecore/component-map.ts` only. Required so layout and editing can resolve and render components. Used by getComponentData and editing API routes.
|
|
23
|
+
Registering components in `.sitecore/component-map.ts` only. Required so layout and editing can resolve and render components. Regenerate `.sitecore/component-map.ts` with `npm run sitecore-tools:generate-map`; edit the map manually only when the generator cannot handle the change. Used by getComponentData and editing API routes.
|
|
24
24
|
|
|
25
25
|
### content-sdk-editing-safe-rendering
|
|
26
26
|
|
|
@@ -56,7 +56,7 @@ Sitemap and robots: `src/pages/api/sitemap.ts` and `src/pages/api/robots.ts` wit
|
|
|
56
56
|
|
|
57
57
|
### content-sdk-component-variants
|
|
58
58
|
|
|
59
|
-
Component variants: different renderings or data-driven variants of the same component type. Use when one component has multiple presentations.
|
|
59
|
+
Component variants: different renderings or data-driven variants of the same component type. Use when one component has multiple presentations. Regenerate the component map; getComponentData resolves props.
|
|
60
60
|
|
|
61
61
|
### content-sdk-troubleshoot-editing
|
|
62
62
|
|
package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-registration/SKILL.md
CHANGED
|
@@ -16,11 +16,11 @@ Register components in the Sitecore component maps so the layout and editing pip
|
|
|
16
16
|
|
|
17
17
|
## How to perform
|
|
18
18
|
|
|
19
|
-
-
|
|
19
|
+
- The component maps at `.sitecore/component-map.ts` and `.sitecore/component-map.client.ts` are generated from `src/components/` during `npm run dev` or `npm run build` (each component goes to the server or client map based on `'use client'`); run `npm run sitecore-tools:generate-map` to refresh them manually, and edit the maps only when the generator cannot handle your case.
|
|
20
20
|
|
|
21
21
|
## Hard Rules
|
|
22
22
|
|
|
23
|
-
- Every component rendered from Sitecore layout must be registered.
|
|
23
|
+
- Every component rendered from Sitecore layout must be registered. Prefer the project's `sitecore-tools:generate-map` script to keep the maps in sync with `src/components/`. Do not hand-edit generated map entries unless necessary.
|
|
24
24
|
- **Server components** (no `'use client'`): Register in `.sitecore/component-map.ts` only.
|
|
25
25
|
- **Client components** (`'use client'`): Register in `.sitecore/component-map.client.ts` only. Editing API routes use both maps (e.g. `clientComponents` from the client map).
|
|
26
26
|
- Use consistent component names (same key in map as used in layout). Follow existing naming in the maps.
|
package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-scaffold/SKILL.md
CHANGED
|
@@ -16,16 +16,18 @@ Scaffold new Sitecore components so they integrate with the layout and editing p
|
|
|
16
16
|
## How to perform
|
|
17
17
|
|
|
18
18
|
- Create a new file under `src/components/` (or existing feature folder). Define props (fields, params), export a single default component.
|
|
19
|
-
- Decide Server vs Client: default Server; add `'use client'` only
|
|
20
|
-
-
|
|
19
|
+
- Decide Server vs Client: default Server; add `'use client'` only for hooks or event handlers.
|
|
20
|
+
- **Map:** Regenerates automatically during `npm run dev` and `npm run build`; otherwise run `npm run sitecore-tools:generate-map` (see content-sdk-component-registration).
|
|
21
|
+
- Run `npm run build` to verify.
|
|
21
22
|
|
|
22
23
|
## Hard Rules
|
|
23
24
|
|
|
24
25
|
- Place components under `src/components/`. Use existing folder conventions.
|
|
26
|
+
- Prefer `npm run sitecore-tools:generate-map` to regenerate the component maps instead of hand-editing them. Only manually register the component if the generator cannot handle the change.
|
|
25
27
|
- Define a props interface with the component's fields (e.g. `fields: { title: Field; ... }`) and any params. Use types from `@sitecore-content-sdk/react` or the app's types.
|
|
26
28
|
- Export a single default component; one component per file unless the app pattern differs.
|
|
27
|
-
- **Server vs Client:** Use Server Components by default. Add `'use client'` only for interactivity (hooks, event handlers).
|
|
28
|
-
-
|
|
29
|
+
- **Server vs Client:** Use Server Components by default. Add `'use client'` only for interactivity (hooks, event handlers). The generator places Server components in `.sitecore/component-map.ts` and Client components in `.sitecore/component-map.client.ts`.
|
|
30
|
+
- Ensure the component appears in the correct map after regeneration (or update the map manually only if the generator cannot handle the case) before considering the task complete (see content-sdk-component-registration).
|
|
29
31
|
|
|
30
32
|
## Stop Conditions
|
|
31
33
|
|
package/dist/templates/nextjs-app-router/.agents/skills/content-sdk-component-variants/SKILL.md
CHANGED
|
@@ -22,7 +22,7 @@ One component definition can have multiple presentations or data-driven variants
|
|
|
22
22
|
- Prefer a single component registration that accepts variant/style data (e.g. params or fields) and branches internally, over multiple map entries for the same logical component unless the app pattern uses separate registrations per variant.
|
|
23
23
|
- Use props (fields, params) from layout to decide variant; do not rely on global state or URL for variant selection when data comes from Sitecore.
|
|
24
24
|
- Register in `.sitecore/component-map.ts` (Server) or `.sitecore/component-map.client.ts` (Client) as appropriate. If the app uses one key per variant, register each; if one key with variant param, single registration. Follow existing app convention.
|
|
25
|
-
-
|
|
25
|
+
- Prefer `sitecore-tools:generate-map` to keep the maps in sync with `src/components/`.
|
|
26
26
|
|
|
27
27
|
## Stop Conditions
|
|
28
28
|
|
|
@@ -21,6 +21,8 @@ npm run type-check # Run TypeScript compiler
|
|
|
21
21
|
|
|
22
22
|
**Environment:** Copy `.env.example` to `.env.local` and set Sitecore API endpoint, key, default site, and language. Never commit `.env` or `.env.local`.
|
|
23
23
|
|
|
24
|
+
**Component maps:** `.sitecore/component-map.ts` (Server) and `.sitecore/component-map.client.ts` (Client) are auto-generated from `src/components/` during `npm run dev` (watch) and `npm run build`. No manual action needed; the generator scans `src/components/` and creates entries in the appropriate map (Server vs Client based on `'use client'`).
|
|
25
|
+
|
|
24
26
|
---
|
|
25
27
|
|
|
26
28
|
## Application Structure (App Router)
|
|
@@ -82,7 +84,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
|
|
|
82
84
|
|
|
83
85
|
### More (component maps, editing, env)
|
|
84
86
|
|
|
85
|
-
- **Component maps:** `.sitecore/component-map.ts` (Server) and `.sitecore/component-map.client.ts` (Client)
|
|
87
|
+
- **Component maps:** `.sitecore/component-map.ts` (Server) and `.sitecore/component-map.client.ts` (Client) — Lists every Sitecore component the layout can render, the maps are auto-generated from `src/components/`. Do not edit manually unless needed.
|
|
86
88
|
- **Editing/preview:** Use `draftMode()` in Server Components; when enabled, use `client.getPreview(searchParams)` or `client.getDesignLibraryData(searchParams)`. Editing API routes live under `src/app/api/editing/`.
|
|
87
89
|
- **Env:** All config via environment variables in `sitecore.config.ts`. Document vars in `.env.example` (or `.env.remote.example` / `.env.container.example`); never commit `.env` or `.env.local`.
|
|
88
90
|
|
|
@@ -144,7 +146,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
|
|
|
144
146
|
|
|
145
147
|
### Component maps and layout
|
|
146
148
|
|
|
147
|
-
- **Server/client components:** `.sitecore/component-map.ts` (Server)
|
|
149
|
+
- **Server/client components:** `.sitecore/component-map.ts` (Server) and `.sitecore/component-map.client.ts` (Client) — Lists every Sitecore component the layout can render, the maps are auto-generated from `src/components/`. Do not edit manually unless needed.
|
|
148
150
|
- **Layout:** `Layout.tsx` renders page layout and placeholders; `Providers` wrap page and component context; `Bootstrap` in `[site]/layout.tsx` receives `siteName={site}` and preview state.
|
|
149
151
|
|
|
150
152
|
---
|
|
@@ -154,7 +156,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
|
|
|
154
156
|
- **Quick checks:** If locale or dictionary is wrong, ensure `setRequestLocale(\`${site}_${locale}\`)` is called at the top of the page and `src/i18n/request.ts` parses `requestLocale` and calls `client.getDictionary`. If not-found doesn't show Sitecore content, use `parseRewriteHeader(headers())` for site/locale. Always `await params` (Next.js 15+).
|
|
155
157
|
- **Security:** Use only environment variables in `sitecore.config.ts`; never hardcode API keys, editing secret, or host URLs. Do not expose secrets in client-side code or in logs. Validate and sanitize user input at boundaries.
|
|
156
158
|
- **Performance:** Keep middleware lightweight; use the proxy `matcher` so it does not run on API routes, `_next`, sitemap, robots, or static assets. Use Server Components for data fetching; add `'use client'` only where interactivity is needed. Use `generateStaticParams` and caching as in the existing page.
|
|
157
|
-
- **Sitecore patterns:** Use SDK field components (`<Text>`, `<RichText>`, `<Image>`) and validate field existence before render.
|
|
159
|
+
- **Sitecore patterns:** Use SDK field components (`<Text>`, `<RichText>`, `<Image>`) and validate field existence before render. Regenerate the component maps with `npm run sitecore-tools:generate-map` or `npm run sitecore-tools:generate-map:watch`; edit the maps manually only when the generator cannot handle the change. Use the single Sitecore client in `lib/sitecore-client.ts` for all data fetching.
|
|
158
160
|
- **Consistency:** Follow the existing patterns in `[site]/[locale]/[[...path]]/page.tsx`, layout hierarchy, `i18n/request.ts` (site_locale), and API route handlers. When adding routes or rewrites, keep the middleware matcher and next-intl config in sync.
|
|
159
161
|
|
|
160
162
|
---
|
|
@@ -188,7 +190,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
|
|
|
188
190
|
|
|
189
191
|
## Example agent tasks
|
|
190
192
|
|
|
191
|
-
- **Add a new Sitecore component:** Create the component under `src/components
|
|
193
|
+
- **Add a new Sitecore component:** Create the component under `src/components/` (maps regenerate automatically during `npm run dev`; otherwise run `npm run sitecore-tools:generate-map`), and ensure it is rendered in the layout/placeholder as in existing components.
|
|
192
194
|
- **Add an API route:** Create the route under `src/app/api/` (e.g. `src/app/api/my-route/route.ts`), add a rewrite in `next.config.ts` if the route should be reached from a public URL, and ensure the proxy `matcher` in `proxy.ts` still excludes it (e.g. `api/` is already excluded).
|
|
193
195
|
|
|
194
196
|
---
|
|
@@ -201,7 +203,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
|
|
|
201
203
|
|
|
202
204
|
**Edit with care:** `next.config.ts` (rewrites, next-intl plugin), `sitecore.config.ts` (env only), `proxy.ts` (matcher and proxy order), `src/i18n/routing.ts` and `request.ts`. When adding routes or rewrites, keep middleware `matcher` and rewrite rules consistent.
|
|
203
205
|
|
|
204
|
-
**Focus on:** `src/app/`, `src/components/`, `src/lib/`, `src/i18n/`, `Layout.tsx`, `Providers.tsx`, `sitecore.config.ts`, `next.config.ts`, `proxy.ts
|
|
206
|
+
**Focus on:** `src/app/`, `src/components/`, `src/lib/`, `src/i18n/`, `Layout.tsx`, `Providers.tsx`, `sitecore.config.ts`, `next.config.ts`, `proxy.ts`. `.sitecore/component-map.ts` and `.sitecore/component-map.client.ts` are auto-generated — do not edit manually.
|
|
205
207
|
|
|
206
208
|
---
|
|
207
209
|
|
|
@@ -16,11 +16,11 @@ Grouping related capabilities makes it easier to know which area of the app appl
|
|
|
16
16
|
|
|
17
17
|
### content-sdk-component-scaffold
|
|
18
18
|
|
|
19
|
-
Creating new Sitecore components: file structure, props interface, and placement under `src/components/`. Use when adding a new component from scratch. In App Router, decide Server vs Client
|
|
19
|
+
Creating new Sitecore components: file structure, props interface, and placement under `src/components/`. Use when adding a new component from scratch. Map regenerates automatically during `npm run dev`; run `npm run sitecore-tools:generate-map` if dev is not running. In App Router, decide Server vs Client (`'use client'`) so the generator places the entry in the correct map.
|
|
20
20
|
|
|
21
21
|
### content-sdk-component-registration
|
|
22
22
|
|
|
23
|
-
Registering components in `.sitecore/component-map.ts` (Server) and `.sitecore/component-map.client.ts` (Client). Required so layout and editing can resolve and render components. App Router has separate server and client maps.
|
|
23
|
+
Registering components in `.sitecore/component-map.ts` (Server) and `.sitecore/component-map.client.ts` (Client). Required so layout and editing can resolve and render components. Regenerate with `npm run sitecore-tools:generate-map`; edit the maps manually only when the generator cannot handle the change. App Router has separate server and client maps.
|
|
24
24
|
|
|
25
25
|
### content-sdk-editing-safe-rendering
|
|
26
26
|
|
|
@@ -56,7 +56,7 @@ Sitemap and robots: `src/app/api/sitemap/route.ts` and `src/app/api/robots/route
|
|
|
56
56
|
|
|
57
57
|
### content-sdk-component-variants
|
|
58
58
|
|
|
59
|
-
Component variants: different renderings or data-driven variants of the same component type. Use when one component has multiple presentations.
|
|
59
|
+
Component variants: different renderings or data-driven variants of the same component type. Use when one component has multiple presentations. Regenerate the component maps.
|
|
60
60
|
|
|
61
61
|
### content-sdk-troubleshoot-editing
|
|
62
62
|
|
|
@@ -16,11 +16,11 @@ Register components in the Sitecore component maps so the layout and editing pip
|
|
|
16
16
|
|
|
17
17
|
## How to perform
|
|
18
18
|
|
|
19
|
-
-
|
|
19
|
+
- The component maps at `.sitecore/component-map.ts` and `.sitecore/component-map.client.ts` are generated from `src/components/` during `npm run dev` or `npm run build` (each component goes to the server or client map based on `'use client'`); run `npm run sitecore-tools:generate-map` to refresh them manually, and edit the maps only when the generator cannot handle your case.
|
|
20
20
|
|
|
21
21
|
## Hard Rules
|
|
22
22
|
|
|
23
|
-
- Every component rendered from Sitecore layout must be registered.
|
|
23
|
+
- Every component rendered from Sitecore layout must be registered. Prefer the project's `sitecore-tools:generate-map` script to keep the maps in sync with `src/components/`. Do not hand-edit generated map entries unless necessary.
|
|
24
24
|
- **Server components** (no `'use client'`): Register in `.sitecore/component-map.ts` only.
|
|
25
25
|
- **Client components** (`'use client'`): Register in `.sitecore/component-map.client.ts` only. Editing API routes use both maps (e.g. `clientComponents` from the client map).
|
|
26
26
|
- Use consistent component names (same key in map as used in layout). Follow existing naming in the maps.
|
|
@@ -16,17 +16,19 @@ Scaffold new Sitecore components so they integrate with the layout and editing p
|
|
|
16
16
|
## How to perform
|
|
17
17
|
|
|
18
18
|
- Create a new file under `src/components/` (or existing feature folder). Define props (fields, params), export a single default component.
|
|
19
|
-
- Decide Server vs Client: default Server; add `'use client'` only
|
|
20
|
-
-
|
|
19
|
+
- Decide Server vs Client: default Server; add `'use client'` only for hooks or event handlers.
|
|
20
|
+
- **Map:** Regenerates automatically during `npm run dev` and `npm run build`; otherwise run `npm run sitecore-tools:generate-map` (see content-sdk-component-registration).
|
|
21
|
+
- Run `npm run build` to verify.
|
|
21
22
|
|
|
22
23
|
## Hard Rules
|
|
23
24
|
|
|
24
25
|
- Place components under `src/components/`. Use existing folder conventions.
|
|
26
|
+
- Prefer `npm run sitecore-tools:generate-map` to regenerate the component maps instead of hand-editing them. Only manually register the component if the generator cannot handle the change.
|
|
25
27
|
- Define a props interface with the component's fields (e.g. `fields: { title: Field; ... }`) and any params. Use types from `@sitecore-content-sdk/react` or the app's types.
|
|
26
28
|
- Export a single default component; one component per file unless the app pattern differs.
|
|
27
|
-
- **Server vs Client:** Use Server Components by default. Add `'use client'` only for interactivity (hooks, event handlers).
|
|
29
|
+
- **Server vs Client:** Use Server Components by default. Add `'use client'` only for interactivity (hooks, event handlers). The generator places Server components in `.sitecore/component-map.ts` and Client components in `.sitecore/component-map.client.ts`.
|
|
28
30
|
- Do not fetch Sitecore data inside the component (no `getSitecorePage` / `client.getPage` calls). Component data comes from the cached page read at the page level.
|
|
29
|
-
-
|
|
31
|
+
- Ensure the component appears in the correct map after regeneration (or update the map manually only if the generator cannot handle the case) before considering the task complete (see content-sdk-component-registration).
|
|
30
32
|
|
|
31
33
|
## Stop Conditions
|
|
32
34
|
|
|
@@ -22,7 +22,7 @@ One component definition can have multiple presentations or data-driven variants
|
|
|
22
22
|
- Prefer a single component registration that accepts variant/style data (e.g. params or fields) and branches internally, over multiple map entries for the same logical component unless the app pattern uses separate registrations per variant.
|
|
23
23
|
- Use props (fields, params) from layout to decide variant; do not rely on global state or URL for variant selection when data comes from Sitecore.
|
|
24
24
|
- Register in `.sitecore/component-map.ts` (Server) or `.sitecore/component-map.client.ts` (Client) as appropriate. If the app uses one key per variant, register each; if one key with variant param, single registration. Follow existing app convention.
|
|
25
|
-
-
|
|
25
|
+
- Prefer `sitecore-tools:generate-map` to keep the maps in sync with `src/components/`.
|
|
26
26
|
|
|
27
27
|
## Stop Conditions
|
|
28
28
|
|
|
@@ -23,6 +23,8 @@ npm run type-check # Run TypeScript compiler
|
|
|
23
23
|
|
|
24
24
|
**Environment:** Copy `.env.example` to `.env.local` and set Sitecore API endpoint, key, default site, language, and `SITECORE_REVALIDATE_SECRET` (used by `POST /api/revalidate`). Never commit `.env` or `.env.local`.
|
|
25
25
|
|
|
26
|
+
**Component maps:** `.sitecore/component-map.ts` (Server) and `.sitecore/component-map.client.ts` (Client) are auto-generated from `src/components/` during `npm run dev` (watch) and `npm run build`. No manual action needed; the generator scans `src/components/` and creates entries in the appropriate map (Server vs Client based on `'use client'`).
|
|
27
|
+
|
|
26
28
|
---
|
|
27
29
|
|
|
28
30
|
## Application Structure (App Router + Cache Components)
|
|
@@ -110,7 +112,7 @@ These are the main head-app–specific concepts. Details are in the sections bel
|
|
|
110
112
|
|
|
111
113
|
### More (component maps, editing, env)
|
|
112
114
|
|
|
113
|
-
- **Component maps:** `.sitecore/component-map.ts` (Server) and `.sitecore/component-map.client.ts` (Client)
|
|
115
|
+
- **Component maps:** `.sitecore/component-map.ts` (Server) and `.sitecore/component-map.client.ts` (Client) — Lists every Sitecore component the layout can render, the maps are auto-generated from `src/components/`. Do not edit manually unless needed.
|
|
114
116
|
- **Editing/preview:** Use `draftMode()` in Server Components; when enabled, use `client.getPreview(searchParams)` or `client.getDesignLibraryData(searchParams)` **directly** (do not route preview through the cache helpers). Editing API routes live under `src/app/api/editing/`.
|
|
115
117
|
- **Env:** All config via environment variables in `sitecore.config.ts`. Document vars in `.env.example` (or `.env.remote.example` / `.env.container.example`); never commit `.env` or `.env.local`. `SITECORE_REVALIDATE_SECRET` is optional (see `.env.*.example` comments).
|
|
116
118
|
|
|
@@ -189,7 +191,7 @@ This template ships **two** not-found components and a segment layout that ties
|
|
|
189
191
|
|
|
190
192
|
### Component maps and layout
|
|
191
193
|
|
|
192
|
-
- **Server/client components:** `.sitecore/component-map.ts` (Server)
|
|
194
|
+
- **Server/client components:** `.sitecore/component-map.ts` (Server) and `.sitecore/component-map.client.ts` (Client) — Lists every Sitecore component the layout can render, the maps are auto-generated from `src/components/`. Do not edit manually unless needed.
|
|
193
195
|
- **Layout:** `Layout.tsx` renders page layout and placeholders; `Providers` wrap page and component context; `Bootstrap` in `[site]/layout.tsx` receives `siteName={site}` and preview state.
|
|
194
196
|
|
|
195
197
|
---
|
|
@@ -199,7 +201,7 @@ This template ships **two** not-found components and a segment layout that ties
|
|
|
199
201
|
- **Quick checks:** If locale or dictionary is wrong, ensure `setRequestLocale(\`${site}_${locale}\`)` is called at the top of the page and `src/i18n/request.ts` parses `requestLocale` and calls `getSitecoreDictionary`. If a content change does not appear, verify the webhook posted to `POST /api/revalidate` with the right secret and check the tag families (`sc:route`, `sc:item`, `sc:dict`) returned by the cache helpers.
|
|
200
202
|
- **Security:** Use only environment variables in `sitecore.config.ts`; never hardcode API keys, editing secret, or `SITECORE_REVALIDATE_SECRET`. Do not expose secrets in client-side code or logs. Validate and sanitize user input at boundaries.
|
|
201
203
|
- **Performance:** Keep middleware lightweight; use the proxy `matcher` so it does not run on `/api/*`, `_next`, sitemap, robots, or static assets. Use Server Components for data fetching and the cache helpers under `'use cache'` so cached payloads carry the right tags. Use `generateStaticParams` and caching as in the existing page.
|
|
202
|
-
- **Sitecore patterns:** Use SDK field components (`<Text>`, `<RichText>`, `<Image>`) and validate field existence before render.
|
|
204
|
+
- **Sitecore patterns:** Use SDK field components (`<Text>`, `<RichText>`, `<Image>`) and validate field existence before render. Regenerate the component maps with `npm run sitecore-tools:generate-map` or `npm run sitecore-tools:generate-map:watch`; edit the maps manually only when the generator cannot handle the change. Use the cache helpers in `src/lib/cache/` for all non-preview Sitecore reads so tags stay consistent across the app.
|
|
203
205
|
- **Consistency:** Follow the existing patterns in `[site]/[locale]/[[...path]]/page.tsx`, `not-found.tsx`, `i18n/request.ts` (site_locale + `getSitecoreDictionary`), and API route handlers. When adding routes or rewrites, keep the middleware matcher and next-intl config in sync.
|
|
204
206
|
|
|
205
207
|
---
|
|
@@ -238,7 +240,7 @@ This template ships **two** not-found components and a segment layout that ties
|
|
|
238
240
|
|
|
239
241
|
## Example agent tasks
|
|
240
242
|
|
|
241
|
-
- **Add a new Sitecore component:** Create the component under `src/components
|
|
243
|
+
- **Add a new Sitecore component:** Create the component under `src/components/` (maps regenerate automatically during `npm run dev`; otherwise run `npm run sitecore-tools:generate-map`), and ensure it is rendered in the layout/placeholder as in existing components.
|
|
242
244
|
- **Add an API route:** Create the route under `src/app/api/` (e.g. `src/app/api/my-route/route.ts`), add a rewrite in `next.config.ts` if the route should be reached from a public URL, and ensure the proxy `matcher` in `proxy.ts` still excludes it (e.g. `api/` is already excluded). If the route returns cached data, decide whether to use `'use cache'` with a Sitecore tag and how it should be invalidated.
|
|
243
245
|
- **Add a new cache helper:** Add a file under `src/lib/cache/`. Inside the function, declare `'use cache';`, call the SDK client, compute Sitecore tags via the SDK helpers (`collectSitecorePageCacheTags`, `buildSitecoreDictionaryCacheTag`, etc.), and call `cacheTag(tag)` for each one. Match the style of `get-sitecore-page.ts`.
|
|
244
246
|
|
|
@@ -252,7 +254,7 @@ This template ships **two** not-found components and a segment layout that ties
|
|
|
252
254
|
|
|
253
255
|
**Edit with care:** `next.config.ts` (`cacheComponents: true`, rewrites, next-intl plugin), `sitecore.config.ts` (env only; keep dictionary cache disabled), `proxy.ts` (matcher and proxy order), `src/i18n/routing.ts` and `request.ts`, `src/lib/cache/*` (tag computation). When adding routes or rewrites, keep middleware `matcher` and rewrite rules consistent.
|
|
254
256
|
|
|
255
|
-
**Focus on:** `src/app/`, `src/components/`, `src/lib/`, `src/lib/cache/`, `src/i18n/`, `Layout.tsx`, `Providers.tsx`, `sitecore.config.ts`, `next.config.ts`, `proxy.ts
|
|
257
|
+
**Focus on:** `src/app/`, `src/components/`, `src/lib/`, `src/lib/cache/`, `src/i18n/`, `Layout.tsx`, `Providers.tsx`, `sitecore.config.ts`, `next.config.ts`, `proxy.ts`. `.sitecore/component-map.ts` and `.sitecore/component-map.client.ts` are auto-generated — do not edit manually.
|
|
256
258
|
|
|
257
259
|
---
|
|
258
260
|
|
|
@@ -16,11 +16,11 @@ Grouping related capabilities makes it easier to know which area of the app appl
|
|
|
16
16
|
|
|
17
17
|
### content-sdk-component-scaffold
|
|
18
18
|
|
|
19
|
-
Creating new Sitecore components: file structure, props interface, and placement under `src/components/`. Use when adding a new component from scratch. In App Router, decide Server vs Client
|
|
19
|
+
Creating new Sitecore components: file structure, props interface, and placement under `src/components/`. Use when adding a new component from scratch. Map regenerates automatically during `npm run dev`; run `npm run sitecore-tools:generate-map` if dev is not running. In App Router, decide Server vs Client (`'use client'`) so the generator places the entry in the correct map.
|
|
20
20
|
|
|
21
21
|
### content-sdk-component-registration
|
|
22
22
|
|
|
23
|
-
Registering components in `.sitecore/component-map.ts` (Server) and `.sitecore/component-map.client.ts` (Client). Required so layout and editing can resolve and render components. App Router has separate server and client maps.
|
|
23
|
+
Registering components in `.sitecore/component-map.ts` (Server) and `.sitecore/component-map.client.ts` (Client). Required so layout and editing can resolve and render components. Regenerate with `npm run sitecore-tools:generate-map`; edit the maps manually only when the generator cannot handle the change. App Router has separate server and client maps.
|
|
24
24
|
|
|
25
25
|
### content-sdk-editing-safe-rendering
|
|
26
26
|
|
|
@@ -56,7 +56,7 @@ Sitemap and robots: `src/app/api/sitemap/route.ts` and `src/app/api/robots/route
|
|
|
56
56
|
|
|
57
57
|
### content-sdk-component-variants
|
|
58
58
|
|
|
59
|
-
Component variants: different renderings or data-driven variants of the same component type. Use when one component has multiple presentations.
|
|
59
|
+
Component variants: different renderings or data-driven variants of the same component type. Use when one component has multiple presentations. Regenerate the component maps.
|
|
60
60
|
|
|
61
61
|
### content-sdk-troubleshoot-editing
|
|
62
62
|
|