Skip to content

Commit

Permalink
fix(storefront): Skip empty metafields and layout custom fields from …
Browse files Browse the repository at this point in the history
…CMS config
  • Loading branch information
leomp12 committed Jan 3, 2025
1 parent 6eb44f3 commit 30872f7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/storefront/src/decap-cms/get-cms-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ export const getCmsConfig = async (_collOptions: Partial<CmsCollOptions>) => {
heroConfig,
sectionsConfig,
};
const parseCustomFields = (customFields?: CmsFields) => {
return customFields && Object.keys(customFields).length
? parseNestedCmsFields(customFields)
: undefined;
};
let config = {
locale,
load_config_file: false,
Expand All @@ -110,9 +115,9 @@ export const getCmsConfig = async (_collOptions: Partial<CmsCollOptions>) => {
},
collections: i18n([
getConfigsColl(collOptions, {
settingsMetafields: settingsMetafields && parseNestedCmsFields(settingsMetafields),
headerCustom: headerCustom && parseNestedCmsFields(headerCustom),
footerCustom: footerCustom && parseNestedCmsFields(footerCustom),
settingsMetafields: parseCustomFields(settingsMetafields),
headerCustom: parseCustomFields(headerCustom),
footerCustom: parseCustomFields(footerCustom),
}),
getPagesColl(collOptions),
getExtraPagesColl(collOptions),
Expand Down

0 comments on commit 30872f7

Please sign in to comment.