-
I am fetching data from an API, including the folder structure. Because the folder structure is unknown, I cannot create the folder under routes. Instead I would like to fetch, e.g. "class-a/this-is-interesting" and pass that to loader through params. However, params will not take anything with a slash, /, and will only get "this-is-interesting." Is there a way to return the full path (including slashes in the middle) in the loader? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Create a splat route ( // routes/blog/$.tsx
export loader: LoaderFunction = async ({request, params}) => {
const slug = params['*']
...
} So for request |
Beta Was this translation helpful? Give feedback.
Create a splat route (
$.tsx
). Then you can get the full path in your loader:So for request
/blog/test-series/post-1
, the slug would betest-series/post-1