import type { Schemas } from "#shopware"; type ArrayElement = ArrayType extends readonly (infer ElementType)[] ? ElementType : never; export type UseCmsBlockReturn = { /** * Cms block content */ block: Schemas["CmsBlock"]; /** * Get slot content by slot name (identifier) * @example getSlotContent("main") */ getSlotContent(slotName: string): ArrayElement; }; /** * Composable to get cms block content * @public * @category CMS (Shopping Experiences) */ export function useCmsBlock( content: BLOCK_TYPE, ): UseCmsBlockReturn { function getSlotContent(slotName: ArrayElement["slot"]) { return content.slots.find((slot) => slot.slot === slotName) as ArrayElement< BLOCK_TYPE["slots"] >; } return { block: content, getSlotContent, }; }