From bfaacd7b5d821366ec3fc82f16d02ddd27e4abe9 Mon Sep 17 00:00:00 2001 From: Arvid Norlin Date: Fri, 3 May 2024 10:33:35 +0200 Subject: [PATCH] feat: add handling of external linking in My Pages Navigation --- components/MyPages/Sidebar/helpers.ts | 1 + components/MyPages/Sidebar/index.tsx | 8 ++++++-- lib/graphql/Fragments/PageLink/ContentPageLink.graphql | 3 +++ lib/graphql/Fragments/PageLink/LoyaltyPageLink.graphql | 3 +++ types/requests/myPages/navigation.ts | 8 +++++--- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/components/MyPages/Sidebar/helpers.ts b/components/MyPages/Sidebar/helpers.ts index 1991df060..82c90ceee 100644 --- a/components/MyPages/Sidebar/helpers.ts +++ b/components/MyPages/Sidebar/helpers.ts @@ -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, } }) } diff --git a/components/MyPages/Sidebar/index.tsx b/components/MyPages/Sidebar/index.tsx index 311510545..10f9f2e1a 100644 --- a/components/MyPages/Sidebar/index.tsx +++ b/components/MyPages/Sidebar/index.tsx @@ -34,7 +34,11 @@ export default async function Sidebar({ lang }: SidebarProps) { {menuItems.map((item) => ( - + {item.linkText} {item.subItems @@ -42,7 +46,7 @@ export default async function Sidebar({ lang }: SidebarProps) { return ( diff --git a/lib/graphql/Fragments/PageLink/ContentPageLink.graphql b/lib/graphql/Fragments/PageLink/ContentPageLink.graphql index f550300be..8b7d5421a 100644 --- a/lib/graphql/Fragments/PageLink/ContentPageLink.graphql +++ b/lib/graphql/Fragments/PageLink/ContentPageLink.graphql @@ -5,4 +5,7 @@ fragment ContentPageLink on ContentPage { } title url + web { + original_url + } } diff --git a/lib/graphql/Fragments/PageLink/LoyaltyPageLink.graphql b/lib/graphql/Fragments/PageLink/LoyaltyPageLink.graphql index d0c6ac0a9..b4759e6bd 100644 --- a/lib/graphql/Fragments/PageLink/LoyaltyPageLink.graphql +++ b/lib/graphql/Fragments/PageLink/LoyaltyPageLink.graphql @@ -5,4 +5,7 @@ fragment LoyaltyPageLink on LoyaltyPage { } title url + web { + original_url + } } diff --git a/types/requests/myPages/navigation.ts b/types/requests/myPages/navigation.ts index 82dda1411..6a576472f 100644 --- a/types/requests/myPages/navigation.ts +++ b/types/requests/myPages/navigation.ts @@ -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 { } + TypenameInterface {} export interface LoyaltyPageLink extends NavigationLink, - TypenameInterface { } + TypenameInterface {} export interface ContentPageLink extends NavigationLink, - TypenameInterface { } + TypenameInterface {} export type PageLink = ContentPageLink | AccountPageLink | LoyaltyPageLink