withastro / roadmap

Ideas, suggestions, and formal RFC proposals for the Astro project.
292 stars 29 forks source link

Wrong RouteData during build #648

Closed Jelenkee closed 1 year ago

Jelenkee commented 1 year ago

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

matthewp commented 1 year ago

Yeah, we really need to redesign the RouteData object.

ematipico commented 1 year ago

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

matthewp commented 1 year ago

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.

bholmesdev commented 1 year ago

@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

natemoo-re commented 1 year ago

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.