wip: refactor sections

This commit is contained in:
2025-09-24 15:14:48 -04:00
parent b2b9b2ba8f
commit 9af11d00cf
9 changed files with 56 additions and 59 deletions

View File

@@ -3,11 +3,12 @@ import { createSSRApp, h } from "vue";
import type { TheSectionFragment } from "#graphql-operations";
export default defineEventHandler(async (event) => {
const { fieldGroupName, ...attrs } = await readBody<TheSectionFragment>(event);
try {
const section = await readBody<TheSectionFragment>(event);
const { component, attrs } = useSection(section);
const app = createSSRApp({
render() {
return h(sectionsMap[fieldGroupName as FieldGroupName], attrs);
return h(component, attrs);
},
});
const html = await renderToString(app);

View File

@@ -6659,7 +6659,7 @@ type GroupAbstractBuilder implements AcfFieldGroup & AcfFieldGroupFields & Group
"""
Field of the &quot;flexible_content&quot; Field Type added to the schema as part of the &quot;GroupAbstractBuilder&quot; Field Group
"""
sections: [GroupAbstractBuilderSections_Layout]!
sections: [GroupAbstractBuilderSections_Layout]
}
"""
@@ -6752,7 +6752,7 @@ interface GroupAbstractBuilder_Fields implements AcfFieldGroup & AcfFieldGroupFi
"""
Field of the &quot;flexible_content&quot; Field Type added to the schema as part of the &quot;GroupAbstractBuilder&quot; Field Group
"""
sections: [GroupAbstractBuilderSections_Layout]!
sections: [GroupAbstractBuilderSections_Layout]
}
"""
@@ -7363,7 +7363,7 @@ type GroupPostArticle implements AcfFieldGroup & AcfFieldGroupFields & GroupAbst
"""
Field of the &quot;flexible_content&quot; Field Type added to the schema as part of the &quot;GroupAbstractBuilder&quot; Field Group
"""
sections: [GroupAbstractBuilderSections_Layout]!
sections: [GroupAbstractBuilderSections_Layout]
}
"""
@@ -7376,7 +7376,7 @@ interface GroupPostArticle_Fields implements AcfFieldGroup & AcfFieldGroupFields
"""
Field of the &quot;flexible_content&quot; Field Type added to the schema as part of the &quot;GroupAbstractBuilder&quot; Field Group
"""
sections: [GroupAbstractBuilderSections_Layout]!
sections: [GroupAbstractBuilderSections_Layout]
}
"""
@@ -8177,7 +8177,7 @@ type GroupPostPage implements AcfFieldGroup & AcfFieldGroupFields & GroupAbstrac
"""
Field of the &quot;flexible_content&quot; Field Type added to the schema as part of the &quot;GroupAbstractBuilder&quot; Field Group
"""
sections: [GroupAbstractBuilderSections_Layout]!
sections: [GroupAbstractBuilderSections_Layout]
}
"""
@@ -8190,7 +8190,7 @@ interface GroupPostPage_Fields implements AcfFieldGroup & AcfFieldGroupFields &
"""
Field of the &quot;flexible_content&quot; Field Type added to the schema as part of the &quot;GroupAbstractBuilder&quot; Field Group
"""
sections: [GroupAbstractBuilderSections_Layout]!
sections: [GroupAbstractBuilderSections_Layout]
}
"""
@@ -8229,7 +8229,7 @@ type GroupPostProject implements AcfFieldGroup & AcfFieldGroupFields & GroupAbst
"""
Field of the &quot;flexible_content&quot; Field Type added to the schema as part of the &quot;GroupAbstractBuilder&quot; Field Group
"""
sections: [GroupAbstractBuilderSections_Layout]!
sections: [GroupAbstractBuilderSections_Layout]
}
"""
@@ -8294,7 +8294,7 @@ interface GroupPostProject_Fields implements AcfFieldGroup & AcfFieldGroupFields
"""
Field of the &quot;flexible_content&quot; Field Type added to the schema as part of the &quot;GroupAbstractBuilder&quot; Field Group
"""
sections: [GroupAbstractBuilderSections_Layout]!
sections: [GroupAbstractBuilderSections_Layout]
}
"""
@@ -8671,7 +8671,7 @@ type GroupPostTemplate implements AcfFieldGroup & AcfFieldGroupFields & GroupAbs
"""
Field of the &quot;flexible_content&quot; Field Type added to the schema as part of the &quot;GroupAbstractBuilder&quot; Field Group
"""
sections: [GroupAbstractBuilderSections_Layout]!
sections: [GroupAbstractBuilderSections_Layout]
}
"""
@@ -8684,7 +8684,7 @@ interface GroupPostTemplate_Fields implements AcfFieldGroup & AcfFieldGroupField
"""
Field of the &quot;flexible_content&quot; Field Type added to the schema as part of the &quot;GroupAbstractBuilder&quot; Field Group
"""
sections: [GroupAbstractBuilderSections_Layout]!
sections: [GroupAbstractBuilderSections_Layout]
}
"""
@@ -25068,9 +25068,6 @@ enum UserRoleEnum {
"""User role with specific capabilities"""
SUBSCRIBER
"""User role with specific capabilities"""
TRANSLATOR
}
"""Connection between the User type and the Comment type"""

View 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 };
}