25 lines
675 B
TypeScript
25 lines
675 B
TypeScript
import type { FooterLinkItem } from "./output"
|
|
|
|
export function transformPageConnectionLinks(links: FooterLinkItem[]) {
|
|
console.log("linksdata", links[0].pageConnection?.edges)
|
|
if (!links) return []
|
|
return links.flatMap((link) => {
|
|
if (link.pageConnection?.edges.length) {
|
|
return link.pageConnection.edges.map((edge) => ({
|
|
title: edge.node.title || "",
|
|
url: edge.node.url || "",
|
|
openInNewTab: link.open_in_new_tab,
|
|
}))
|
|
} else if (link.link) {
|
|
return [
|
|
{
|
|
title: link.link.title,
|
|
url: link.link.href,
|
|
openInNewTab: link.open_in_new_tab,
|
|
},
|
|
]
|
|
}
|
|
return []
|
|
})
|
|
}
|