-
Notifications
You must be signed in to change notification settings - Fork 2
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
Auto Route - Automatically generated routes. #6
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hi All, I've updated the main RFC post with a complete re-think based on @smolinari and I bashing it out in discord to try and cover all possible things that would be required. Looking forward to the feedback. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hi all! So my colleague @IlCallo asked me to share my opinion on this RFC since I've worked with Nuxt.js, and my thoughts are based on my experience with that framework . Directory structureMy main concern here is that this type of structure can be a little bit confusing to the developer. I think it's better to have all logic regarding a single route inside its own folder. To me, this means that (using the RFC example):
LayoutI think it would be be nice to have a separate folder in which to store layouts, so that a single layout can be used in different route components.
|
Hey! Thanks very much for the feedback! We appreciate you taking the time for it. Structure Layout meta File |
Talking about the last point: I think the problem is the |
Ah, whoops. It should be Just to clarify as well. We moved away from |
Hi, About the layout, I didn't though about that, but I think that yours could be a neat solution. About the structure I see your point. A possible solution would be to move all the child views inside their own folder and let the main component, which should be rendered by default, keep its name instead of being renamed to |
RE: Meta and Layout - Great!
I feel, when it comes to auto routing, that there is always going to be a dilemma like this because we're trying to automate something. When it comes to keeping its name, point 1 of the spec does allow for the default view having the same name as it's parent or using So it's about this point of nesting the children. One option could be to add an option to the meta file so that you can configure where the component(s) are: i.e With your experience in Nuxt, how do they avoid this kind of thing? |
Nuxt uses the same solution you proposed in the RFC: they use an The only difference is that they include the information you include in the I think that another solution for the sub folder issue would be to just place all What do you think about this? |
Right, I see. We initially thought about adding the routing info into the vue file but didn't want to be parsing all the files just for the routing info but you make a good point, having the meta also allows easy visibility of routing data. Glad to see we went the right way with that. RE: Children. EDIT: Removed. Misunderstood. Re-thinking :) |
Hi every one. This idea is amazing to big projects to order and centralize these recurring actions. i'm working in a front side modular project using Quasar as base. beginning i was thinking the same, generate routes according to exiting files but bellow i was needed manage this actions manually for add or config more especific actions. So i was code a way to auto load not just Routes, too Stores (Vuex) and this it's working so well for my and my working team. this is a example how i doing:
With this method, I create and manage routes with more order and faster, I also allow this information in What do you think about this? |
@michaelsoup Thanks for the thoughts. Whilst this might work for your team, I'm not sure of it's scalability for the needs of Quasar. That being said, it's not really on topic of this RFC - we are going down the file structure route, we're just trying to determine how the community would like us to do that. |
@webnoob nice job man. Seeing the functionality being theoretically created is just fantastic. When the feature is released, this issue must to appear at the bottom of the documentation page because this participation has been essential to developers and the community. |
Very eager to know the progress on this ... :) |
Just waiting on @rstoenescu to take a peak and provide his thoughts but I'm pretty happy with the spec at the moment. I'll start work ASAP. |
Horrible route if so much page, layout! Automatic generator route is needed. |
RFC (Request for Comments) Template
Please select your type of RFC (one or more):
Put an
x
in the boxes that applyOther
Does this introduce a breaking change?
Put an
x
in the box that appliesProposed RFC
Generate route definitions automatically, by reading the folder structure of the pages directory with the option to override on a route level using meta files.
Requirements
Configurable as to whether it'll generate routes or not (default Off).
quasar.conf.js
The following folder structure:
Generates the following routes:
Routing Conventions
If a .vue file and a path below it match names (including brackets and underscores), the .vue file must be a
router-view
and the folder beneath it are its child pages. If in the children, there is an index.vue file, it is considered "pathless" and would be the first page to be shown when navigating to that route. If there is a .vue file which matches the parent folder, that'll be the default route otherwise (when no index vue file exists) and will also be considered pathless._foo
- an underscore in front of the word means the word is a parameter. So, in the example vue filebaz_foo.vue
, "foo" is a parameter for "baz". There can be multiple parameters such asbaz_bar_foo.vue
.[foo]
- brackets around the word means it is optional. A path or a parameter can be optional./[foo]
would be an optional path. Inbaz_[bar].vue
, "bar" would be an optional parameter for "baz"./foo!
- an exclamation mark after a folder name means it is a wildcard path. So, a folder with the name/foo!
will translate to/foo/*
. In most cases, you'll also need to add a same named.meta.[js|ts]
file below the wildcard path (folder) to add your specialized routing rules, including any reroutes to a 404 page, where necessary.A same-named
.meta.[js|ts]
file will be a container for any additional overriding, validation, guarding, etc. More details on this is below.Example Meta File / Override route info
index_[post-id].meta.js
With the above meta file defined, the route for
pages/blog_category/index_[post-id].vue
will now look like:Everything under
route: { }
will be assumed as standard vue-router properties and will in turn be added directly to the route.Additional properties will go on the same level as
route: {}
.Meta File MeProperties
lazyLoad: boolean = true
- Whether the route should be added as a lazy loading route or not.parameters: ['param1', 'param2', 'param3']
- These parameters will be added to the route, for instance a filesome-path.vue
with this meta file property set would have a path generated likesome-path/:param1/:param2/:param3
. The idea for this is to avoid long file names when a route needs many params.route: RouteConfig = {}
- RouteConfig propertes which will be attached to the generated route i.ebeforeEnter
.Layouts &
This is dealt with in point 1 of the Routing conventions above. It is up to the developer to chose what file they would like to use as a layout and also how that file is named. For instance, a layout file could be defined like so:
It would then be clear to the users this was a layout but because there is a folder matching the file name, it would know that there is a
<router_view />
contained within that file and the files below the same-named folder are the router-view's child pages.To index.vue or not to index.vue?
It would be up to the developer to decide if they would like to use
index.vue
as the route / pathless view of that route. Point 1 of the convention again gives us a way by allowing us to either useindex.vue
or a file with the same name as the parent folder.index.vue
if specified will always take precedence over a same named file.Dev only pages (
__something.vue
)These will only be generated in the
routes.[js|ts]
file when running in dev mode e.gquasar dev
.Development Notes
We will refer to the UI Kit for code generation regarding fetching of files and routing (see: https://github.com/quasarframework/quasar-starter-kit-ui/blob/master/template/ui/dev/src/router/pages.js) however, we will need to make sure the call to
require.context()
uses the fourth paramlazy
so as to honor lazy loading components.The text was updated successfully, but these errors were encountered: