Fix: giscus.html fails when country code is specified.
The problem is that the Giscus API fails when given data-lang of something like de-DE:
This fix uses just the language tag, not the whole language code: https://gohugo.io/methods/site/language/#methods
With this fix:
(live at https://forkful.ai/de/kotlin/good-coding-practices/ )
Deploy Preview for hugo-hextra ready!
| Name | Link |
|---|---|
| Latest commit | 27a70e4c122e0590248f0cb49767403f422d56a9 |
| Latest deploy log | https://app.netlify.com/sites/hugo-hextra/deploys/661dcc21350f64000885cbcf |
| Deploy Preview | https://deploy-preview-358--hugo-hextra.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Thanks for the PR. It makes sense.
I checked the list of available locales on giscus and noticed that zh-CN and zh-TW use mixed casing.
With this change, the giscus will now use the lowercase zh-cn in our example site, which can be seen here:
https://github.com/imfing/hextra/blob/be7e0d3f40f8f39d6323f13c3ae0ef253499ed5d/exampleSite/hugo.yaml#L25
Could you try changing zh-cn to zh-CN in the above link to see if everything still works correctly?
Huh, will do. I'm guessing we need to make a special case for those. And yep, currently on my site, using just zh, it's broken.
With this change, the giscus will now use the lowercase zh-cn in our example site, which can be seen here:
https://github.com/imfing/hextra/blob/be7e0d3f40f8f39d6323f13c3ae0ef253499ed5d/exampleSite/hugo.yaml#L25
Could you try changing
zh-cntozh-CNin the above link to see if everything still works correctly?
I'm confused, sorry. With my change, it will just use the first two letters of the code. Here's my debug output I verified this with:
".Language.Lang": "zh"
".Language.LanguageCode": "zh-CN"
And that currently breaks because giscus doesn't have i18n support for simple zh.
I added special handling for Chinese. I tested it with:
languageCode: zh
languageCode: zh-cn
languageCode: zh-CN
languageCode: zh-tw
languageCode: zh-TW
Awesome,appreciate it 👍 I was asking because of this issue https://github.com/imfing/hextra/issues/231
Will review it later today