0
votes

I am facing a problem getting the correct slug in getStaticProps(). I am trying to get translated slug for the page (eg: about page)

getStaticPaths() generates correct obeject. These params are genearte from DatoCMS API

 [
  { params: { slug: 'about-us' }, locale: 'en' },
  { params: { slug: 'ueber-uns' }, locale: 'de' },
  ...  
]

However, when I am on the german page (www.exmaple.com/de/ueber-uns) getStaticProps gives context as below.

{
  params: { slug: 'about-us' }, // it should be `ueber-uns` or ?
  locales: [ 'en', 'de' ],
  locale: 'de', // this is correct 
  defaultLocale: 'en'
}

I am following documentation from here -> https://nextjs.org/docs/advanced-features/i18n-routing#dynamic-getstaticprops-pages

1

1 Answers

0
votes

The getStaticPaths method only defines which “pages” should be statically generated during build time. Your problem will be wrong getStaticProps implementation, imho.

Could you provide us with you getStaticProps implementation?