Export page utility functions
Describe the feature
- Related https://github.com/nuxt-modules/i18n/issues/2411
- Blocks https://github.com/nuxt-modules/i18n/pull/2408
In @nuxtjs/i18n (v8) we manually sync the implementation of parseSegment and getRoutePath as these are not exported. Not sure if exporting as is, or in @nuxt/kit, or elsewhere would make more sense.
Additional information
- [X] Would you be willing to help implement this feature?
- [ ] Could this feature be implemented as a module?
Final checks
- [X] Read the contribution guide.
- [X] Check existing discussions and issues.
We think it would be good to create a single library we can depend on in Nuxt and in i18n.
If @posva would like to expose it we could depend on it, otherwise I am happy to create a library.
Do you mean the matcher? Or do you have some specific functions in mind? There is already an exposed createMatcher(). It's marked as internal of course as it's not intended for broader usage but it's fine if well-known parts of the ecosystem like Nuxt and i18n use it. A few years ago I started a project to open source the underlying layers of the route parsing but I never made it public 😅
I'm meaning a library to convert/parse file system paths into route matching syntax.
There is already an exposed createMatcher(). It's marked as internal of course as it's not intended for broader usage but it's fine if well-known parts of the ecosystem like Nuxt and i18n use it.
I have been holding off on using this for i18n routing since it was marked internal 😅 .. I'll look into using it.
A few years ago I started a project to open source the underlying layers of the route parsing but I never made it public 😅
I would be interested in this, for i18n routing I keep on wanting to use Vue Router internal utilities like parseURL, parseQuery as well as their stringifying couterparts. We want to match the behaviour of Vue Router, as we internally parse paths and change it a bit to resolve a localized route, especially encoding/decoding paths has been difficult to match, but maybe createRouterMatcher is intended for such use cases.
I'm meaning a library to convert/parse file system paths into route matching syntax.
This would be useful for Nuxt i18n (and other file based i18n routing as well https://github.com/nuxt-modules/i18n/pull/2686#issuecomment-1890951656 /cc @kazupon), I don't think https://github.com/posva/unplugin-vue-router exposes this right?
I have also found myself copying these functions in some modules so quite interested in this.
Just commenting to add a link to https://github.com/unjs/unrouting (the library was described here but not referenced)