forked from purefinance/pure.finance
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add redirect from localized homepage
- Loading branch information
1 parent
0e58898
commit 331f8e8
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters