Files
cultureat-bak/wp-content/themes/ccat/app/composables/useSection.ts

13 lines
521 B
TypeScript

import type { TheSectionFragment } from "#graphql-operations";
import { SectionTextBlock } from "#components";
const sections = {
GroupAbstractBuilderSectionsTextBlockLayout: SectionTextBlock,
} as const;
export function useSection({ fieldGroupName, ...attrs }: TheSectionFragment) {
const component = sections[fieldGroupName as keyof typeof sections];
if (!component) throw createError({ statusCode: 500, statusMessage: "Erreur interne", message: "Type de section invalide." });
return { component, attrs };
}