oedotme / generouted

Generated file-based routes for Vite
https://stackblitz.com/github.com/oedotme/generouted/tree/main/explorer
MIT License
1.04k stars 48 forks source link

Folders without an index file create empty routes #157

Closed ferretwithaberet closed 7 months ago

ferretwithaberet commented 7 months ago

Describe the Bug

Folders without an index file create empty routes

Generouted Version

1.18.5

Your Example Website or App or Reproduction

https://stackblitz.com/edit/vitejs-vite-jbnrwj?file=src%2Fpages%2Findex.tsx&terminal=dev

Steps to Reproduce the Bug or Issue

  1. Create a route structure like:
    - segment1/
    - segment2/
        - index.tsx
    - 404.tsx
  2. Navigate to /segment1, observe that the router matches and an empty page is shown, even though there is no index.tsx

Expected Behavior

When navigating to /segment1, it should show the 404 page.

Screenshots or Videos

No response

Platform

Additional context

No response

oedotme commented 7 months ago

@ferretwithaberet That's mainly react-router matching for the routes config, you could see a related warning the devtools console — tbh that's kind of expected but feel free to report there if you find it an issue.

To get around that, you could try:

Here's the updated example I've tested: https://stackblitz.com/edit/vitejs-vite-7e9xxf?file=src%2Fpages%2Fseg1.seg2.tsx

Hope that helps.