You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So here's my problem, I'm using a Headless Drupal as an API for a Next/Drupal boilerplate project, and I am trying to figure out a thing or two.
Back in November 2019, it was announced that getStaticPaths could not be nested one into another, but I really need to achieve it (and maybe since then it is somehow feasible).
For now, my routes look like this :
pages
|
--[type]
|
|
--[slug].js
|
--index.js
In my index.js, I fetch all the content types that exist on the API (like article, page, event, etc...) and generate a "main" view listing all the nodes.
In [slug].js I would like to retrieve the [type] value in order to use it in the fetch that is used to retrieve every single node from my content type and feed the paths of getStaticPaths.
The thing is, there is no params to get in getStaticPaths even if the page is one level below it.
Is there any hack to get this upper-level param ? I tried using the router in order to get the path but of course, since we are generating a static build, the router is null at this specific moment.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everybody,
So here's my problem, I'm using a Headless Drupal as an API for a Next/Drupal boilerplate project, and I am trying to figure out a thing or two.
Back in November 2019, it was announced that getStaticPaths could not be nested one into another, but I really need to achieve it (and maybe since then it is somehow feasible).
For now, my routes look like this :
In my index.js, I fetch all the content types that exist on the API (like
article
,page
,event
, etc...) and generate a "main" view listing all the nodes.In [slug].js I would like to retrieve the
[type]
value in order to use it in the fetch that is used to retrieve every single node from my content type and feed the paths ofgetStaticPaths
.The thing is, there is no params to get in
getStaticPaths
even if the page is one level below it.Is there any hack to get this upper-level param ? I tried using the router in order to get the path but of course, since we are generating a static build, the router is null at this specific moment.
Thanks in advance,
Beta Was this translation helpful? Give feedback.
All reactions