Skip to content

Commit

Permalink
chore: Adds address object if one of the attributes is available
Browse files Browse the repository at this point in the history
  • Loading branch information
hellofanny committed Feb 15, 2025
1 parent 1eae4b5 commit 9ad2a22
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions packages/core/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ function Page({
}

const publisherId = settings?.seo?.publisherId ?? storeConfig.seo.publisherId
const orgAddress = settings?.seo?.organization?.address

const address =
orgAddress && Boolean(Object.values(orgAddress).find(Boolean))
? Object.fromEntries(
Object.entries(orgAddress).filter(([, value]) => Boolean(value))
)
: null

return (
<>
Expand Down Expand Up @@ -102,25 +110,7 @@ function Page({
}),
},
})}
{...(settings?.seo?.organization?.address && {
address: {
type: 'PostalAddress',
...(settings.seo.organization.address.streetAddress && {
streetAddress: settings.seo.organization.address.streetAddress,
}),
...(settings.seo.organization.address.addressLocality && {
addressLocality:
settings.seo.organization.address.addressLocality,
}),
...(settings.seo.organization.address.postalCode && {
postalCode: settings.seo.organization.address.postalCode,
}),
...(settings.seo.organization.address.addressCountry && {
addressCountry:
settings.seo.organization.address.addressCountry,
}),
},
})}
{...(address && { address })}
/>
)}

Expand Down

0 comments on commit 9ad2a22

Please sign in to comment.