Skip to content

Commit

Permalink
Merge pull request #16 from Tomburgs/fix-header-item-active
Browse files Browse the repository at this point in the history
Fix "Pages" header item not being highlighted when on /[pages] url
  • Loading branch information
Tomburgs committed Oct 12, 2020
2 parents cf5309c + 925cf46 commit 7554f20
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/header/items/Items.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@ const {
} = styles;

const links = [
{ name: 'Home', url: '/' },
{ name: 'Pages', url: '/pages' },
{ name: 'Profile', url: '/profile' }
{ name: 'Home', url: '/', alias: [] },
{ name: 'Pages', url: '/pages', alias: ['/[page]'] },
{ name: 'Profile', url: '/profile', alias: [] }
];

export default function Items(): JSX.Element {
const { pathname } = useRouter();

return (
<ul className={ items }>
{ links.map(({ name, url }) => (
{ links.map(({ name, url, alias }) => (
<li
key={ name }
className={
injectClassNames([
active,
pathname === url
|| alias.includes(pathname)
])
}
>
Expand Down

1 comment on commit 7554f20

@vercel
Copy link

@vercel vercel bot commented on 7554f20 Oct 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.