Suggested `/about` route clashes with dynamic `/[name]` route
Description
While following the getting start guide, the create a new project command (i.e. deno run -A -r https://fresh.deno.dev <project-name>) generates a default [name] dynamic route.
When the tutorial asks to create the about route, I believe that the new page visible at http://localhost:8000/about is captured by the [name] shipped with the create project command.
This may be confusing for some. Shall we update the docs accordingly? My assumption is that fresh prioritizes dynamic routes, is that correct?
Actual behaviour
| File name | Route pattern | Matching paths |
|---|---|---|
| routes/[name].tsx | /about | /about |
Expected behaviour
| File name | Route pattern | Matching paths |
|---|---|---|
| routes/about.tsx | /about | /about |
@ddayguerrero Cannot replicate this issue. Can you please share a recording or a screenshot?
https://user-images.githubusercontent.com/47249618/177854292-b182fb60-6600-4e48-a962-7afbdf2a79cc.mp4
@iamsahilsonawane, can't play your video — GitHub says it's corrupt.
@ddayguerrero, I created the new project but couldn't get the same result — while having both /about.tsx and /[name].tsx files, visiting /about route returns /about.tsx.
While I would say that preferred behavior should probably be the /about.tsx being returned instead of /[name].tsx, I do think that creating any /[dynamic].tsx routes in the same folder with /static.tsx routes should return either an error or a warning since it may lead to an unexpected behavior.
Thanks folks! I managed to render /routes/about.tsx with the /about path correctly while still having the routes/[name].tsx route.
I believe executing deno run dev.ts generated the manifest. My fresh.gen.ts file generated:
import * as $0 from "./routes/[name].tsx";
import * as $1 from "./routes/about.tsx";
import * as $2 from "./routes/api/joke.ts";
import * as $3 from "./routes/index.tsx";
import * as $$0 from "./islands/Counter.tsx";
const manifest = {
routes: {
"./routes/[name].tsx": $0,
"./routes/about.tsx": $1,
"./routes/api/joke.ts": $2,
"./routes/index.tsx": $3,
},
islands: {
"./islands/Counter.tsx": $$0,
},
baseUrl: import.meta.url,
};
I don't remember my previous approach... I believe I tried running deno run on production entry point of my project (i.e. main.ts) 🤷
I do think that creating any /[dynamic].tsx routes in the same folder with /static.tsx routes should return either an error or a warning since it may lead to an unexpected behavior.
The idea of having a signal would be helpful. Should Deno reinforce a standard? For comparison, NextJS static routes take precedence over dynamic routes.
@ddayguerrero, it's not something to do necessarily with Deno, but with Fresh. It seems that in Fresh, static routes do in fact also take precedence over the dynamic routes, but I'm not so sure. This needs to be tested and added into the documentation somewhere.
Can we close the issue?
Yep, thanks folks. I'll be keeping eyes on https://github.com/denoland/fresh/issues/475