withastro/roadmap

Wrong RouteData during build

Jelenkee opened this issue · 5 comments

What version of astro are you using?

1.9.1

Are you using an SSR adapter? If so, which one?

no

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

When printing out the routeData for a dynamic route (e.g. test-[id].astro), a url for a specific page is printed.
image

Perhaps you should remove the distURL for dynamic routes. Or even better, add all URLs for the route to the routeData

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-9zdqva?file=astro.config.mjs,src%2Fpages%2Ftest-[id].astro&on=stackblitz

Participation

  • I am willing to submit a pull request for this issue.

Yeah, we really need to redesign the RouteData object.

@matthewp what's the best course of action for this issue? I'd gladly make a PR for that

The problem here is that distURL points to the file that was created for the route. This only works for SSG as obviously there are no files in SSR. Also this is a single URL which doesn't work for dynamic routes.

I would probably suggest adding a distURLs property that is an array of all URLs. And then deprecating distURL. Would ask @bholmesdev to chime in as I believe he added this property for sitemaps if I remember correctly.

@matthewp Ah yep, I agree with that refactor idea! Also think exposing RouteData as-is was... not the best idea. Many properties exposed that have unclear use cases. +1 to making a PR with that change and elevating this for v3 discussion

Unfortunately this isn't going to make it into 3.0, but we'd love to move this over to our roadmap so we can discuss the best design for this feature. astro:build:done is kinda wonky right now and deserves some thought and discussion.