(feat): pass locale
to params inside getStaticProps to load content based on locale
#933
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NextJS has a default support for loading content using
locale
. Which means we don't need to manually add the[locale]
route to get it from the URL and pass it to the data fetchers. You can read it more about it here.https://nextjs.org/docs/pages/building-your-application/routing/internationalization#sub-path-routing
You can directly get the
locale from the
contextinside
getStaticProps`.So, we are going to pass the
locale
field to all the data-fetchers by default. This PR only adds support to load content using thelocale
for cms-pages. If the projects are usingcms-list
orcms-item
which usesDataProvider
to fetch the data. Then we need to take the locale from the route usinguseRouter
from nextjs. Which we can discuss further when needed.This
locale
field is used by different cms platforms in their own way, as passing as query-params, post body, gql query etc.