Skip to content

Commit

Permalink
chore: refactoring to improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
hellofanny committed Feb 17, 2025
1 parent 9ad2a22 commit 1c0e35f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/core/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ 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
const organizationAddress = Object.entries(
settings?.seo?.organization?.address ?? {}
).reduce(
(acc, [key, value]) => {
if (value) {
acc[key] = value
}
return acc
},
{} as Record<string, string>
)

return (
<>
Expand Down Expand Up @@ -110,7 +114,9 @@ function Page({
}),
},
})}
{...(address && { address })}
{...(Object.keys(organizationAddress).length !== 0 && {
address: organizationAddress,
})}
/>
)}

Expand Down

0 comments on commit 1c0e35f

Please sign in to comment.