From c53e46d1615f8201718654df00d191e6ec034bbb Mon Sep 17 00:00:00 2001 From: Simao Rodrigues Date: Fri, 5 Jul 2024 11:34:00 +0100 Subject: [PATCH] Fix active links in the header not displaying correctly for the static pages --- frontend/src/components/active-link.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/active-link.tsx b/frontend/src/components/active-link.tsx index 5f5ea498..379cba96 100644 --- a/frontend/src/components/active-link.tsx +++ b/frontend/src/components/active-link.tsx @@ -4,6 +4,8 @@ */ import React, { useState, useEffect, PropsWithChildren } from 'react'; +import { UrlObject } from 'url'; + import Link, { LinkProps } from 'next/link'; import { useRouter } from 'next/router'; @@ -35,7 +37,12 @@ const ActiveLink: React.FC = ({ // Dynamic route will be matched via props.as // Static route will be matched via props.href const linkPathname = new URL( - `${(props.as as string) ?? (props.href as string)}`, + `${ + (props.as as string) ?? + (typeof props.href === 'string' + ? (props.href as string) + : ((props.href as UrlObject)?.pathname as string)) + }`, window.location.href ).pathname;