content-sdk-component-variants
Multiple presentations per component; regenerate maps after changes.
от Sitecore★ 39 звёзд на GitHub
Установить content-sdk-component-variants в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Component variants (App Router + Cache Components)
Detail: AGENTS-router-specifics.md#component-maps-and-layout
When
- Component variants or alternate renderings
Rules
- Mirror existing variant patterns
- Regenerate component maps
Lazy-loaded variants
Lazy (next/dynamic) components require self-managed component maps (see content-sdk-component-registration). withVariants (from @sitecore-content-sdk/nextjs) resolves all SXA variants (named exports) of a lazily loaded module.
Server components: register the dynamic() result in .sitecore/component-map.ts:
const Promo = dynamic(() => import('src/components/promo/Promo').then(withVariants));
// ...
['Promo', Promo],
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 components: Next.js bundles every Client Component imported by the server map with the page, so dynamic() in the maps does not load it on demand. Register a small 'use client' wrapper in both maps instead, and keep the variant code in a separate file:
// src/components/promo/Promo.tsx: small wrapper, the only part bundled with the page
'use client';
import dynamic from 'next/dynamic';
import { withVariants } from '@sitecore-content-sdk/nextjs';
const PromoLazy = dynamic(() => import('./PromoVariants').then(withVariants));
export const Default = PromoLazy;
export const Banner = PromoLazy;
// .sitecore/component-map.ts
import * as Promo from 'src/components/promo/Promo';
['Promo', { ...Promo, componentType: 'client' }],
// .sitecore/component-map.client.ts
import * as Promo from 'src/components/promo/Promo';
['Promo', { ...Promo }],
src/components/promo/PromoVariants.tsxexports the variants (Default,Banner, …); it is loaded on demand- Export every variant name from the wrapper, pointing to the same lazy component;
withVariantsrenders the export matchingrendering.params.FieldNames(unknown variant → MissingComponent) - Equivalent without
withVariants: onedynamic()per variant in the wrapper, e.g.export const Banner = dynamic(() => import('./PromoVariants').then((mod) => mod.Banner)); - New variant: add the export to the variants file and its name to the wrapper
Client-only rendering (ssr: false)
- ❌ Never in
.sitecore/component-map.tsor.sitecore/component-map.client.ts: both maps are imported on the server (editing config route), so the build fails with`ssr: false` is not allowed with `next/dynamic` in Server Components - ✅ Pass it to
dynamic()in the'use client'wrapper; all variants work:const PromoLazy = dynamic(() => import('./PromoVariants').then(withVariants), { ssr: false });
Stop
- Stop if variant change breaks layout item without Sitecore update
Docs: Content SDK.
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл content-sdk-component-variants?
Multiple presentations per component; regenerate maps 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…