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

Expose currentLang in getStaticProps param #130

Merged
merged 2 commits into from
Dec 15, 2022

Conversation

willybrauner
Copy link
Member

@willybrauner willybrauner commented Dec 15, 2022

currentLang object is needed in getStaticProps route property to request URL by language

   {
    path: "/article/:slug",
    component: ArticlePage,
    name: "Article",
    getStaticProps: async (props, currentLang) => {
      // props contains route props and params (ex: slug: "article-1")
      const res = await fetch(`https://api.com/posts/${currentLang.key}/${props.params.slug}`);
      const api = await res.json();
      return { api };
    }
  }

@willybrauner willybrauner merged commit beee7f7 into v3 Dec 15, 2022
@willybrauner willybrauner mentioned this pull request Dec 15, 2022
Merged
@willybrauner willybrauner deleted the expose-currentLang-in-getStaticProps branch February 9, 2023 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant