I’m creating a small CMS with a Drupal backend (https://www.contentacms.org/) for Ember. In the backend I have a field to define a path for each page. I’m having trouble how to architect the routing in a bice way. I would like to avoid using page ID and just use the path defined in the backend.
this is a property I can access through my api as one string /foo/bar/baz.
What I’m having trouble is defining my router so I can use the path defined in the api. It works when the slug is simply /foo or /bar. But what do I do if the slug is /foo/bar or just `/´ or any other length.
I’m also having trouble with the menu. How can I define a LinkTo helper that would work for any url length. {{#link-to 'page' item.alias}} only works for urls in the first level.
Also I’m wondering how I would approach converting internal links that are used inside the body field with link-to helpers. I’m also having the same issue in the menu.
I would like to avoid using page ID and just use the path defined in the backend.
You might break saved URLs if the path value changes. If you are using the same route/controller/template to load and display all the paths, you could do:
The problem is what do I do if the path has several segments. /segment-one/segment-two Doesn’t the link to helper have to look different depending on the amount of segments? How can I anticipate that.
I would wanna avoid to slugify urls as I would want to give authors the flexibility to structure their webpage via url paths.
I will use @ryanto approach works for the link-to helpers as well. For links that the authors place in the body field I would probably have to process the content of the field or just have a full page reload.