kiliman / remix-flat-routes

Remix package to define routes using the flat-routes convention
MIT License
640 stars 22 forks source link

Nested + directories do not nest parent layouts correctly #73

Closed stephen776 closed 9 months ago

stephen776 commented 9 months ago

This is related to previous issue: #63 but I am opening a new one as the workaround suggested does not solve another (potentially more common) case:

I have a pathless layout directory and children within. I'd like all children to use the parent layout but I also want to use the + convention on said children. As I only have a single shared parent layout, I can't nest the parent inside personnel+

Here is a simplified directory structure

image

personnel+ should nest within the _dashboard layout but it does not. Here is the output of the route config:


  <Route file="root.tsx">
    <Route path="*" file="routes/$.tsx" />
    <Route path="auth/auth0" file="routes/_auth+/auth.auth0.tsx">
      <Route path="callback" file="routes/_auth+/auth.auth0.callback.tsx" />
    </Route>
    <Route path="login" file="routes/_auth+/login.tsx" />
    <Route path="logout" file="routes/_auth+/logout.tsx" />
    <Route file="routes/_dashboard/_layout.tsx" />
    <Route file="routes/_dashboard/personnel+/$personId.edit.tsx" />
    <Route file="routes/_dashboard/personnel+/create.tsx" />
    <Route index file="routes/_dashboard/personnel+/index.tsx" />
    <Route index file="routes/_index.tsx" />
    <Route path="resources/healthcheck" file="routes/resources+/healthcheck.tsx" />
  </Route>```
kiliman commented 9 months ago

You're missing the + suffix on the _dashboard folder. And _layout.tsx should be under _dashboard not personnel.

You can only have "naked" folders in the last segment since that is for collocation. You need to add the + suffix in folders for organization.

stephen776 commented 9 months ago

oh perfect!. Missing the + on _dashboard was the issue. Thank you!