Skip to content

Commit

Permalink
fix: switch language stay on the same page
Browse files Browse the repository at this point in the history
  • Loading branch information
thedaviddias committed Jun 10, 2023
1 parent 01524b6 commit 118b9ac
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion public/rss/feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>The David Dias | Front-End Developer, podcaster &amp; content creator</title>
<link>https://thedaviddias.dev</link>
<description>Hey, I'm David Dias! Front-End Developer based in Toronto/Canada. I love talking about code, technology, expatriation and life.</description>
<lastBuildDate>Sat, 10 Jun 2023 18:41:32 GMT</lastBuildDate>
<lastBuildDate>Sat, 10 Jun 2023 19:02:24 GMT</lastBuildDate>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>https://github.com/jpmonette/feed</generator>
<language>en</language>
Expand Down
2 changes: 1 addition & 1 deletion public/rss/fr/feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>The David Dias | Développeur Front-End, podcasteur &amp; créateur de contenu</title>
<link>https://thedaviddias.dev</link>
<description>Salut toi! Je m'appele David Dias. Je suis développeur Front-End, podcasteur, créateur de contenu numérique passioné pour résoudre les problèmes digitaux et humains! J'aime rencontrer de nouvelles personnes, bâtir des communautées et parler de tech, d'expatriation et de web.</description>
<lastBuildDate>Sat, 10 Jun 2023 18:41:32 GMT</lastBuildDate>
<lastBuildDate>Sat, 10 Jun 2023 19:02:24 GMT</lastBuildDate>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>https://github.com/jpmonette/feed</generator>
<language>fr</language>
Expand Down
4 changes: 3 additions & 1 deletion src/components/ChangeLanguage/ChangeLanguage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useRouter } from 'next/router'
import useTranslation from 'next-translate/useTranslation'

import { CustomLink } from '@/components/CustomLink'
Expand All @@ -11,6 +12,7 @@ const { locales } = i18nConfig

export const ChangeLanguage = () => {
const { t, lang } = useTranslation('common')
const router = useRouter()

const langSwitch = locales.map((lng: string) => {
if (lng === lang) return null
Expand All @@ -25,7 +27,7 @@ export const ChangeLanguage = () => {
key={lng}
aria-label={switchLabel}
className="w-8 h-8 bg-gray-200 rounded-lg dark:bg-gray-600 flex items-center justify-center hover:ring-2 ring-gray-300 transition-all"
href="/"
href={router.asPath}
locale={lng}
>
{lng === 'en' ? (
Expand Down
8 changes: 4 additions & 4 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export const Header: React.FC<HeaderProps> = ({ pathname }) => {
{t('title')}
</CustomLink>
)}
<div className="hidden sm:flex" data-testid="desktop-menu">
<nav aria-label="Main navigation">
<div className="hidden sm:flex sm:gap-x-5" data-testid="desktop-menu">
<nav aria-label="Main navigation" className="flex gap-x-8">
{MENU_LINKS(t)
.filter((item) => item.menu !== false)
.map((item) => (
Expand All @@ -63,8 +63,8 @@ export const Header: React.FC<HeaderProps> = ({ pathname }) => {
aria-current={pathname === item.path ? 'page' : undefined}
className={
pathname === item.path
? 'mr-10 font-bold !no-underline'
: 'mr-10 hover:text-black hover:underline dark:hover:text-white'
? 'font-bold !no-underline p-2'
: 'hover:text-black hover:underline dark:hover:text-white p-2'
}
>
{item.label}
Expand Down

2 comments on commit 118b9ac

@vercel
Copy link

@vercel vercel bot commented on 118b9ac Jun 10, 2023

Choose a reason for hiding this comment

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

@github-actions
Copy link

Choose a reason for hiding this comment

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

Deploy preview for thedaviddiasdev ready!

✅ Preview
https://thedaviddiasdev-m1f45s7sa-thedaviddias1.vercel.app

Built with commit 118b9ac.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.