Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic route is not working with index.js #123

Open
subhendukundu opened this issue Feb 14, 2021 · 2 comments
Open

Dynamic route is not working with index.js #123

subhendukundu opened this issue Feb 14, 2021 · 2 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@subhendukundu
Copy link
Contributor

Describe the problem:

Dynamic routing is not able to fetch params with [slug]/index.js.
This is what I am doing so far

export async function getEdgeProps({ params }) {
  const { slug } = params;
  // const post = await getSomeRemotePost({ slug });
  console.log("server", slug);
  return {
    props: {
      slug,
    },
  };
}

export default function Post({ slug }) {
  console.log('client', slug);
  return <div>I'm the {slug}</div>;
}

slug is undefined in this case when localhost:3000/product but localhost:3000/product/index is passing the slug.

If I look at Nextjs, it does reolve it there.

@traffisco
Copy link
Contributor

If all you want is
localhost:3000/slug1
localhost:3000/slug2

Use [slug].js

@subhendukundu
Copy link
Contributor Author

subhendukundu commented Feb 14, 2021

Right! That's correct behavior too. That's how I made it work. example
But theoretically [slug]/index.js should work too. That's where I think this should be supported.
If you look at NextJs, they support it too. Cause index.js by default resolved with the folder name.

@jplhomer jplhomer added help wanted Extra attention is needed good first issue Good for newcomers labels Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants