Skip to content

Mapping dynamic route parameter values to aliases for use in the url #1283

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

Closed
Harper04 opened this issue Mar 28, 2017 · 3 comments
Closed

Mapping dynamic route parameter values to aliases for use in the url #1283

Harper04 opened this issue Mar 28, 2017 · 3 comments

Comments

@Harper04
Copy link

Feature request

Hi,

i came to the need of having to map an enum parameter to an url parameter.
Like:
Possible Values for
FooType = ['bigFoo', 'littleFoo', 'specialFoo', 'dumbFoo', 'otherFoo']
So a route using a FooType Parameter could look like this:

/foos/:fooType/:id
/foos/bigFoo/3
/foos/specialFoo/3
/foos/otherFoo/3

For usabillity, SEO, requirements, etc. reasons i need to show values which the user can relate to.

/foos/YOURBIGFOO/3
/foos/SPECIALFOONESS/3
/foos/MISCFOOS/3

The best way to implement this would be a 1:1 Mapping defined in the route definition. For now i have to either create a lot of routes or use the displayed values and do the mapping everywhere i want to use the parameter.

@posva
Copy link
Member

posva commented Mar 28, 2017

@Harper04 What is wrong about creating different routes for different things? If you need some reusability you can create a function that returns the route object for you

function generateFooRoute (type) {
  return {
    alias: type,
    path: `/foos/${type}/:id`,
  }
}

@posva
Copy link
Member

posva commented Apr 4, 2017

Closing due to inactivity.

@posva posva closed this as completed Apr 4, 2017
@Harper04
Copy link
Author

Harper04 commented Apr 4, 2017

Sorry, i tend to not respond to messages i consider off topic.
Your response did question my use case which my collegues and i consider to be valid. In general messages like i have a problem with X, why dont you use Z are not helpful for the matter.

Furthermore your response did little to address my problem, which may be my fault if i was not clear enough. I don't want to seperate different things... URLs are no implementation detail, they are user facing and used by search engines, so a mapping is a valid use case.

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

No branches or pull requests

2 participants