Skip to content
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

Support overriden route names (through definePageMeta) #81

Open
ChronicStone opened this issue Mar 28, 2023 · 6 comments
Open

Support overriden route names (through definePageMeta) #81

ChronicStone opened this issue Mar 28, 2023 · 6 comments

Comments

@ChronicStone
Copy link

It looks like the generated types definition does not take into account overriding of route name using definePageMeta. Here's an actual example :

// DEFAULT PAGE NAME SHOULD BE "testCenter-candidates-candidateId" HERE

definePageMeta({
  name: "testCenter-candidates-profile",
});

navigateTo({ name: "testCenter-candidates-candidateId", params: { candidateId: "hjzez" } });
// VALID NAME, even though the name has been overridden

navigateTo({ name: "testCenter-candidates-profile", params: { candidateId: "hjzez" } });
/*  No overload matches this call.
  Overload 1 of 2, '(to: TypedRouteLocationRawFromName<RoutesNamesList, string>, options?: NavigateToOptions | undefined): Promise<...>', gave the following error.
  Overload 2 of 2, '(to: string, options?: NavigateToOptions | undefined): Promise<void | NavigationFailure | TypedRouteFromName<never>>', gave the following error.ts(2769)

*/

Is this an actual limitation, or something that can be addressed ?
@victorgarciaesgi
Copy link
Owner

Hi @ChronicStone ! I will look at what is generated Nuxt-side as the generated types are based on what Nuxt provides in terms of routing, did you check in the devtools that the route name is changed, or just the component name?

@ChronicStone
Copy link
Author

Hi @victorgarciaesgi, the name in definePageMeta works fine, it's the one that's displayed in the nuxt devtools. Also, if I try to use the default name, the one I've replaced (that autocomplete correctly), then it does not work because that name isn't matching any route.

@victorgarciaesgi
Copy link
Owner

Sorry for late response.

After tests yeah I have the same as you, displaying in router devtools. But as i'm generating what nuxt gives me i'm wondering if it send the correct router output in the module hook. I'll check and keep you updated

@victorgarciaesgi
Copy link
Owner

the nuxt-i18n-module don't support this behaviours either, I will open a bug on nuxt side

@victorgarciaesgi
Copy link
Owner

infortunetly Daniel Roe responded that it's not possible to access it within the module, i'll see how can I work around this

@Sakamitsu
Copy link

Since nuxt 3.12 scanPageMeta feature enabled by default, so I think this issue can be closed.
You can now overriden name and path through definePageMeta, after compilation (npm run dev or npx nuxi prepare) the generated types will be as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants