generated from pascalmartineau/wp-skeleton
refactor: fieldGroupName => __typename
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 58s
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 58s
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
fragment TheSection on GroupAbstractBuilderSections_Layout {
|
||||
fieldGroupName
|
||||
__typename
|
||||
... on GroupAbstractBuilderSectionsTextBlockLayout {
|
||||
...SectionTextBlock
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ function ccat_acf_init() {
|
||||
}
|
||||
|
||||
// Helper: Get GraphQL field group name for flexible content layout
|
||||
function ccat_get_graphql_field_group_name( $field_group_key, $layout_name ) {
|
||||
function ccat_get_graphql_layout_typename( $field_group_key, $layout_name ) {
|
||||
$layout_type_name = \WPGraphQL\Utils\Utils::format_type_name( $layout_name );
|
||||
return "GroupAbstractBuilderSections{$layout_type_name}Layout";
|
||||
}
|
||||
@@ -84,9 +84,9 @@ function ccat_get_graphql_preview_data() {
|
||||
throw new Exception( "Erreur de prévisualisation (section invalide)" );
|
||||
}
|
||||
$result = array(
|
||||
'fieldGroupName' => ccat_get_graphql_field_group_name( 'group_abstract_builder', $layout_name ),
|
||||
'__typename' => ccat_get_graphql_layout_typename( 'group_abstract_builder', $layout_name ),
|
||||
);
|
||||
$format_value = $result['fieldGroupName'] !== 'GroupAbstractBuilderSectionsTemplateLayout';
|
||||
$format_value = $result['__typename'] !== 'GroupAbstractBuilderSectionsTemplateLayout';
|
||||
foreach ( get_row( $format_value ) ?: array() as $key => $value ) {
|
||||
if ( strpos( $key, 'acf_fc_layout' ) !== 0 && strpos( $key, '_' ) !== 0 ) {
|
||||
$result[ ccat_get_graphql_field_name( array( 'name' => $key ) ) ] = $value;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
$preview_url = ( defined( 'NUXT_PUBLIC_SITE_URL' ) ? NUXT_PUBLIC_SITE_URL : 'https://cultureat.ca' ) . '/api/preview';
|
||||
$data = ccat_get_graphql_preview_data();
|
||||
if ( $data['fieldGroupName'] === 'GroupAbstractBuilderSectionsTemplateLayout' ) {
|
||||
if ( $data['__typename'] === 'GroupAbstractBuilderSectionsTemplateLayout' ) {
|
||||
echo '<div style="font-weight: bold; padding: 16px;">' . get_the_title( $data['fieldTemplateId'] ) . '</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,11 +6,8 @@ export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const section = await readBody<TheSectionFragment>(event);
|
||||
const { component, attrs } = useSection(section);
|
||||
const app = createSSRApp({
|
||||
render() {
|
||||
return h(component, attrs);
|
||||
},
|
||||
});
|
||||
// @ts-expect-error Properties from TheSectionFragment
|
||||
const app = createSSRApp({ render: () => h(component, attrs) });
|
||||
const html = await renderToString(app);
|
||||
return html;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ type ACFE_Language {
|
||||
}
|
||||
|
||||
"""
|
||||
Connection between the GroupAbstractCreditsContributions_Fields type and the ContentNode type
|
||||
Connection between the GroupAbstractBuilderSectionsTemplateLayout_Fields type and the ContentNode type
|
||||
"""
|
||||
type AcfContentNodeConnection implements Connection & ContentNodeConnection {
|
||||
"""Edges for the AcfContentNodeConnection connection"""
|
||||
@@ -6913,6 +6913,74 @@ interface GroupAbstractBuilderSectionsLayoutSettings_Fields implements AcfFieldG
|
||||
fieldGroupName: String @deprecated(reason: "Use __typename instead")
|
||||
}
|
||||
|
||||
"""
|
||||
The "GroupAbstractBuilderSectionsTemplateLayout" Field Group. Added to the Schema by "WPGraphQL for ACF".
|
||||
"""
|
||||
type GroupAbstractBuilderSectionsTemplateLayout implements AcfFieldGroup & AcfFieldGroupFields & GroupAbstractBuilderSectionsTemplateLayout_Fields & GroupAbstractBuilderSections_Layout {
|
||||
"""
|
||||
Field of the "text" Field Type added to the schema as part of the "GroupAbstractBuilderSectionsTemplateLayout" Field Group
|
||||
"""
|
||||
acfeFlexibleLayoutTitle: String
|
||||
|
||||
"""The name of the field group"""
|
||||
fieldGroupName: String @deprecated(reason: "Use __typename instead")
|
||||
|
||||
"""
|
||||
Field of the "post_object" Field Type added to the schema as part of the "GroupAbstractBuilderSectionsTemplateLayout" Field Group
|
||||
"""
|
||||
template(
|
||||
"""
|
||||
Cursor used along with the "first" argument to reference where in the dataset to get data
|
||||
"""
|
||||
after: String
|
||||
|
||||
"""
|
||||
Cursor used along with the "last" argument to reference where in the dataset to get data
|
||||
"""
|
||||
before: String
|
||||
|
||||
"""The number of items to return after the referenced "after" cursor"""
|
||||
first: Int
|
||||
|
||||
"""The number of items to return before the referenced "before" cursor"""
|
||||
last: Int
|
||||
): AcfContentNodeConnection
|
||||
}
|
||||
|
||||
"""
|
||||
Interface representing fields of the ACF "GroupAbstractBuilderSectionsTemplateLayout" Field Group
|
||||
"""
|
||||
interface GroupAbstractBuilderSectionsTemplateLayout_Fields implements AcfFieldGroup & AcfFieldGroupFields & GroupAbstractBuilderSections_Layout {
|
||||
"""
|
||||
Field of the "text" Field Type added to the schema as part of the "GroupAbstractBuilderSectionsTemplateLayout" Field Group
|
||||
"""
|
||||
acfeFlexibleLayoutTitle: String
|
||||
|
||||
"""The name of the field group"""
|
||||
fieldGroupName: String @deprecated(reason: "Use __typename instead")
|
||||
|
||||
"""
|
||||
Field of the "post_object" Field Type added to the schema as part of the "GroupAbstractBuilderSectionsTemplateLayout" Field Group
|
||||
"""
|
||||
template(
|
||||
"""
|
||||
Cursor used along with the "first" argument to reference where in the dataset to get data
|
||||
"""
|
||||
after: String
|
||||
|
||||
"""
|
||||
Cursor used along with the "last" argument to reference where in the dataset to get data
|
||||
"""
|
||||
before: String
|
||||
|
||||
"""The number of items to return after the referenced "after" cursor"""
|
||||
first: Int
|
||||
|
||||
"""The number of items to return before the referenced "before" cursor"""
|
||||
last: Int
|
||||
): AcfContentNodeConnection
|
||||
}
|
||||
|
||||
"""
|
||||
The "GroupAbstractBuilderSectionsTextBlockLayout" Field Group. Added to the Schema by "WPGraphQL for ACF".
|
||||
"""
|
||||
@@ -7711,7 +7779,7 @@ type GroupPostContributor implements AcfFieldGroup & AcfFieldGroupFields & Group
|
||||
"""
|
||||
Field of the "repeater" Field Type added to the schema as part of the "GroupPostContributor" Field Group
|
||||
"""
|
||||
locality: [GroupPostContributorLocality]
|
||||
localities: [GroupPostContributorLocalities]
|
||||
|
||||
"""
|
||||
Field of the "repeater" Field Type added to the schema as part of the "GroupAbstractGallery" Field Group
|
||||
@@ -7751,11 +7819,11 @@ interface GroupPostContributorAlternativeTitles_Fields implements AcfFieldGroup
|
||||
}
|
||||
|
||||
"""
|
||||
The "GroupPostContributorLocality" Field Group. Added to the Schema by "WPGraphQL for ACF".
|
||||
The "GroupPostContributorLocalities" Field Group. Added to the Schema by "WPGraphQL for ACF".
|
||||
"""
|
||||
type GroupPostContributorLocality implements AcfFieldGroup & AcfFieldGroupFields & GroupPostContributorLocality_Fields {
|
||||
type GroupPostContributorLocalities implements AcfFieldGroup & AcfFieldGroupFields & GroupPostContributorLocalities_Fields {
|
||||
"""
|
||||
Field of the "acfe_address" Field Type added to the schema as part of the "GroupPostContributorLocality" Field Group
|
||||
Field of the "acfe_address" Field Type added to the schema as part of the "GroupPostContributorLocalities" Field Group
|
||||
"""
|
||||
address: Address!
|
||||
|
||||
@@ -7764,11 +7832,11 @@ type GroupPostContributorLocality implements AcfFieldGroup & AcfFieldGroupFields
|
||||
}
|
||||
|
||||
"""
|
||||
Interface representing fields of the ACF "GroupPostContributorLocality" Field Group
|
||||
Interface representing fields of the ACF "GroupPostContributorLocalities" Field Group
|
||||
"""
|
||||
interface GroupPostContributorLocality_Fields implements AcfFieldGroup & AcfFieldGroupFields {
|
||||
interface GroupPostContributorLocalities_Fields implements AcfFieldGroup & AcfFieldGroupFields {
|
||||
"""
|
||||
Field of the "acfe_address" Field Type added to the schema as part of the "GroupPostContributorLocality" Field Group
|
||||
Field of the "acfe_address" Field Type added to the schema as part of the "GroupPostContributorLocalities" Field Group
|
||||
"""
|
||||
address: Address!
|
||||
|
||||
@@ -7827,7 +7895,7 @@ interface GroupPostContributor_Fields implements AcfFieldGroup & AcfFieldGroupFi
|
||||
"""
|
||||
Field of the "repeater" Field Type added to the schema as part of the "GroupPostContributor" Field Group
|
||||
"""
|
||||
locality: [GroupPostContributorLocality]
|
||||
localities: [GroupPostContributorLocalities]
|
||||
|
||||
"""
|
||||
Field of the "repeater" Field Type added to the schema as part of the "GroupAbstractGallery" Field Group
|
||||
@@ -11288,6 +11356,9 @@ type MediaItem implements ContentNode & DatabaseIdentifier & HierarchicalContent
|
||||
"""The globally unique identifier of the attachment object."""
|
||||
id: ID!
|
||||
|
||||
"""Image center point for cropping (e.g., "50% 50%")"""
|
||||
imageCenter: String
|
||||
|
||||
"""Whether the node is a Comment"""
|
||||
isComment: Boolean!
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ const sections = {
|
||||
GroupAbstractBuilderSectionsTextBlockLayout: SectionTextBlock,
|
||||
} as const;
|
||||
|
||||
export function useSection({ fieldGroupName, ...attrs }: TheSectionFragment) {
|
||||
const component = sections[fieldGroupName as keyof typeof sections];
|
||||
export function useSection({ __typename, ...attrs }: TheSectionFragment) {
|
||||
const component = sections[__typename 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