fix(SW-187): Fixed open in new tab and some general refactoring
This commit is contained in:
@@ -321,7 +321,7 @@ const validateInternalLink = z
|
||||
const lang = node.system.locale
|
||||
|
||||
return {
|
||||
url: originalUrl ?? removeMultipleSlashes(`/${lang}/${url}`),
|
||||
url: originalUrl || removeMultipleSlashes(`/${lang}/${url}`),
|
||||
title: node.title,
|
||||
}
|
||||
})
|
||||
@@ -339,14 +339,18 @@ export const validateLinkItem = z
|
||||
url: data.pageConnection?.url ?? data.link?.href ?? "",
|
||||
title: data?.title ?? data.link?.title,
|
||||
openInNewTab: data.open_in_new_tab,
|
||||
isExternal: !!data.link?.href,
|
||||
isExternal: !data.pageConnection?.url,
|
||||
}
|
||||
})
|
||||
|
||||
const validateLinks = z
|
||||
.array(validateLinkItem)
|
||||
.transform((data) => data.filter((item) => item.url))
|
||||
|
||||
export const validateSecondaryLinks = z.array(
|
||||
z.object({
|
||||
title: z.string(),
|
||||
links: z.array(validateLinkItem),
|
||||
links: validateLinks,
|
||||
})
|
||||
)
|
||||
|
||||
@@ -362,7 +366,7 @@ export const validateFooterConfigSchema = z
|
||||
all_footer: z.object({
|
||||
items: z.array(
|
||||
z.object({
|
||||
main_links: z.array(validateLinkItem),
|
||||
main_links: validateLinks,
|
||||
app_downloads: z.object({
|
||||
title: z.string(),
|
||||
links: validateLinksWithType,
|
||||
@@ -371,7 +375,7 @@ export const validateFooterConfigSchema = z
|
||||
social_media: z.object({
|
||||
links: validateLinksWithType,
|
||||
}),
|
||||
tertiary_links: z.array(validateLinkItem),
|
||||
tertiary_links: validateLinks,
|
||||
})
|
||||
),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user