Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Top level dynamic routes are prioritized #11394

Open
1 task
mrchantey opened this issue Jul 1, 2024 · 5 comments
Open
1 task

Top level dynamic routes are prioritized #11394

mrchantey opened this issue Jul 1, 2024 · 5 comments
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) pkg: node Related to Node adapter (scope)

Comments

@mrchantey
Copy link

mrchantey commented Jul 1, 2024

What version of starlight are you using?

0.24.5

What version of astro are you using?

4.10.2

What package manager are you using?

npm

What operating system are you using?

Windows

What browser are you using?

Chrome

Describe the Bug

According to route priority order static files are prioritized over dynamic routes, however top level dynamic routes break starlight routes.

To see the effect click on the primary action button which redirects to a dynamic route.

An example use for this is github-style top level username routes: [username]/[project].astro

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-61gc9w?file=src%2Fpages%2F%5Busername%5D%2F%5Bproject%5D.astro

Participation

  • I am willing to submit a pull request for this issue.
@delucis
Copy link
Member

delucis commented Jul 1, 2024

Thanks for the issue @mrchantey.

In the docs, what is meant by “static routes” are routes without any parameters (e.g. src/pages/something.astro), but Starlight pages are actually generated using a [...path].astro route under the hood, so I think the two-part, user-defined dynamic route in your example is winning.

One thing I’m seeing with your reproduction is that if I build the project (I added the Node adapter to do this), the production site does serve Starlight’s pages before hitting the dynamic route. See https://stackblitz.com/edit/github-61gc9w-qyzhpu and then run npm run preview. So there’s an inconsistency between the dev server and the build in this case.

I’m not 100% sure what the expected behaviour is here based on the docs, but hopefully it’s that the static pages always win and this is just a dev server bug.

@mrchantey
Copy link
Author

Oh awesome thats super helpful, yeah i hadn't tried a preview but noticed the static files in dist and thought somehow they were being skipped 😅
Ill have a play with it, might be able to do a dev-mode-only redirect or something.

@delucis
Copy link
Member

delucis commented Jul 1, 2024

I chatted a bit with @Fryuni who implemented the routing priority rules in Astro and he said that unfortunately the dev server behaviour is the correct behaviour as currently specced. So technically it working in production with the Node adapter is a “bug” 😅

Seems a bit of a limitation to me, so we’ll chat to see if there’s a way to make this more easily configurable. To my mind users would always want a Starlight slug for which there is a content file to be served, and then their dynamic SSR routes to kick in.

@delucis
Copy link
Member

delucis commented Jul 1, 2024

OK, moving this across to the main Astro repo for @Fryuni to think about how to handle best 🫡

@delucis delucis transferred this issue from withastro/starlight Jul 1, 2024
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jul 1, 2024
@Princesseuh Princesseuh added - P3: minor bug An edge case that only affects very specific usage (priority) pkg: node Related to Node adapter (scope) and removed needs triage Issue needs to be triaged labels Jul 17, 2024
@ematipico
Copy link
Member

@Fryuni any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) pkg: node Related to Node adapter (scope)
Projects
None yet
Development

No branches or pull requests

5 participants