getResourceFromContext returns null for dynamic page generation
See original GitHub issueHi
I have the following file pages/[LB].tsx
I want to fetch a page that has the layout builder many blocks inside of it.
here is the code
import Badges from "@/components/Home-page/badges";
import { DrupalClient, DrupalNode } from "next-drupal";
import { Fragment } from "react";
const drupal = new DrupalClient(process.env.NEXT_PUBLIC_DRUPAL_BASE_URL);
export default function LB(props){
console.log('props.node: ', props);
return (
<Fragment>
<h1>Tesing dynamique LB pages rendering.</h1>
</Fragment>
);
}
export async function getStaticPaths(context) {
console.log('context: ', context);
return {
paths: [
{
params: {
LB: await drupal.getStaticPathsFromContext("node--page", context) + ''
}
}
],
fallback: 'blocking',
}
}
export async function getStaticProps(context){
const node = await drupal.getResourceFromContext<DrupalNode>("node--page", context);
return {
props: {
node,
},
};
}
what it returs:
props: {
"node": null
}
Thanks a lot.
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
getResourceFromContext returns null for dynamic page ...
Hi. I have the following file pages/[LB].tsx. I want to fetch a page that has the layout builder many blocks inside of it....
Read more >Building Pages - Next.js for Drupal
How to build pages using JSON:API resources from Drupal. ... You can use Next.js dynamic route to build static pages for Drupal entity...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You don’t need the params part. This is handled for you.
See https://next-drupal.org/docs/pages#advanced-example