Fix missing styles for dynamic routes rendering <StarlightPage>
#2905
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a repro for an issue happening when a dyanmic route using a rest parameter renders a
<StarlightPage>
component. Just by having such setup, an unrelated page, e.g. the home page, rendering a component that includes some styles, will not have the styles applied.This happens only when the route is using a rest parameter, and the
<StarlightPage>
component is rendered in the dynamic route. If one of these conditions is not met, the styles are applied correctly.This is also a dev-only issue, as the production build works as expected.
This PR also includes a potential workaround, which hopefully is not needed but helps understand the issue, by moving the
useRouteData
function used inroutes/common.astro
to a dedicated file. At the moment, I've left the original implementation in place so it's easy to change the import path to test the issue and the workaround.I have not yet understood the root cause of the issue, if we're doing something specific that triggers an issue in Astro (or maybe Vite?) but wanted to share my findings so far.
Notes: