Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

content-sdk-pages-router-component-registration

/content-sdk-pages-router-component-registration

Rejestruje komponenty w wygenerowanym pliku .sitecore/component-map.ts aplikacji Pages Router Content SDK, bez ręcznej edycji mapy.

Licencja
Apache-2.0
Ostatnia zmiana repozytorium
05.11.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
2
Przestarzałość

Brak sygnałów. Repozytorium zmienione 05.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

Co robi i kiedy

Rejestruje komponenty w wygenerowanym pliku .sitecore/component-map.ts aplikacji Pages Router Content SDK, bez ręcznej edycji mapy.

Oryginalny opis (EN)

Registers components in the generated .sitecore/component-map.ts of a Content SDK Pages Router app (regenerate, never hand-edit). Use when adding a component or layout or the editor cannot find one. Not App Router.

Jak działa

  1. When to use
  2. How to perform
  3. Worked example
  4. Hard Rules
  5. Stop Conditions
  6. References
Sekcje z nagłówków SKILL.md, w oryginale · 54 linii, 469 słów
Podgląd SKILL.md
---
name: content-sdk-pages-router-component-registration
description: "Registers components in the generated .sitecore/component-map.ts of a Content SDK Pages Router app (regenerate, never hand-edit). Use when adding a component or layout or the editor cannot find one. Not App Router."
license: Apache-2.0
compatibility: "Requires @sitecore-content-sdk/* packages, Next.js 13+, and access to a SitecoreAI Edge endpoint with valid Edge context values (SITECORE_EDGE_CONTEXT_ID etc.)."
metadata:
  author: Christian Hahn
  version: "0.6.3"
  upstream_repo: Sitecore/content-sdk
  upstream_commit: 70eccc43
  upstream_name: content-sdk-component-registration
  upstream_path: packages/create-content-sdk-app/src/templates/nextjs/.agents/skills/content-sdk-component-registration/SKILL.md
---

# Content SDK Component Registration (Pages Router)

Register components in the Sitecore component map so the layout and editing pipeline can resolve and render them. This app has a **single** map: `.sitecore/component-map.ts`.

## When to use

- After scaffolding or adding a new Sitecore component (must be registered).
- User reports a component not rendering, "component not found," or layout/placeholder showing raw component name.
- Task involves `.sitecore/component-map.ts`.
- User asks how to register a component or fix component resolution.

## How to perform

- **The map is GENERATED, not hand-written.** `.sitecore/component-map.ts` is produced from `src/components/` by `sitecore-tools project component generate-map`, which the scaffold wires into **both** `npm run dev` and `npm run build`, plus a `--watch` variant during dev. So the normal way to register a component is to **create the file in `src/components/` and re-run dev/build**.
- Refresh manually with `npm run sitecore-tools:generate-map`. Edit the map by hand only when the generator genuinely cannot express your case — and expect the next `dev`/`build` to overwrite it. The map is consumed by getComponentData and the editing API routes; keys must match the layout `componentName`.

## Worked example

Pages Router has ONE map (no `component-map.client.ts`) and no `componentType: 'client'` split. The key is the layout `componentName` (case-sensitive); each entry spreads the imported module.

```ts
// .sitecore/component-map.ts — the single Pages Router map
import { NextjsContentSdkComponent } from '@sitecore-content-sdk/nextjs';
import * as Promo from 'src/components/Promo/Promo';

export const componentMap = new Map<string, NextjsContentSdkComponent>([
  // ...built-ins from the scaffold (BYOCWrapper, FEaaSWrapper, Form) stay as-is...
  ['Promo', { ...Promo }],
]);

export default componentMap;
```

This map is consumed by `getComponentData(page.layout, context, components)` in `src/pages/[[...path]].tsx` and by the editing API routes (`src/pages/api/editing/config.ts`, `render.ts`, `feaas/render.ts`). A wrong/missing key renders `<MissingComponent>`.

## Hard Rules

- Every component rendered from Sitecore layout must be registered in `.sitecore/component-map.ts` — but achieve that by running `npm run sitecore-tools:generate-map` (or just `npm run dev` / `npm run build`), not by editing the map. Do not hand-edit generated entries unless the generator cannot handle the case.
- Component **names** come from the file/folder name, so renaming a component file renames its map key and breaks the layout binding. Rename deliberately and update the Sitecore rendering to match.
- 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`).
- Use consistent component names (same key in map as used in layout). Follow existing naming in the map.
- Do not remove or rename registrations without updating all references (layout, getComponentData, editing routes).

## Stop Conditions

- Stop if modifying the component map would break existing layout or editing; suggest a safe change or ask for confirmation.
- Do not edit `.sitecore/metadata.json` or import-map unless the task explicitly requires it.

## References

- [Content SDK skills overview](https://github.com/Chris1415/sitecore-skills-pocs#skills-by-cluster).
- [Official Content SDK docs](https://doc.sitecore.com/sai/en/developers/content-sdk/sitecore-content-sdk-for-sitecoreai.html).

Wersje

W bazie nie ma innych skilli o nazwie content-sdk-pages-router-component-registration.

Migawka bazy z 13.11.2026 · wersja paczki 535b87c46ba2 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 1 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.