generated from pascalmartineau/wp-skeleton
wip: refactor sections
This commit is contained in:
12
wp-content/themes/ccat/server/utils/useSection.ts
Normal file
12
wp-content/themes/ccat/server/utils/useSection.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import type { TheSectionFragment } from "#graphql-operations";
|
||||
import SectionTextBlock from "~/components/sections/SectionTextBlock.vue";
|
||||
|
||||
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 };
|
||||
}
|
||||
Reference in New Issue
Block a user