0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-06 22:10:10 -05:00
astro/.changeset/short-keys-bow.md
Luiz Ferraz fd17f4a40b
Implement priority overrides for injected routes and redirects (#9439)
* Implement priority overrides for injected routes and redirects

* Fix ordering for route specificity

* Don't mix rules on tests

* Detailed collision detection

* Add changeset

* Remove TODO

* Add comments to clarify default values

* Update terminology

* Revert unrelated changes

* WIP

* Refactor

* Fix typo and typing

* chore: default to legacy

* chore: use experimental flag instead of option

* fix: do not throw an error on collisions

* chore: fix regression

* chore: use `continue` instead of `return`

* chore: fix tests but one

* chore: Update test

* chore: Change remaining new error to warning

* chore: Test collision warnings

* docs: Update docs of new config

* docs: Improve changesets

* chore: rename experimental flag

* chore: update changeset and docs

* Sarah editing pass

* nit: Align Markdown table

* defined definitions!

Co-authored-by: Luiz Ferraz <luiz@lferraz.com>

* added logging info to docs for experimental flag

* Yan final boss review

Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com>

* chore: Update flag name in tests

* chore: Update flag name in tests

---------

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com>
2024-01-17 13:28:18 +00:00

983 B

astro
patch

Updates Astro's routing priority rules to prioritize the most specifically-defined routes.

Now, routes with more defined path segments will take precedence over less specific routes.

For example, /blog/posts/[pid].astro (3 path segments) takes precedence over /blog/[...slug].astro (2 path segments). This means that:

  • /pages/blog/posts/[id].astro will build routes of the form /blog/posts/1 and /blog/posts/a
  • /pages/blog/[...slug].astro will build routes of a variety of forms, including blog/1 and /blog/posts/1/a, but will not build either of the previous routes.

For a complete list of Astro's routing priority rules, please see the routing guide. This should not be a breaking change, but you may wish to inspect your built routes to ensure that your project is unaffected.