Closed edimitchel closed 5 years ago
Interesting. If it wasn't working before your fix, can you describe, what was wrong? Parent route wasn't working on client-side navigation, am I right? And can you provide your nested routes structure?
What I found out is that nested routes generation doesn't work right, thanks to your help. In my implementation, only child-route has been extracting to payload.json, which is wrong for parent-route. But in your implementation only parent-route is extracting right data to payload.json (because .find returns first true value from array), which is wrong for child-route. In other words, with your approach, on client-side navigation to child-route, you should have payload.json with data of parent-route. With my approach it is another way around and still wrong.
To solve the issue, we need to get nesting-level of current route. Maybe I'll try to calculate it from route path. What do you think about this?
Interesting. If it wasn't working before your fix, can you describe, what was wrong? Parent route wasn't working on client-side navigation, am I right? And can you provide your nested routes structure? I have a nested route like :
/_lang/blog/_slug
and/_lang/blog/_slug/_page
. The two last nested routes didn't getpayload.json
built properly (empty :{ }
).
I debug in local for looking the issue, and I found that data of the most nested route is a double array, with the last empty. The code takes always the last one.
What I found out is that nested routes generation doesn't work right, thanks to your help. In my implementation, only child-route has been extracting to payload.json, which is wrong for parent-route. But in your implementation only parent-route is extracting right data to payload.json (because .find returns first true value from array), which is wrong for child-route.
You're may be right.. I will check this. I've perhaps miss something..
In other words, with your approach, on client-side navigation to child-route, you should have payload.json with data of parent-route. With my approach it is another way around and still wrong. To solve the issue, we need to get nesting-level of current route. Maybe I'll try to calculate it from route path. What do you think about this?
I'll see this tomorrow ;)
Thanks for your reply !
Cool, it works, but:
I'll think about it tomorrow, in case I'll have night dream about better implementation...
All data available for providing payload on nested routes
By this way, all payload are extracted for routes (nested too).
It works for my personal website.