fix: rename retried-wrapped fetch to make caching work again
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { removeMultipleSlashes } from "@/utils/url"
|
||||
|
||||
import { PageLinkEnum } from "@/types/requests/pageLinks"
|
||||
import type { Edges } from "@/types/requests/utils/edges"
|
||||
import type { NodeRefs } from "@/types/requests/utils/refs"
|
||||
import type { GetNavigationMyPagesRefsData } from "./output"
|
||||
import type { GetNavigationMyPagesRefsData, MenuItems } from "./output"
|
||||
|
||||
export function getConnections(refs: GetNavigationMyPagesRefsData) {
|
||||
const connections: Edges<NodeRefs>[] = []
|
||||
@@ -14,3 +17,36 @@ export function getConnections(refs: GetNavigationMyPagesRefsData) {
|
||||
|
||||
return connections
|
||||
}
|
||||
|
||||
export function mapMenuItems(menuItems: MenuItems) {
|
||||
return menuItems.map((menuItem) => {
|
||||
return {
|
||||
...menuItem,
|
||||
links: menuItem.links
|
||||
.filter((link) => {
|
||||
// If content is unpublished or in other way inaccessible in Contentstack
|
||||
// there will be no edges, filter out those links.
|
||||
return !!link.page.edges[0]
|
||||
})
|
||||
.map((link) => {
|
||||
const page = link.page.edges[0].node
|
||||
let originalUrl = undefined
|
||||
if (
|
||||
page.__typename === PageLinkEnum.ContentPage ||
|
||||
page.__typename === PageLinkEnum.LoyaltyPage
|
||||
) {
|
||||
if (page.web.original_url) {
|
||||
originalUrl = page.web.original_url
|
||||
}
|
||||
}
|
||||
return {
|
||||
lang: page.system.locale,
|
||||
linkText: link.link_text ? link.link_text : page.title,
|
||||
uid: page.system.uid,
|
||||
url: removeMultipleSlashes(`/${page.system.locale}/${page.url}`),
|
||||
originalUrl,
|
||||
}
|
||||
}),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user