feat(SW-187): use custom title for links

This commit is contained in:
Pontus Dreij
2024-09-10 10:23:15 +02:00
parent f79c88d07e
commit 84fb10aa2c
2 changed files with 5 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ query GetFooter($locale: String!) {
all_footer(limit: 1, locale: $locale) { all_footer(limit: 1, locale: $locale) {
items { items {
main_links { main_links {
title
open_in_new_tab open_in_new_tab
link { link {
href href
@@ -35,6 +36,7 @@ query GetFooter($locale: String!) {
secondary_links { secondary_links {
title title
links { links {
title
open_in_new_tab open_in_new_tab
pageConnection { pageConnection {
edges { edges {
@@ -52,6 +54,7 @@ query GetFooter($locale: String!) {
} }
} }
tertiary_links { tertiary_links {
title
open_in_new_tab open_in_new_tab
link { link {
href href

View File

@@ -318,6 +318,7 @@ const validateInternalLink = z
export const validateLinkItem = z export const validateLinkItem = z
.object({ .object({
title: z.string(),
open_in_new_tab: z.boolean(), open_in_new_tab: z.boolean(),
link: validateExternalLink, link: validateExternalLink,
pageConnection: validateInternalLink, pageConnection: validateInternalLink,
@@ -325,7 +326,7 @@ export const validateLinkItem = z
.transform((data) => { .transform((data) => {
return { return {
url: data.pageConnection?.url ?? data.link?.href ?? "", url: data.pageConnection?.url ?? data.link?.href ?? "",
title: data.pageConnection?.title ?? data.link?.title, title: data?.title ?? data.link?.title,
openInNewTab: data.open_in_new_tab, openInNewTab: data.open_in_new_tab,
isExternal: !!data.link?.href, isExternal: !!data.link?.href,
} }