Last active
April 13, 2020 17:26
-
-
Save timothyde/4706535b63a57b1def04434bf35a82c8 to your computer and use it in GitHub Desktop.
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
// pass location from page as props | |
export const localeLink = location, to => { | |
const keys = ['en', 'jp'] | |
const { pathname } = location | |
const lang = keys.find( | |
k => pathname.includes(`/${k}/`) || pathname.includes(`/${k}`) | |
) | |
if (!lang) { | |
return to | |
} | |
return `/${lang}${to}` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment