-
-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getPathname with params #1274
Comments
This question has come up a few times already though, I've now clarified this a bit in #1275. Hope this helps! |
That's great and I can confirm it does work as expected but I think there's some issue with the type definition for
when calling Which is actually the reason why I did not know that I could pass in a params object. (Sidenote: since we're at it I caught a typo on the updated docs PR #1275: "If you're use the same pathnames for all locales...") |
Thanks, fixed the typo in 3ef6bea! It's actually not a bug in the types, E.g.: const test: string = '/asdf';
// ❌ Type 'string' is not assignable to type '"/" | "/about"
getPathname({locale: 'en', href: test});
// ✅ Works
getPathname({locale: 'en', href: '/about'}); Similarly, In case you need to provide arbitrary |
Maybe I'm missing something on my setup then because I'm not using arbitrary strings and still getting that type error. Here's a minimal reproduction of the error following my current setup architecture:
I'm getting this error for the
And no error for I'm also not getting any intellisense autocomplete suggestions for the pathname of the Href |
Oh right, I think you had the same issue that I just fixed in that PR before. See here: https://github.com/amannn/next-intl/pull/1275/files#diff-28315a1743287da414ba279f75543ef824afe446dcfbe5fa579f5c07df2485b1 The key is using |
Awesome I had missed that change, tysm! |
Is your feature request related to a problem? Please describe.
I'm using the sitemap generation for my app following the example provided here.
However when I try to run that script I get an error saying:
Error: Insufficient params provided for localized pathname.
because I have some pathnames that take in some route params.Describe the solution you'd like
It'd be great if the
getPathname
function that we get from callingcreateLocalizedPathnamesNavigation
would take in a params object like therouter.replace
method does:router.replace({ pathname, params, query }, { locale })
(i.e.:getPathname({locale, href, params})
)Describe alternatives you've considered
Generating the sitemap entries for routes that have params in a more manual fashion by putting together the urls with their params in each language. This would however lead to less maintainable code.
The text was updated successfully, but these errors were encountered: