strapi / nextjs-corporate-starter

Strapi Demo application for Corporate Websites using Next.js
MIT License
959 stars 285 forks source link

Navbar and Footer not displaying localized content from Strapi CMS in Next.js #58

Closed AnasGamal closed 11 months ago

AnasGamal commented 1 year ago

Bug Description: Next.js Navbar and Footer components do not display localized content that should be fetched from Strapi CMS,. Despite creating localized versions in different languages and adding language-specific content to the header and footer sections in the Strapi CMS, the website only shows the default (i suppose) locale content for the Navbar and Footer across all languages.

Steps to Reproduce:

  1. Go to the Content Manager in Strapi CMS.
  2. Select Global under Single Type.
  3. Create a localized version in another language.
  4. Add language-specific content to the header and footer or any other sections.
  5. Save the changes.
  6. View the website in the selected language.

Expected Result: All homepage sections, including the Navbar and Footer, should display the localized content specific to the selected language.

Actual Result: The Navbar and Footer components continue to display the default locale content across all languages, instead of the expected localized content.

AnasGamal commented 1 year ago

I think the issue stems from the way Global single content type data is fetched from Strapi API in frontend/src/app/[lang]/layout.tsx.

The issue also affects meta data from my experience. I think this is because data for meta data, header, and footer are all imported together from Global content type.

Line 21-34 in frontend/src/app/[lang]/layout.tsx

const urlParamsObject = { populate: [ "metadata.shareImage", "favicon", "notificationBanner.link", "navbar.links", "navbar.navbarLogo.logoImg", "footer.footerLogo.logoImg", "footer.menuLinks", "footer.legalLinks", "footer.socialLinks", "footer.categories", ], };

AnasGamal commented 1 year ago

I created pull request #61 related to this issue, please review it and merge it if it's possible.

PaulBratslavsky commented 11 months ago

You are the best @AnasGamal thank you.