fix: move url field on content page to root

This commit is contained in:
Christel Westerberg
2024-04-18 10:28:35 +02:00
parent d2c1887179
commit 1a95b65653
4 changed files with 4 additions and 20 deletions

View File

@@ -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, "/"),
} }
}) })
} }

View File

@@ -30,8 +30,6 @@ fragment ContentPageLink on ContentPage {
locale locale
uid uid
} }
web { url
url
}
title title
} }

View File

@@ -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"]
} }

View File

@@ -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