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 {
|
||||
NavigationItem,
|
||||
MenuItem,
|
||||
PageLink,
|
||||
} 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[]) {
|
||||
return navigationItems.map(({ item }): MenuItem => {
|
||||
const { node } = item.pageConnection.edges[0]
|
||||
@@ -24,7 +12,7 @@ export function mapMenuItems(navigationItems: NavigationItem[]) {
|
||||
lang: node.system.locale,
|
||||
subItems: item.sub_items ? mapMenuItems(item.sub_items) : null,
|
||||
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
|
||||
uid
|
||||
}
|
||||
web {
|
||||
url
|
||||
}
|
||||
url
|
||||
title
|
||||
}
|
||||
|
||||
@@ -25,5 +25,5 @@
|
||||
}
|
||||
},
|
||||
"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
|
||||
extends NavigationLink,
|
||||
TypenameInterface<PageLinkEnum.ContentPage> {
|
||||
web: {
|
||||
url: string
|
||||
}
|
||||
url: string
|
||||
}
|
||||
|
||||
export type PageLink = ContentPageLink | AccountPageLink | LoyaltyPageLink
|
||||
|
||||
Reference in New Issue
Block a user