Command Palette

Search for a command to run...

Назад к скиллам
скилл № 46727

content-sdk-component-variants

Multiple renderings of one component type; regenerate component map after changes.

БесплатноБез исполняемых скриптов
Sitecoreот Sitecore★ 39 звёзд на GitHub

Установить content-sdk-component-variants в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Component variants (Pages Router)

Detail: AGENTS-router-specifics.md#component-map-and-layout

When

  • One component type with multiple presentations or variants

Rules

  • Follow existing variant patterns in src/components/
  • Regenerate component map after changes

Lazy-loaded variants

Lazy (next/dynamic) components require a self-managed component map (see content-sdk-component-registration). Wrap the module with withVariants (from @sitecore-content-sdk/nextjs) and register the dynamic() result itself as the entry, so all SXA variants (named exports) are resolved without listing them:

// .sitecore/component-map.ts (self-managed)
import dynamic from 'next/dynamic';
import { withVariants } from '@sitecore-content-sdk/nextjs';

const Promo = dynamic(() => import('src/components/promo/Promo').then(withVariants));

// ...
['Promo', Promo],
  • withVariants renders the export matching rendering.params.FieldNames, or Default / default when no variant is requested; unknown variant → MissingComponent (never Default)
  • Without withVariants, a single component entry (e.g. dynamic(() => import('src/components/promo/Promo'))) ignores FieldNames and always renders itself, so a variant it does not implement is not reported as MissingComponent
  • Client-only rendering: dynamic(() => import('src/components/promo/Promo').then(withVariants), { ssr: false }) works the same way

Component-level data fetching (getComponentServerProps / getStaticProps)

The SDK finds these functions on the server through dynamicModule. Attach it to the dynamic() component, so the entry stays a single component and all variants are still resolved by withVariants:

const Promo = Object.assign(
  dynamic(() => import('src/components/promo/Promo').then(withVariants)), // optionally { ssr: false }
  { dynamicModule: () => import('src/components/promo/Promo') }
);

// ...
['Promo', Promo],
  • Object entries ({ Default: …, Banner: …, dynamicModule }) resolve only their listed keys: a missing variant renders MissingComponent (no fallback to Default)

Stop

  • Stop if variant rename would break layout without Sitecore update

Docs: Content SDK.

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл content-sdk-component-variants?

Multiple renderings of one component type; regenerate component map after changes.

Как установить скилл content-sdk-component-variants?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл content-sdk-component-variants запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить content-sdk-component-variants с