generouted
generouted copied to clipboard
Colocating non page components
One of my gripes with file based routes is you usually cannot co-locate components that belong to a page in the same folder. Is this possible with this package?
Something like:
- pages/contact/index.ts
- pages/contact/_components/form.tsx
It sounds like a good default to be added in generouted
, thank you for bringing that up. Also seems pretty straight forward to filter out private paths, will try to add that in an upcoming release.
If I understand correctly, any page path contains directory or route starts with an underscore will be ignored:
-
/pages/_private.tsx
-
/pages/contact/_components/button.tsx
-
/pages/contact/_components/tabs/index.tsx
I'm not sure if the underscore prefix is the right call but it seems somewhat inline with other patterns I've seen, which is why I suggested it. Thanks for fast response and interest
➕ for this, I think the underscore prefix is a good default here and I would love the ability to co-locate page-related components in generouted 🤓
I'm not sure if you've seen it, Next.js 13 is now allowing pages to be collocated with components. They are doing it in a way that is retro-compatible with the existing pages/ paradigm in order to facilitate gradual adoption. It's pretty cool, check it out: https://nextjs.org/blog/next-13#app-directory-beta
If you want to stay close to what Next is doing, an App/ folder would be a very worthwhile feature.
(image taken from the page linked above)
IMHO the separation between routes and components makes it more clear. I like the idea to support co-locating page related components as it might be handy and expected but it's not my personal preference.
If you want to stay close to what Next is doing, an App/ folder would be a very worthwhile feature.
Next.js new router is very promising, but I see it offers much more than the routing conventions.
This is a related opinion/take 😄: https://mobile.twitter.com/delba_oliveira/status/1586666502039691264
Quick update, supporting co-locating non-pages files inside pages/
directory with _
prefix was added here https://github.com/oedotme/generouted/commit/87ed45417f0882d2fae058401c4a65d13fc9d9d2.
Another related update, _layout.tsx
is also now supported (similar to Expo router and Next.js new router) https://github.com/oedotme/generouted/issues/13
Will close this issue with a new version release, after some required docs updates.