#How to route to paginated rest folder and sub-folder (SSR)

5 messages · Page 1 of 1 (latest)

brazen topaz
#

Is it possible to route to this file structure?

src/pages/
├── index.astro
├── blog/
└── ├── [sub_blog]/
    │   └── [...page].astro
    │   └── [slug].astro
│   └── [...page].astro
│   └── [slug].astro

where the site is static, except for the two [...page].astro files, which are SSR.
As it is now, both /blog/2 and /blog/other-blog/2 get routed to /blog/[sub_blog]/[...page].astro, which makes sense according to the routing order of things. But, is there a way to make this work? Or do I need to re-think this structure?

limpid jay
#

@gritty loom would you be able to shed any light on this?

gritty loom
#

Hey 👋
Rest parameter can be undefined, matching the URL without them.

So [sub_blog]/[...page].astro in SSR matches any URL

#

In SSG you can use that structure fine as long as no two files produce the same route in the end

But in SSR, any URL will be handled by the first route that matches, and only the first. Other routes won't be tried in the first route doesn't work

#

So when using SSR your routes need to resolve which file will serve a URL based only on the filenames, nothing else.
You'll have to organize your structure around that