content-sdk-component-variants
Multiple renderings of one component type; regenerate component map after changes.
от 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],
withVariantsrenders the export matchingrendering.params.FieldNames, orDefault/defaultwhen no variant is requested; unknown variant → MissingComponent (neverDefault)- Without
withVariants, a single component entry (e.g.dynamic(() => import('src/components/promo/Promo'))) ignoresFieldNamesand 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 toDefault)
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), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…