Comments (4)
There is already some sorting mechanism (see
next-roots/src/router/router.ts
Line 76 in 5b659c0
[β¦
to the end.
IMO we need:
- Non-dynamic routes/segments to come first
- Dynamic but not catch all as second
- Catch all as third
Probably we need to sort routes segment by segment with above rules? But that could harm performance
from next-roots.
One thing cane to my mind - we can represent each segment as a number:
- static segment = 1
- dynamic = 2
- catch-all or optimal catch all = 3
For each route we can then compute its weight represented as decimal number like:
/static/[dynamic]
= 0.12
/[dynamic]/[dynamic]
= 0.22
/[dynamic]/static
= 0.21
/[β¦catchAll]
= 0.3
Then simple sort of decimal numbers can do the trick. We can even calculate this map only once.
What do you think?
from next-roots.
Crystal clear! Geat idea.
I can propose a PR for this.
I might need some help to rework the tests for the best. I'll tell you .
from next-roots.
π This issue has been resolved in version 3.10.1 π
The release is available on:
Your semantic-release bot π¦π
from next-roots.
Related Issues (20)
- getHref should return the most specific route HOT 5
- Question about language detection HOT 9
- Question about usage HOT 2
- question regarding a possible --watch option HOT 4
- Source folder wiped completely when roots script runs into error HOT 3
- How to Handle Dynamic Slugs with Translated Slugs? HOT 4
- Type error at build time HOT 5
- How to generate route with optional catch-all segments? HOT 6
- CSS/favicon issue when integrating with app created by `npx create-next-app` HOT 2
- No utility classes were detected in your source files. (tailwind.config.ts)
- getHref in route with multiple dynamic params HOT 3
- next-roots - Given rewrite is not a page route rewrite. HOT 2
- Is there a downside of using Inlang compared to next-roots? HOT 2
- Feature Request: skip page generation for specific languages HOT 6
- Add support for localising .js pages HOT 1
- Support for Es module? HOT 4
- Feature Request: Allowing "Generate params from the top down" for route with multiple dynamic segments HOT 6
- Feature Request: Include `generateStaticParams` Function in Generated `layout.tsx` Files HOT 1
- Running yarn next-roots: cannot find modules node-watch, parse-typed-args and path-to-regexp HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-roots.