DEV Community

loading...

Discussion on: How to redirect in SvelteKit endpoints

Collapse
spences10 profile image
Scott Spence • Edited

So I'm currently looking to move from my old blog, which has a filing structure like:

content/posts/2021/06/some-post-title/index.mdx
Enter fullscreen mode Exit fullscreen mode

In my blog currently that will be mydomain.com/2021/06/some-post-title

I'm looking to move to SvelteKit and use MDSveX and with Vite and the routing doesn't allow that (which I have found, and I've looked, like, a lot) so I'm looking to simplify the routes to something like:

src/routes/posts/some-post-title.svx
Enter fullscreen mode Exit fullscreen mode

How would I structure the redirects so that I'm not creating a path for each of the existing routes (130 odd)?

Do you have an example or some source code I could check out?

Thanks

Collapse
danawoodman profile image
Dana Woodman Author

You've added MDSvex with this adder? github.com/svelte-add/mdsvex

And you can't create a file like this src/routes/posts/2021/06/some-post-title/index.svx and then navigate to /posts/2021/06/some-post-title?