From cc07b8d66d7b5fbe80b5d0ad0aac37b42eb0a568 Mon Sep 17 00:00:00 2001 From: "Alejandro E. Rendon" Date: Mon, 29 Jan 2024 13:21:30 -0500 Subject: [PATCH] Redireccionar URL de acuerdo al lenguaje --- src/app/[lang]/components/NavbarCustom.js | 15 ++-- src/app/[lang]/keynotes/[uniquepage]/page.js | 80 +++++++++++++++++++ src/app/[lang]/keynotes/images/avatar.jpeg | Bin 0 -> 5303 bytes src/app/[lang]/keynotes/page.js | 49 ++++++++++++ src/app/[lang]/layout.js | 11 ++- src/app/[lang]/speakers/page.js | 45 +++++++---- src/data/speakers.json | 2 + 7 files changed, 177 insertions(+), 25 deletions(-) create mode 100644 src/app/[lang]/keynotes/[uniquepage]/page.js create mode 100644 src/app/[lang]/keynotes/images/avatar.jpeg create mode 100644 src/app/[lang]/keynotes/page.js diff --git a/src/app/[lang]/components/NavbarCustom.js b/src/app/[lang]/components/NavbarCustom.js index bfc2084..bb3ac74 100644 --- a/src/app/[lang]/components/NavbarCustom.js +++ b/src/app/[lang]/components/NavbarCustom.js @@ -1,7 +1,7 @@ 'use client'; import React from 'react'; -import { useRouter, usePathname } from 'next/navigation'; +import { useRouter, useSelectedLayoutSegments } from 'next/navigation'; import Link from 'next/link'; import propTypes from 'prop-types'; import Container from 'react-bootstrap/Container'; @@ -15,10 +15,10 @@ import { locales } from '@/utils/locale'; const NavbarCustom = ({ lang }) => { const i18nDictionary = useI18n(); const router = useRouter(); - const pathname = usePathname(); + const urlSegments = useSelectedLayoutSegments(); const onChangeLocale = (locale) => { - router.replace(pathname, { locale }); + router.replace(`/${locale}/${urlSegments.join('/')}`); }; return ( @@ -54,16 +54,13 @@ const NavbarCustom = ({ lang }) => {