Skip to content

Commit

Permalink
Merge pull request #280 from Vizzuality/SKY30-383-header-links-no-lon…
Browse files Browse the repository at this point in the history
…ger-displaying-icons-for-the-static-pages

[SKY30-383] Fix header links for static pages no longer displaying the "active" page arrow
  • Loading branch information
SARodrigues authored Jul 8, 2024
2 parents 6ad2c47 + c53e46d commit 0dd3c0c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion frontend/src/components/active-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -35,7 +37,12 @@ const ActiveLink: React.FC<ActiveLinkProps> = ({
// 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;

Expand Down

0 comments on commit 0dd3c0c

Please sign in to comment.