fix: move url field on content page to root
This commit is contained in:
@@ -1,20 +1,8 @@
|
|||||||
import { PageLinkEnum } from "@/types/requests/myPages/navigation"
|
|
||||||
import type {
|
import type {
|
||||||
NavigationItem,
|
NavigationItem,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
PageLink,
|
|
||||||
} from "@/types/requests/myPages/navigation"
|
} from "@/types/requests/myPages/navigation"
|
||||||
|
|
||||||
function getURL(node: PageLink) {
|
|
||||||
switch (node.__typename) {
|
|
||||||
case PageLinkEnum.ContentPage:
|
|
||||||
return node.web.url
|
|
||||||
case PageLinkEnum.AccountPage:
|
|
||||||
case PageLinkEnum.LoyaltyPage:
|
|
||||||
return node.url
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function mapMenuItems(navigationItems: NavigationItem[]) {
|
export function mapMenuItems(navigationItems: NavigationItem[]) {
|
||||||
return navigationItems.map(({ item }): MenuItem => {
|
return navigationItems.map(({ item }): MenuItem => {
|
||||||
const { node } = item.pageConnection.edges[0]
|
const { node } = item.pageConnection.edges[0]
|
||||||
@@ -24,7 +12,7 @@ export function mapMenuItems(navigationItems: NavigationItem[]) {
|
|||||||
lang: node.system.locale,
|
lang: node.system.locale,
|
||||||
subItems: item.sub_items ? mapMenuItems(item.sub_items) : null,
|
subItems: item.sub_items ? mapMenuItems(item.sub_items) : null,
|
||||||
uid: node.system.uid,
|
uid: node.system.uid,
|
||||||
url: `/${node.system.locale}/${getURL(node)}`.replaceAll(/\/\/+/g, "/"),
|
url: `/${node.system.locale}/${node.url}`.replaceAll(/\/\/+/g, "/"),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ fragment ContentPageLink on ContentPage {
|
|||||||
locale
|
locale
|
||||||
uid
|
uid
|
||||||
}
|
}
|
||||||
web {
|
url
|
||||||
url
|
|
||||||
}
|
|
||||||
title
|
title
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,5 +25,5 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules", ".next"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,9 +44,7 @@ export interface LoyaltyPageLink
|
|||||||
export interface ContentPageLink
|
export interface ContentPageLink
|
||||||
extends NavigationLink,
|
extends NavigationLink,
|
||||||
TypenameInterface<PageLinkEnum.ContentPage> {
|
TypenameInterface<PageLinkEnum.ContentPage> {
|
||||||
web: {
|
url: string
|
||||||
url: string
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PageLink = ContentPageLink | AccountPageLink | LoyaltyPageLink
|
export type PageLink = ContentPageLink | AccountPageLink | LoyaltyPageLink
|
||||||
|
|||||||
Reference in New Issue
Block a user