Skip to content

Commit

Permalink
Add redirect from localized homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
leanazulyoro committed Apr 16, 2024
1 parent 0e58898 commit 331f8e8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
23 changes: 23 additions & 0 deletions site/pages/[locale]/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { useRouter } from 'next/router'
import { useEffect } from 'react'

import { defaultLocale, locales } from '../../navigation'
import { homepageRedirect } from '../index'

function HomePage() {
const router = useRouter()

useEffect(
function redirectHomepage() {
const [language] = navigator.language.split('-')
const enabledLanguage = locales.includes(language)
router.replace(
`/${enabledLanguage ? language : defaultLocale}${homepageRedirect}`
)
},
[router]
)
return null
}

export default HomePage
4 changes: 3 additions & 1 deletion site/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useRedirectToDefaultLocale } from '../hooks/useRedirectToDefaultLocale'
import { defaultLocale, locales } from '../navigation'

export const homepageRedirect = '/merkle-claims'

function HomePage() {
useRedirectToDefaultLocale({
defaultLocale,
locales,
redirectPage: '/merkle-claims'
redirectPage: homepageRedirect
})
return null
}
Expand Down

0 comments on commit 331f8e8

Please sign in to comment.