feat(SW-186): Added refs and some extra querys
This commit is contained in:
40
server/routers/contentstack/base/utils.ts
Normal file
40
server/routers/contentstack/base/utils.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { HeaderRefResponse } from "@/types/header"
|
||||
import { Edges } from "@/types/requests/utils/edges"
|
||||
import { NodeRefs } from "@/types/requests/utils/refs"
|
||||
|
||||
export function getConnections(refs: HeaderRefResponse) {
|
||||
const connections: Edges<NodeRefs>[] = []
|
||||
const headerData = refs.all_header.items[0]
|
||||
const topLink = headerData.top_link
|
||||
if (topLink) {
|
||||
connections.push(topLink.linkConnection)
|
||||
}
|
||||
|
||||
headerData.menu_items.forEach(
|
||||
({ linkConnection, see_all_link, cardConnection, submenu }) => {
|
||||
const card = cardConnection.edges[0]?.node
|
||||
connections.push(linkConnection)
|
||||
|
||||
if (see_all_link) {
|
||||
connections.push(see_all_link.linkConnection)
|
||||
}
|
||||
|
||||
if (card) {
|
||||
if (card.primary_button) {
|
||||
connections.push(card.primary_button.linkConnection)
|
||||
}
|
||||
if (card.secondary_button) {
|
||||
connections.push(card.secondary_button.linkConnection)
|
||||
}
|
||||
}
|
||||
|
||||
submenu.forEach(({ links }) => {
|
||||
links.forEach(({ linkConnection }) => {
|
||||
connections.push(linkConnection)
|
||||
})
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
return connections
|
||||
}
|
||||
Reference in New Issue
Block a user