You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Nextjs frontend and I'd like to add canonical URLs based on a pages collection. I use GraphQL to fetch the data and I'm looking for a way to get the other slug field of the other languages.
Does anyone know an easier solution than using aliases for each locale? My initial idea was like this:
Hotels(locale: en, where: { slug: { equals: "${slug}" } }) { docs: { ... } } // current page is en, so I fetch the others as well
deHotels: Hotels(locale: de, where: { slug: { equals: "${slug}" } }) { docs: { slug } }
frHotels: Hotels(locale: fr, where: { slug: { equals: "${slug}" } }) { docs: { slug } }
...
}
This doesn't work, because the current slug doesn't match the slug in the other languages.
In the best case, I simply select the slug field of all locales when fetching the current locales document.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a Nextjs frontend and I'd like to add canonical URLs based on a pages collection. I use GraphQL to fetch the data and I'm looking for a way to get the other slug field of the other languages.
Does anyone know an easier solution than using aliases for each locale? My initial idea was like this:
This doesn't work, because the current slug doesn't match the slug in the other languages.
In the best case, I simply select the slug field of all locales when fetching the current locales document.
Beta Was this translation helpful? Give feedback.
All reactions