import type { Schemas } from "#shopware"; type ArrayElement = ArrayType extends readonly (infer ElementType)[] ? ElementType : never; type UseCmsSectionType = { /** * CMS section */ section: Schemas["CmsSection"]; /** * Position of the section */ getPositionContent( position: ArrayElement["sectionPosition"], ): Array; }; /** * Composable to get cms section content * @public * @category CMS (Shopping Experiences) */ export function useCmsSection( content: SECTION_TYPE, ): UseCmsSectionType { function getPositionContent( position: ArrayElement["sectionPosition"], ) { return content.blocks.filter( (block) => block.sectionPosition === position, ) as Array; } return { section: content, getPositionContent, }; }