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
Today while developing a project for a client I just realized I could use [type-of-page]/[slug].js, I was planning to have these SSG'd but the getStaticPath does not provide any context for the request as in getStaticProps. So what I'm trying to do is:
export async function getStaticPaths() {
const data = await getAllRelatedPages(/*[type-of-page]*/); // 😔 This function would like to receive [type-of-page] param from the context as in getStaticProps
const paths = data.map(obj => ({params: {slug: obj.slug}}));
return {paths, fallback: true};
}
My main reason for this is so my client can create pages on the CMS and then Next.js can catch it and generate the page.
Have someone encountered a case like this?
PS: While writing this it just came to my mind that I can just render them all(which is not as optimized as I wish).
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.
-
Hey Guys!
Today while developing a project for a client I just realized I could use
[type-of-page]/[slug].js
, I was planning to have these SSG'd but thegetStaticPath
does not provide any context for the request as ingetStaticProps
. So what I'm trying to do is:My main reason for this is so my client can create
pages
on the CMS and then Next.js can catch it and generate the page.Have someone encountered a case like this?
PS: While writing this it just came to my mind that I can just render them all(which is not as optimized as I wish).
Beta Was this translation helpful? Give feedback.
All reactions