vercel / swr-site

The official website for SWR.
https://swr.vercel.app
Apache License 2.0
486 stars 353 forks source link

Translate default OG Image #393

Open valentinpolitov opened 1 year ago

valentinpolitov commented 1 year ago

Can we add translations for default OG image https://swr-card.vercel.app ? From the code I can see there is a search param title witch generates dynamic cards on every page except home page. But what about default one, witch is slightly different and it has only english version. Could we add another search param like ?lang=${locale} or maybe a rout /${locale} that will consume translations from TITLE_WITH_TRANSLATIONS constant in theme.config.js

shuding commented 1 year ago

I think we can already do it with today's setup, it's just that we need to design multiple cards (it's not dynamic). The real tricky thing is when you share the homepage on social media, the crawler doesn't know about the actual viewer's language settings. For example when you share SWR's site on Twitter, people with different Twitter language settings still see the same card.

guilherssousa commented 1 year ago

For example when you share SWR's site on Twitter, people with different Twitter language settings still see the same card.

It could share based on the URL locale, even if you load the page via the root endpoint without a locale id, the NEXT_LOCALE will be populated, or not? So by sending the URL like https://swr.vercel.app/es-ES/docs/getting-started should render a card with es-ES?

Twitter users not seeing the card in different languages shouldn't be a problem since most of the time you only share a non-English documentation link to someone that speaks that non-English language or to a community with speakers of that language