feat(SW-285): Ship support for ContentPageBlocksCardsGrid
This commit is contained in:
@@ -6,6 +6,7 @@ import { request } from "@/lib/graphql/request"
|
||||
import { notFound } from "@/server/errors/trpc"
|
||||
|
||||
import { generateTag, generateTags } from "@/utils/generateTag"
|
||||
import { removeMultipleSlashes } from "@/utils/url"
|
||||
|
||||
import { removeEmptyObjects } from "../../utils"
|
||||
import { ContentPageRefsDataRaw, validateContentPageRefsSchema } from "./output"
|
||||
@@ -130,3 +131,29 @@ export function getConnections(refs: ContentPageRefsDataRaw) {
|
||||
}
|
||||
return connections
|
||||
}
|
||||
|
||||
export function makeButtonObject(button: any) {
|
||||
if (!button) return null
|
||||
|
||||
const isContenstackLink =
|
||||
button?.is_contentstack_link || button.linkConnection?.edges?.length
|
||||
const linkConnnectionNode = isContenstackLink
|
||||
? button.linkConnection.edges[0]?.node
|
||||
: null
|
||||
|
||||
return {
|
||||
openInNewTab: button?.open_in_new_tab,
|
||||
title:
|
||||
button.cta_text ||
|
||||
(linkConnnectionNode
|
||||
? linkConnnectionNode.title
|
||||
: button.external_link.title),
|
||||
href: linkConnnectionNode
|
||||
? linkConnnectionNode.web?.original_url ||
|
||||
removeMultipleSlashes(
|
||||
`/${linkConnnectionNode.system.locale}/${linkConnnectionNode.url}`
|
||||
)
|
||||
: button.external_link.href,
|
||||
isExternal: !isContenstackLink,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user