#DRY approach to grouping routes

1 messages · Page 1 of 1 (latest)

dense sparrow
#

you could keep the pages out of the pages folder and use the pages:extend hook in your nuxt.config

hooks:{
     'pages:extend': (pages) => {
         pages.push({
             name: 'example-page',
             path: '/example-page',
             file: 'auth-pages/example-page.vue',
         });
     }
 }

#

or keep them in the auth folder and just add aliases using the above

latent onyx
#

I know about this method, but it is not a very clean solution. Nuxt should provide such feature out of the box. For example, putting folder name in brackets wouldn't add anything to the path.

dense sparrow
#

putting a folder name in brackets turns it into a route parameter

latent onyx
#

I don't mean square brackets

#

So they should provide an opportunity to logically group related routes

dense sparrow
#

they do, it's called folders 🙂

#

you can always opt out of using the folder based routing

latent onyx
#

What are you talking about, I don't understand

#

You create a folder and it becomes a part of the path

#

You didn't understand the question

dense sparrow
#

yes, that is part of the logical organization of related routes

#

ok have a nice day

latent onyx
#

It isn't practical to have, for example, auth prefix for the login path. For this reason you don't want to have folders affecting paths all the time

#

You will come across such a problem if you work on medium or big projects with many routes

#

I am coming from custom routing. I have actually switched to file-system routing because they have awful support for custom routing rn. No way to assign middleware and most modules are built on file-system routing (e.g. i18n, sitemap, etc.).

dense sparrow
#

yes i've worked with very large projects/apps with many routes, all of them have the auth prefix

latent onyx
#

Because of the constraints imposed by Nuxt

#

While in reality, it shouldn't be like that

#

For SEO, as well, it is preferable to provide shorter paths

dense sparrow
#

i appreciate your opinion, it would be wise of you not to insult or talk down to people helping you

#

ciao

latent onyx
#

I'm not insulting you, mate. Just you haven't read my question properly

dense sparrow
#

i assure you i have and i understand what you are looking for, that is why i have given you options that are clearly applicable.

#

so yes, you're talking to me like i don't understand things when i've obviously provided relevant answers that you simply don't like

latent onyx
#

I appreciate you effort. But the solutions you provided do not really address the problem. You are telling me what I already know, that it is a good practice to accept the folder based routing as it is, with folders reflecting on paths. But the solution I am looking for is actually QOL improvement for better readability.

#

With regard to Custom Routing, as I said, there are many problems with its support

#

But anyway, they seem to be adding route grouping in Nuxt 4