feat: add handling of external linking in My Pages Navigation
This commit is contained in:
@@ -13,6 +13,7 @@ export function mapMenuItems(navigationItems: NavigationItem[]) {
|
||||
subItems: item.sub_items ? mapMenuItems(item.sub_items) : null,
|
||||
uid: node.system.uid,
|
||||
url: `/${node.system.locale}/${node.url}`.replaceAll(/\/\/+/g, "/"),
|
||||
originalUrl: node.web?.original_url,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -34,7 +34,11 @@ export default async function Sidebar({ lang }: SidebarProps) {
|
||||
</Title>
|
||||
{menuItems.map((item) => (
|
||||
<Fragment key={item.uid}>
|
||||
<Link href={item.url} partialMatch variant="sidebar">
|
||||
<Link
|
||||
href={item.originalUrl || item.url}
|
||||
partialMatch
|
||||
variant="sidebar"
|
||||
>
|
||||
{item.linkText}
|
||||
</Link>
|
||||
{item.subItems
|
||||
@@ -42,7 +46,7 @@ export default async function Sidebar({ lang }: SidebarProps) {
|
||||
return (
|
||||
<Link
|
||||
key={subItem.uid}
|
||||
href={subItem.url}
|
||||
href={subItem.originalUrl || subItem.url}
|
||||
partialMatch
|
||||
variant="sidebar"
|
||||
>
|
||||
|
||||
@@ -5,4 +5,7 @@ fragment ContentPageLink on ContentPage {
|
||||
}
|
||||
title
|
||||
url
|
||||
web {
|
||||
original_url
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,7 @@ fragment LoyaltyPageLink on LoyaltyPage {
|
||||
}
|
||||
title
|
||||
url
|
||||
web {
|
||||
original_url
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ export type MenuItem = {
|
||||
subItems: MenuItem[] | null
|
||||
uid: string
|
||||
url: string
|
||||
originalUrl: string | undefined
|
||||
}
|
||||
|
||||
export type SidebarProps = {
|
||||
@@ -28,19 +29,20 @@ interface NavigationLink {
|
||||
}
|
||||
url: string
|
||||
title: string
|
||||
web?: { original_url: string }
|
||||
}
|
||||
|
||||
export interface AccountPageLink
|
||||
extends NavigationLink,
|
||||
TypenameInterface<PageLinkEnum.AccountPage> { }
|
||||
TypenameInterface<PageLinkEnum.AccountPage> {}
|
||||
|
||||
export interface LoyaltyPageLink
|
||||
extends NavigationLink,
|
||||
TypenameInterface<PageLinkEnum.LoyaltyPage> { }
|
||||
TypenameInterface<PageLinkEnum.LoyaltyPage> {}
|
||||
|
||||
export interface ContentPageLink
|
||||
extends NavigationLink,
|
||||
TypenameInterface<PageLinkEnum.ContentPage> { }
|
||||
TypenameInterface<PageLinkEnum.ContentPage> {}
|
||||
|
||||
export type PageLink = ContentPageLink | AccountPageLink | LoyaltyPageLink
|
||||
|
||||
|
||||
Reference in New Issue
Block a user