forked from amannn/next-intl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
localePrefix
for navigation APIs for an improved initial …
…render of `Link` when using `localePrefix: never`. Also fix edge case in middleware when using localized pathnames for redirects that remove a locale prefix (fixes an infinite loop). (amannn#678) By accepting an optional `localePrefix` for the navigation APIs, we can get the initial render of the `href` of `Link` right if `localePrefix: 'never'` is set. This can be helpful if domain-based routing is used and you have a single locale per domain. Note that this change is backward-compatible. It's now recommended to set the `localePrefix` for the navigation APIs to get improved behavior for `Link` in case `localePrefix: 'never'` is used, but otherwise your app will keep working with the previous behavior. Ref amannn#444
- Loading branch information
Showing
26 changed files
with
1,325 additions
and
690 deletions.
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
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
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
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
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
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
43 changes: 36 additions & 7 deletions
43
src/navigation/react-client/createSharedPathnamesNavigation.tsx
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
10 changes: 4 additions & 6 deletions
10
src/navigation/react-server/BaseLink.tsx → src/navigation/react-server/ServerLink.tsx
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 |
---|---|---|
@@ -1,20 +1,18 @@ | ||
import React, {ComponentProps} from 'react'; | ||
import {getLocale} from '../../server'; | ||
import BaseLinkWithLocale from '../../shared/BaseLinkWithLocale'; | ||
import {AllLocales} from '../../shared/types'; | ||
import BaseLink from '../shared/BaseLink'; | ||
|
||
type Props<Locales extends AllLocales> = Omit< | ||
ComponentProps<typeof BaseLinkWithLocale>, | ||
ComponentProps<typeof BaseLink>, | ||
'locale' | ||
> & { | ||
locale?: Locales[number]; | ||
}; | ||
|
||
export default async function BaseLink<Locales extends AllLocales>({ | ||
export default async function ServerLink<Locales extends AllLocales>({ | ||
locale, | ||
...rest | ||
}: Props<Locales>) { | ||
return ( | ||
<BaseLinkWithLocale locale={locale || (await getLocale())} {...rest} /> | ||
); | ||
return <BaseLink locale={locale || (await getLocale())} {...rest} />; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.