fix(SW-190): added linkConnectionNode as variable for readability

This commit is contained in:
Erik Tiekstra
2024-08-16 09:07:13 +02:00
parent 8c76cf62c7
commit 56312335b2

View File

@@ -84,18 +84,19 @@ export function makeButtonObject(button: any) {
const isContenstackLink = const isContenstackLink =
button?.is_contentstack_link || button.linkConnection?.edges?.length button?.is_contentstack_link || button.linkConnection?.edges?.length
const linkConnnectionNode = button.linkConnection.edges[0].node
return { return {
openInNewTab: button?.open_in_new_tab, openInNewTab: button?.open_in_new_tab,
title: title:
button.cta_text || button.cta_text ||
(isContenstackLink (isContenstackLink
? button.linkConnection.edges[0].node.title ? linkConnnectionNode.title
: button.external_link.title), : button.external_link.title),
href: isContenstackLink href: isContenstackLink
? button.linkConnection.edges[0].node.web?.original_url || ? linkConnnectionNode.web?.original_url ||
removeMultipleSlashes( removeMultipleSlashes(
`/${button.linkConnection.edges[0].node.system.locale}/${button.linkConnection.edges[0].node.url}` `/${linkConnnectionNode.system.locale}/${linkConnnectionNode.url}`
) )
: button.external_link.href, : button.external_link.href,
isExternal: !isContenstackLink, isExternal: !isContenstackLink,