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
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
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?
Software hacker working in the industry since 2003. Currently loves: #Typescript and #Svelte. Founder of Chimera, the first makerspace in northern California.
Thanks to @askrodney who helped me work this out...
For anyone else that has the same specific issue as me, make a file structure that mirrors the old filing structure, this is in the src/routes folder:
Then in the index file:
<!--
Redirects from my old blog filing structure yyyy/mm/dd/post-title
to posts/post-title thanks to rodneylab for the example 👇
https://github.com/rodneylab/sveltekit-blog-mdx/blob/dev__redirect/src/routes/%5Byear%5D/%5Bmonth%5D/%5Bday%5D/%5Bslug%5D/index.svelte
--><script context="module">exportasyncfunctionload({page}){const{slug}=page.paramsreturn{status:301,redirect:`/posts/${slug}`,}}</script>
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
So I'm currently looking to move from my old blog, which has a filing structure like:
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:
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
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
?Thanks to @askrodney who helped me work this out...
For anyone else that has the same specific issue as me, make a file structure that mirrors the old filing structure, this is in the
src/routes
folder:Then in the index file: